aws-solutions / smart-product-solution

The Smart Product Solution is a customer deployable reference architecture to help manufacturers to jumpstart development of innovative connected/smart product services.
Apache License 2.0
28 stars 20 forks source link

Stack creation fails on CICDCustomResource creation #23

Open halfn0rmal opened 2 years ago

halfn0rmal commented 2 years ago

I have run through the build as per the readme instructions. The stack creation gets to the CICDCustomResource step and fails with event description:

Received response status [FAILED] from custom resource. Message returned: See the details in CloudWatch Log Stream: 2022/07/11/[$LATEST]f6f0c3911a0045189d0eb9f2d5768fe7 (RequestId: 6279b397-813e-4472-93bf-ccff21981233)

Cloudwatch logs for the event shows:

{
    "Status": "FAILED",
    "Reason": "See the details in CloudWatch Log Stream: 2022/07/11/[$LATEST]f6f0c3911a0045189d0eb9f2d5768fe7 ",
    "PhysicalResourceId": "2022/07/11/[$LATEST]f6f0c3911a0045189d0eb9f2d5768fe7",
    "StackId": "arn:aws:cloudformation:ap-southeast-2:019156605395:stack/xincIoT/321826a0-016d-11ed-88d3-0219e5a28b7a",
    "RequestId": "6279b397-813e-4472-93bf-ccff21981233",
    "LogicalResourceId": "CICDCustomResource",
    "Data": {
        "Error": {
            "message": "Access Denied",
            "code": "AccessDenied",
            "region": null,
            "time": "2022-07-11T23:01:38.693Z",
            "requestId": "3W5TDFTCMF7XZFTT",
            "extendedRequestId": "wkQ0Mai3l+s7MEuw2OLyZZTH6gSah5cxWQmxPnZVdO0yYnIWStGsQBKQc1EnLCQmCVzR+EdZURA=",
            "statusCode": 403,
            "retryable": false,
            "retryDelay": 70.3567942522274
        }
    }
}

I can see that the lambda fails on requesting the file smart-product-solution.zip from the s3 bucket. This s3 bucket is correct but the file smart-product-solution.zip does not exist.

        const _repo = process.env.CODECOMMIT_REPO
        const s3Bucket = process.env.CODE_BUCKET;
        const s3Key = process.env.CODE_KEY;
        const codeSource = process.env.CODE_SOURCE;
        const s3params = {
          Bucket: s3Bucket,
          Key: `${s3Key}/${codeSource}`
        };

        Logger.log(
          Logger.levels.ROBUST,
          `${event.LogicalResourceId}:${event.RequestType}` //<< this logs "xincIoT/1.0.0/smart-product-solution.zip"
        );

        const file = fs.createWriteStream('/tmp/smart-product-solution.zip'); 
        let smartProductData = await s3.getObject(s3params).promise();//<<<This line here is where is fails
        file.write(smartProductData.Body, () => {
          file.end();
        });

I have looked through build-s3-dist.sh and can't see anywhere that references smart-product-solution.zip. Is there something missing here?

halfn0rmal commented 2 years ago

This is the same error as a previously unresolved issue that was closed by the author. https://github.com/aws-solutions/smart-product-solution/issues/20