UPD: clean up aws directory
This commit is contained in:
parent
e6d6b97721
commit
6b8bb00748
|
@ -1,15 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import boto3
|
||||
|
||||
client = boto3.client('config')
|
||||
resp = client.get_discovered_resource_counts()
|
||||
for item in resp['resourceCounts']:
|
||||
print(item['resourceType'])
|
||||
reslist = client.list_discovered_resources(resourceType=item['resourceType'])
|
||||
count = 1
|
||||
# for res in reslist['resourceIdentifiers']:
|
||||
# print(count, res['resourceId'])
|
||||
# count+=1
|
||||
for index, item in enumerate(reslist['resourceIdentifiers'], 1):
|
||||
print(f"{index}. {item['resourceId']}")
|
57
aws/json
57
aws/json
|
@ -1,57 +0,0 @@
|
|||
{
|
||||
"ProtectionGroupId": "Proxies",
|
||||
"Aggregation": "SUM",
|
||||
"Pattern": "ARBITRARY",
|
||||
"Members": [
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0ffe0084439dabfa5",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-05841bc3e86c0a02c",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0c8c1cd56cc6812f0",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0554a730c84838cb2",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-06400a193622f18ef",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0943a26dff737c3bb",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-077d3ec5fd5d5815f",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0ea7ba83567d8dc77",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-00d4f1e5bfe2a29ac",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0f4ea29293daafa0c",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0f17f811a17375567",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-08c66c8d4793f600f",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-052aee7ebca95a297",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0290936c16a783f48",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0cce181acf4f5228b",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0b04be0d39e8b6805",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0ff81f6efa6fb6601",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0780c63f667aa53b1",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0edd524a2afdfc7c0",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0f3c83df95bd6ac76",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0dc990d8299cade51",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0a01d13764e9bb4d9",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-09b9958ddb3fb2b81",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0662c94b444ee6fd7",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-06aeba0dd6bd37bbb",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0064badc3c20d01cb",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-062f18a351eb3c44b",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0d7fabd6b6736d8ba",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-08d9a5fd5a24f6410",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0adda055467e5e5a6",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-01a938dfb927c8f3f",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-03cb14ef5313e4675",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-046e405d363fd4c4f",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0b986e4e5ffd5b1e2",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0ec66214895ce0c7c",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-01ea4b48ec61a3068",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-06abef49b076dd20c",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-056470c9f98dce3fc",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-01e870c66848a8991",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-036e72654499bb46a",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0d52b854250ed9d83",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-01185fd790b008301",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-015859de51da5208c",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-00ee026701f21593f",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-00855bb5bae5e0e8b",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-06038eeb961c72d1a",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0e92317ee06b38396",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-03a47ae15fccad2c5",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-0d13f893a9ac741f0",
|
||||
"arn:aws:ec2:ap-south-1:234605732439:eip-allocation/eipalloc-041d3f17fa7e019f5"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"Metrics": [
|
||||
{
|
||||
"Namespace": "CWAgent",
|
||||
"MetricName": "Memory % Committed Bytes In Use",
|
||||
"Dimensions": [
|
||||
{
|
||||
"Name": "InstanceId",
|
||||
"Value": "i-050d4adeafaa53cd0"
|
||||
},
|
||||
{
|
||||
"Name": "objectname",
|
||||
"Value": "Memory"
|
||||
},
|
||||
{
|
||||
"Name": "ImageId",
|
||||
"Value": "ami-0bb821cb43852704d"
|
||||
},
|
||||
{
|
||||
"Name": "InstanceType",
|
||||
"Value": "t3.large"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Namespace": "CWAgent",
|
||||
"MetricName": "Memory % Committed Bytes In Use",
|
||||
"Dimensions": [
|
||||
{
|
||||
"Name": "InstanceId",
|
||||
"Value": "i-050d4adeafaa53cd0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Namespace": "CWAgent",
|
||||
"MetricName": "LogicalDisk % Free Space",
|
||||
"Dimensions": [
|
||||
{
|
||||
"Name": "InstanceId",
|
||||
"Value": "i-050d4adeafaa53cd0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Namespace": "CWAgent",
|
||||
"MetricName": "LogicalDisk % Free Space",
|
||||
"Dimensions": [
|
||||
{
|
||||
"Name": "instance",
|
||||
"Value": "C:"
|
||||
},
|
||||
{
|
||||
"Name": "InstanceId",
|
||||
"Value": "i-050d4adeafaa53cd0"
|
||||
},
|
||||
{
|
||||
"Name": "objectname",
|
||||
"Value": "LogicalDisk"
|
||||
},
|
||||
{
|
||||
"Name": "ImageId",
|
||||
"Value": "ami-0bb821cb43852704d"
|
||||
},
|
||||
{
|
||||
"Name": "InstanceType",
|
||||
"Value": "t3.large"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
import os.path
|
||||
import boto3
|
||||
import gzip
|
||||
import shutil
|
||||
from botocore.exceptions import ClientError
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.application import MIMEApplication
|
||||
|
||||
s3 = boto3.client("s3")
|
||||
|
||||
|
||||
def lambda_handler(event, context):
|
||||
mail_sender = "abc@abc.com"
|
||||
mail_recipient = "efg@efg.com"
|
||||
aws_region = "ap-east-1"
|
||||
mail_subject = "Monthly billing csv 410429265162"
|
||||
FILEOBJ = event["Records"][0]
|
||||
BUCKET_NAME = str(FILEOBJ['s3']['bucket']['name'])
|
||||
KEY = str(FILEOBJ['s3']['object']['key'])
|
||||
FILE_NAME = os.path.basename(KEY)
|
||||
temp_file = '/tmp/' + FILE_NAME
|
||||
s3.download_file(BUCKET_NAME, KEY, temp_file)
|
||||
with open(temp_file, 'rb') as f_in:
|
||||
with gzip.open('billing-csv.gz', 'wb') as f_out:
|
||||
shutil.copyfileobj(f_in, f_out)
|
||||
ATTACHMENT = '/tmp/billing-csv.gz'
|
||||
BODY_TEXT = "The Object file was uploaded to S3"
|
||||
client = boto3.client('ses',region_name=aws_region)
|
||||
msg = MIMEMultipart()
|
||||
# Add subject, from and to lines.
|
||||
msg['Subject'] = mail_subject
|
||||
msg['From'] = mail_sender
|
||||
msg['To'] = mail_recipient
|
||||
textpart = MIMEText(BODY_TEXT)
|
||||
msg.attach(textpart)
|
||||
att = MIMEApplication(open(ATTACHMENT, 'rb').read())
|
||||
att.add_header('Content-Disposition','attachment',filename=ATTACHMENT)
|
||||
msg.attach(att)
|
||||
print(msg)
|
||||
try:
|
||||
response = client.send_raw_email(
|
||||
Source=mail_sender,
|
||||
Destinations=[mail_sender,mail_recipient],
|
||||
RawMessage={ 'Data':msg.as_string() }
|
||||
)
|
||||
except ClientError as e:
|
||||
print(e.response['Error']['Message'])
|
||||
else:
|
||||
print("Email sent! Message ID:",response['MessageId'])
|
Loading…
Reference in New Issue