aws-samples / amazon-cloudfront-secure-static-site

Create a secure static website with CloudFront for your registered domain.
Apache License 2.0
385 stars 140 forks source link

The following resource(s) failed to create: [CFNCustomProvider] #39

Closed jakxnz closed 2 years ago

jakxnz commented 3 years ago

I can't seem to successfully deploy with command aws cloudformation deploy, or find any resources about the error:

Embedded stack arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name-CustomResourceStack-7DW59NE2GVAK/e7a068f0-198f-11ec-aa73-02f20e17bf6a was not successfully created: The following resource(s) failed to create: [CFNCustomProvider].

Steps to reproduce:

aws s3 mb s3://name-artifacts --region ap-southeast-2
make_bucket: name-artifacts
aws cloudformation package \
    --region ap-southeast-2 \
    --template-file templates/main.yaml \
    --s3-bucket name-artifacts \
    --output-template-file packaged.template
aws cloudformation deploy \
    --region ap-southeast-2 \
    --stack-name name \
    --template-file packaged.template \
    --capabilities CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \
    --parameter-overrides DomainName=mydomain.com SubDomain=www

Expected result:

Actual result:

The deployment fails during CREATE_IN_PROGRESS.

CLI outputs:

Waiting for changeset to be created..
Waiting for stack create/update to complete

Failed to create/update the stack. Run the following command
to fetch the list of events leading up to the failure
aws cloudformation describe-stack-events --stack-name name

aws cloudformation describe-stack-events --stack-name name:

