This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": [ | |
"ec2:DescribeTags", | |
"ec2:DescribeInstances" | |
], | |
"Resource": "*", | |
"Effect": "Allow" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "arn:aws:iam::Mainaccount:role/lambda-execution-role" | |
}, | |
"Action": "sts:AssumeRole" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##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:') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "Assumerole", | |
"Effect": "Allow", | |
"Action": [ | |
"sts:AssumeRole" | |
], | |
"Resource": "arn:aws:iam::*:role/cross-account-role" |