Search code examples
amazon-web-servicesamazon-s3aws-cloudformationaws-codepipeline

Git Webhooks with AWS services template doesn't work


I'm following the instruction here in order to automate deployment of static site from GitHub to S3.

However, when I started the template (with the right region us-east-1, the default template is Ohio us-east-2), I have these errors:

CREATE_FAILED   AWS::KMS::Key   KMSKey  Resource creation cancelled
17:45:43 UTC-0500   
CREATE_FAILED   AWS::CloudFormation::CustomResource CopyZips    Failed to create resource. See the details in CloudWatch Log Stream: 2019/01/29/[$LATEST]...

I check CloudWatch Log and get this:

[ERROR] 2019-01-29T22:45:41.776Z    ... Exception: An error occurred (NoSuchBucket) when calling the CopyObject operation: The specified bucket does not exist

It looks like the S3 bucket that contains the template or the zip file doesn't exist anymore. Can you help?

I tried the template with default region: us-east-2 and it works.

Thank you.


Solution

  • If you're using GitHub (not GitHub enterprise) then CodePipeline supports webhooks out of the box and you don't need to use the method described in that white-paper.

    Instead, you can simply add a GitHub action to your pipeline via the console. If you're using CloudFormation you can find instructions here: https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-webhooks-create-cfn.html

    CodePipeline also recently added S3 deploy action which can simplify that too: https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-s3deploy.html