Skip to content

Instantly share code, notes, and snippets.

View ramtamilan's full-sized avatar

Ramaswamy Arunachalam ramtamilan

View GitHub Profile
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:DescribeTags",
"ec2:DescribeInstances"
],
"Resource": "*",
"Effect": "Allow"
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::Mainaccount:role/lambda-execution-role"
},
"Action": "sts:AssumeRole"
}
##Import Libraries
import json
import boto3
import jmespath
## Recieve event from Cloud watch Event bus
## Variable "ID" get the instance id which triggered the alert.
## Variable "Sourceaccount" gets the account information from where the Cloudwatch rule triggered.
def lambda_handler(event, context):
print('Input received:')
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Assumerole",
"Effect": "Allow",
"Action": [
"sts:AssumeRole"
],
"Resource": "arn:aws:iam::*:role/cross-account-role"