Skip to content

AWS Lambda function to allow CloudFlare web access via security group

Notifications You must be signed in to change notification settings

sys0dm1n/lambda-cloudflare-ip-security-group-update

Repository files navigation

lambda-cloudflare-ip-security-group-update

Using a Lambda function to automate creating and updating a Security Group of Cloudflares IPv4 addresses.

Configure triggers using CloudWatch Events

  • Schedule expression: rate(1 day)
  • Enabled

Function code for cloudflare

  • Python 2.7

Environment variables

key: PORTS_LIST value: 80,443

key: SECURITY_GROUP_ID value: add your security group id here

If required you can create a custom security group using the below command line:

aws ec2 create-security-group --group-name cloudflare-access --description "cloudflare IPs access" --vpc-id VPC-ID-GOES-HERE

Create a custom role

  • Role Name: cloudflare-ip-security-group-update

Required rule to allow the lambda function to edit the security group, use the content of the allow-ec2-security-group-role file

Time out

Set the Timeout to 8 seconds

Room for improvement

If you happen to find something not to your liking, you are welcome to send a PR.

Ref.:

About

AWS Lambda function to allow CloudFlare web access via security group

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages