Skip to content

Instantly share code, notes, and snippets.

@antimius
Created September 11, 2018 13:54
Show Gist options
  • Save antimius/55cc0c6c347da9d3cfeab9b7b8271543 to your computer and use it in GitHub Desktop.
Save antimius/55cc0c6c347da9d3cfeab9b7b8271543 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
MD5=$(curl --silent https://ip-ranges.amazonaws.com/ip-ranges.json | md5)
CF_FUNCTION_ARN=$(aws lambda list-functions | jq -r '.Functions[]|select(.Handler=="update-cloudfront-sg.lambda_handler").FunctionArn')
aws lambda invoke --function-name $CF_FUNCTION_ARN --invocation-type RequestResponse \
--payload "{\"Records\":[{\"EventVersion\":\"1.0\",\"EventSubscriptionArn\":\"arn:aws:sns:EXAMPLE\",\"EventSource\":\"aws:sns\",\"Sns\":{\"SignatureVersion\":\"1\",\"Timestamp\":\"1970-01-01T00:00:00.000Z\",\"Signature\":\"EXAMPLE\",\"SigningCertUrl\":\"EXAMPLE\",\"MessageId\":\"95df01b4-ee98-5cb9-9903-4c221d41eb5e\",\"Message\":\"{\\\"create-time\\\": \\\"yyyy-mm-ddThh:mm:ss+00:00\\\", \\\"synctoken\\\": \\\"0123456789\\\", \\\"md5\\\": \\\"$MD5\\\", \\\"url\\\": \\\"https://ip-ranges.amazonaws.com/ip-ranges.json\\\"}\",\"Type\":\"Notification\",\"UnsubscribeUrl\":\"EXAMPLE\",\"TopicArn\":\"arn:aws:sns:EXAMPLE\",\"Subject\":\"TestInvoke\"}}]}" \
lambda-output.txt
cat lambda-output.txt
@antimius
Copy link
Author

Initial invocation of lambda function to update security groups based on AWS IP Ranges

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment