Lambda code for Creating VPC flow log automatically when a VPC is created

boto3 python aws lambda 5 years ago
from __future__ import print_function import json import os import boto3 import logging def lambda_handler(event, context): detail = event['detail'] eventname = detail['eventName'] if eventname == 'CreateVpc': vpcid = detail['responseElements']['vpc']['vpcId'] region = 'us-east-1' client = boto3.client('ec2') response = client.create_flow_logs( LogDestinationType='s3', LogDestination='arn:aws:s3:::bucket_name', ResourceIds=[ vpcid, ], ResourceType='VPC', TrafficType='ALL' )
2614
Posted By
Usage of Operator functions instead of lambda
import functools
import operator
list = [1, 2, 3, 4, 5]
lambda operator python
harika
Difference between normal def defined functio
li = [4,65,65,23,86,343,75,3,7,5,87,34,5
final_list = list(filter(lambda x: (x%2 
print ("Using Lamba Function:")
lambda python
Ramya Ramya
Deleting Amazon EBS snapshots older than n da
import sys
import boto3
import datetime
python aws boto3
Ramya Ramya
Removing IAM Users from IAM group
def remove_user():
    import boto3
    client = boto3.client('iam')
boto3 aws python
Ramya Ramya
Listing contents of a bucket with boto3
import boto3

_BUCKET_NAME = 'Bucket_name'
boto3 files s3 bucket sub folders python
Reshma
Crating a bucket in S3 using boto3
import boto3
sess = Session(aws_access_key_id='aws_ke
            aws_secret_access_key='aws_s
boto3 s3 create bucket python
Reshma
How to get the list of available files in S3
import boto3

client = boto3.client('s3', aws_access_k
boto3 python list of files in s3
Reshma
PYTHON: To download AWS ELB access log files
import boto3
import datetime
from datetime import datetime,timedelta,
python boto3 s3 aws
Ramya Ramya
PYTHON: AWS IAM password reset
import boto3
client = boto3.client('iam')
UserName=input("Enter UserName:")
boto3 python
Ramya Ramya
Ansible Code to create AWS VPC
---

- name: Create/Delete VPC
ansible aws vpc
sandeep sandeep
Python Script to create AWS beanstalk
#!/usr/bin/python
  
import boto
python aws beanstalk
sandeep sandeep
How to get the master IP Address of EMR Clust
import os
import boto3
session = boto3.Session(profile_name='aw
python aws ipaddress
Reshma
List all files and folders using python os mo
import os

def list_files_folders(path):
python python-os
kishore_kumar
Get current environment variables in python
import os
env = os.environ

python python-os
kishore_kumar
Get os details using python os
import os
print os.uname()
# Don't use os.system('uname -a'), its j
python python-os
kishore_kumar
Get stats ( lines, words, char count ) of fil
def file_stats(path):
    f = open(path, 'r')
    lines = f.readlines()
python
kishore_kumar
Use map function in python
def get_double(num):
    return num * 2

python
kishore_kumar
Python sample codes for beginners
print "Welcome to python"
python
gaya38 gaya38
Python program for even number checking
a=input("Enter a value:")
if (a%2==0):
    print "The given number is even numb
python
gaya38 gaya38
Python program for prime number check
a=input("Enter a value:")
k=0
b=(a/2)+1
python
gaya38 gaya38