Simple Lambda funtion to update a Security Group using a DDNS IP. Useful if you need to update your security group(s) often because of clients using dynamic IPs being used to access your instance.
This is the policy that grants the permissions to modify EC2 security groups and write logs, register it in IAM and create / apply to the role used to execute the function:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"ec2:DescribeSecurityGroups",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:RevokeSecurityGroupIngress"
],
"Resource": "*"
}
]
}Tag the rules of the security group using the description DDNS_Update. Modify the script to use the appropriate dynamic domain and security group id.
- MacK - Initial work - Oddbytes
This project is licensed under the MIT License - see the LICENSE.md file for details
- Lambda function inspired by Grig Gheorghiu's Modifying EC2 security groups via AWS Lambda functions post in Medium and modified slightly.
Made with ❤️ by Oddbytes.