aws-solutions / aws-waf-security-automations

This solution automatically deploys a single web access control list (web ACL) with a set of AWS WAF rules designed to filter common web-based attacks.
https://aws.amazon.com/solutions/aws-waf-security-automations
Apache License 2.0
843 stars 361 forks source link

IAM Role for Custom Resource - Invoke Function Policy fails with long CF stack names #143

Closed ghost closed 2 years ago

ghost commented 4 years ago

Describe the bug If the stack name is long and is getting truncated on lambda names creation, the Invoke Function policy on the IAM Role for Custom Resources does not work.

To Reproduce Create a new deployment using the quickstart. Name the Cloudformation Stack with a custom name such as: testDeployment-Developer-12-waf-security-automations-drupal-300

Expected behavior No errors are thrown

Please complete the following information about the solution:

Screenshots n/a - see above for error

Additional context Cloudformation is shortening the resource names for lambda functions, so the following policy using the AWS::StackName will not work:

The Stack Name was: testDeployment-developer-12-waf-security-automations-drupal-300 The lambda function name that got created was: testDeployment-developer-12-waf-s-AddAthenaPartitions-1GOE8YBUON14

AWS::StackName for the IAM policy won't work in this situation.

This could be solved by using tags on the lambda functions and then locking down the lambda:InvokeFunction with a condition on the policy looking for a specific tag. For our testing of the quickstart, we removed ${AWS::StackName} and left just "*" but this is not ideal and we won't be moving to production with that test policy.

praveenis commented 4 years ago

Hi @brentbain ,

We have added this issue to our backlog for upcoming release and we will update the thread once the fix for the issue is released.

Thanks, Praveen

hongyuanlei commented 3 years ago

I'm facing the same issue, I think it is better to add some comments in the readme file to mention this.

dscpinheiro commented 2 years ago

Hi!

We just released v3.2.0 of the solution, and this issue has been fixed.