{
    "StackEvents": [
        {
            "StackId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "EventId": "35707430-1990-11ec-8908-0268dfce7816",
            "StackName": "name",
            "LogicalResourceId": "name",
            "PhysicalResourceId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2021-09-19T21:26:10.406000+00:00",
            "ResourceStatus": "ROLLBACK_COMPLETE"
        },
        {
            "StackId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "EventId": "CustomResourceStack-DELETE_COMPLETE-2021-09-19T21:26:09.891Z",
            "StackName": "name",
            "LogicalResourceId": "CustomResourceStack",
            "PhysicalResourceId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name-CustomResourceStack-7DW59NE2GVAK/e7a068f0-198f-11ec-aa73-02f20e17bf6a",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2021-09-19T21:26:09.891000+00:00",
            "ResourceStatus": "DELETE_COMPLETE",
            "ResourceProperties": "{\"TemplateURL\":\"https://s3.ap-southeast-2.amazonaws.com/name-artifacts/11b1cecde084b69018f7111349ffd773.template\",\"Tags\":[{\"Value\":\"ACFS3\",\"Key\":\"Solution\"}]}"
        },
        {
            "StackId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "EventId": "CustomResourceStack-DELETE_IN_PROGRESS-2021-09-19T21:25:47.897Z",
            "StackName": "name",
            "LogicalResourceId": "CustomResourceStack",
            "PhysicalResourceId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name-CustomResourceStack-7DW59NE2GVAK/e7a068f0-198f-11ec-aa73-02f20e17bf6a",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2021-09-19T21:25:47.897000+00:00",
            "ResourceStatus": "DELETE_IN_PROGRESS",
            "ResourceProperties": "{\"TemplateURL\":\"https://s3.ap-southeast-2.amazonaws.com/name-artifacts/11b1cecde084b69018f7111349ffd773.template\",\"Tags\":[{\"Value\":\"ACFS3\",\"Key\":\"Solution\"}]}"
        },
        {
            "StackId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "EventId": "20568990-1990-11ec-9f66-0238336d1d20",
            "StackName": "name",
            "LogicalResourceId": "name",
            "PhysicalResourceId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2021-09-19T21:25:35.007000+00:00",
            "ResourceStatus": "ROLLBACK_IN_PROGRESS",
            "ResourceStatusReason": "The following resource(s) failed to create: [CustomResourceStack]. Rollback requested by user."
        },
        {
            "StackId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "EventId": "CustomResourceStack-CREATE_FAILED-2021-09-19T21:25:34.317Z",
            "StackName": "name",
            "LogicalResourceId": "CustomResourceStack",
            "PhysicalResourceId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name-CustomResourceStack-7DW59NE2GVAK/e7a068f0-198f-11ec-aa73-02f20e17bf6a",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2021-09-19T21:25:34.317000+00:00",
            "ResourceStatus": "CREATE_FAILED",
            "ResourceStatusReason": "Embedded stack arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name-CustomResourceStack-7DW59NE2GVAK/e7a068f0-198f-11ec-aa73-02f20e17bf6a was not successfully created: The following resource(s) failed to create: [CFNCustomProvider]. ",
            "ResourceProperties": "{\"TemplateURL\":\"https://s3.ap-southeast-2.amazonaws.com/name-artifacts/11b1cecde084b69018f7111349ffd773.template\",\"Tags\":[{\"Value\":\"ACFS3\",\"Key\":\"Solution\"}]}"
        },
        {
            "StackId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "EventId": "CustomResourceStack-CREATE_IN_PROGRESS-2021-09-19T21:24:00.048Z",
            "StackName": "name",
            "LogicalResourceId": "CustomResourceStack",
            "PhysicalResourceId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name-CustomResourceStack-7DW59NE2GVAK/e7a068f0-198f-11ec-aa73-02f20e17bf6a",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2021-09-19T21:24:00.048000+00:00",
            "ResourceStatus": "CREATE_IN_PROGRESS",
            "ResourceStatusReason": "Resource creation Initiated",
            "ResourceProperties": "{\"TemplateURL\":\"https://s3.ap-southeast-2.amazonaws.com/name-artifacts/11b1cecde084b69018f7111349ffd773.template\",\"Tags\":[{\"Value\":\"ACFS3\",\"Key\":\"Solution\"}]}"
        },
        {
            "StackId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "EventId": "CustomResourceStack-CREATE_IN_PROGRESS-2021-09-19T21:23:59.151Z",
            "StackName": "name",
            "LogicalResourceId": "CustomResourceStack",
            "PhysicalResourceId": "",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2021-09-19T21:23:59.151000+00:00",
            "ResourceStatus": "CREATE_IN_PROGRESS",
            "ResourceProperties": "{\"TemplateURL\":\"https://s3.ap-southeast-2.amazonaws.com/name-artifacts/11b1cecde084b69018f7111349ffd773.template\",\"Tags\":[{\"Value\":\"ACFS3\",\"Key\":\"Solution\"}]}"
        },
        {
            "StackId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "EventId": "e49a06c0-198f-11ec-9bbe-06bff3cf5060",
            "StackName": "name",
            "LogicalResourceId": "name",
            "PhysicalResourceId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2021-09-19T21:23:54.779000+00:00",
            "ResourceStatus": "CREATE_IN_PROGRESS",
            "ResourceStatusReason": "User Initiated"
        },
        {
            "StackId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "EventId": "e151b990-198f-11ec-b726-02a7eba5ab24",
            "StackName": "name",
            "LogicalResourceId": "name",
            "PhysicalResourceId": "arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2021-09-19T21:23:49.376000+00:00",
            "ResourceStatus": "REVIEW_IN_PROGRESS",
            "ResourceStatusReason": "User Initiated"
        }
    ]
}
ConnorKirk commented 2 years ago

Hi Jackson, thanks for raising an issue, and including useful detail. If you check the events in the embedded stack arn:aws:cloudformation:ap-southeast-2:921529881624:stack/name/e15255d0-198f-11ec-b726-02a7eba5ab24, is there a more descriptive reason for theCFNCustomProvider failing?

If there isn't more detail, an alternative place to check is the logs for the lambda function acting as the custom resource CFNCustomProvider. These can be found in the the Cloudwatch logs group for that lambda function.

bob-user commented 2 years ago

Not sure if it's for the exact same reason, but here is an error occuring in the embedded stack :

Resource handler returned message: "Error occurred while GetObject. S3 Error Code: PermanentRedirect. S3 Error Message: The bucket is in this region: us-east-1. Please use this region to retry the request (Service: Lambda, Status Code: 400, Request ID: 61242b39-ccfb-4eec-be99-2f5b73701416, Extended Request ID: null)" (RequestToken: 5f8b59fa-1632-2d4c-7fa1-1477df191d35, HandlerErrorCode: InvalidRequest)

ConnorKirk commented 2 years ago

Hi @bob-user

You might be getting this error if you deploy the template in a region that is not us-east-1. It's a limitation of the current sample that it can only be deployed the region us-east-1. See #19 for the tracking issue.