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
837 stars 359 forks source link

Stack creation fails: "Error occurred while GetObject. S3 Error Code: NoSuchKey." #189

Closed v-karbovnichy closed 1 year ago

v-karbovnichy commented 3 years ago

Describe the bug Stack creation fails with a error. See also #135 for the same error. Logical ID: Helper Status: CREATE_FAILED Status reason : Error occurred while GetObject. S3 Error Code: NoSuchKey. S3 Error Message: The specified key does not exist. (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 39aab78e-c6e9-467e-b401-240e8bac28db; Proxy: null)

To Reproduce Performed all the steps outlined in a Readme.

Expected behavior Expected the Stack to be created successfully.

Please complete the following information about the solution:

Screenshots Will put in comments.

Additional context Is reproducible 100% of the time.

v-karbovnichy commented 3 years ago

image

v-karbovnichy commented 3 years ago

image

v-karbovnichy commented 3 years ago

image

v-karbovnichy commented 3 years ago

image

47812 commented 3 years ago

Hello,

I am having the same error as well.

I am trying to use cdk codepipeline to build and deploy a serverless application(apigateway - lambda) using cdk. The pipeline is building correctly but errors out during deployment which creates the cloudformation template to create lambda and api gateway.

Error: Error occurred while GetObject. S3 Error Code: NoSuchKey. S3 Error Message: The specified key does not exist. (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 6c84cebf-148d-41e6-9753-5ecd8c12b0d8; Proxy: null)

Please help me fix this issue. S3 bucket for the source artifact is created by the pipelinestack.

v-karbovnichy commented 3 years ago

@leavertj could you please have a look?

aijunpeng commented 3 years ago

Hey there, the error is because the solution template can't find the source code packages needed for creating lambda function from your distribution s3 bucket. In readme, step 4 and 6 have instructions about how to create s3 buckets and upload deployment assets to the buckets. Please verify if those s3 buckets exist in your AWS account and if all deployment assets are in the buckets. The assets in buckets should be publicly accessible. One more note: make sure you add region as suffix to your distribution bucket name. Here is an example bucket name: my-dist-bucket-us-east-1. Hope this helps. Thanks!

abbathaw commented 3 years ago

I have the same issue. I have checked that my bucket includes the region suffix (us-east-1) and also checked that the assets exist and the whole bucket is public.

aijunpeng commented 3 years ago

Hey abbathaw, can you please provide a screenshot of your error message and your s3 bucket (redact any sensitive content)? Also are you able to download your assets using the s3 path to your assets https://...?

v-karbovnichy commented 3 years ago

I followed these steps to make objects public in both buckets. The error is the same. image

These are the results of making bucket contents public: image image

aijunpeng commented 3 years ago

Thanks for providing the information. What's your bucket level permission? Your bucket should either open to public or have a bucket policy to grant access at bucket level. You can test it out by downloading your assets using the s3 object url ( https://...).

kstro21 commented 3 years ago

Same issue here, but it has nothing to do with the bucket policy, it is a misleading example in the readme. If we check the templates in the repo we can see this in the Mappings KeyPrefix: '%SOLUTION_NAME%/%VERSION%' so the correct example in the readme should be using the env var $SOLUTION_NAME and not the hardcoded value of aws-waf-security-automations.

Using this deploy successfully

aws s3 cp ./deployment/regional-s3-assets s3://$DIST_OUTPUT_BUCKET-$AWS_REGION/$SOLUTION_NAME/$VERSION \
--recursive --acl bucket-owner-full-control
aijunpeng commented 3 years ago

Thanks for the feedback. Solution name is your choice and the readme only provides an example. We will take a look and see if the readme needs to be more clear.