[codepipeline] CDK Deploy-Step Fails - Lambda Assets not uploaded to S3 after build -- "Error occurred while GetObject. S3 Error Code: NoSuchKey"
See original GitHub issue❓ General Issue
I did build a CDK application (let’s call it app “A”) including multiple lambda functions (all single file python code - no dependencies). This CDK application works great and deploys just fine from my local CLI.
Now, I want to deploy app “A” using a CICD Pipeline via a 2nd separate CDK application.
- I pull the source from a source commit repo - works fine.
- I build app “A” using a codeBuild job with a custom buildspec.yml (including the
cdk synth
call). This works fine. The output artifact contains the expectedcdk.out
including the usual content. - Now i want to deploy my application. I pass the output artifact from the build step into a CloudFormationCreateUpdateStackAction() (see code below).
PROBLEM:
The CloudFormation deploy step fails.
The CloudFormation deploy fails with the 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: 7dbfdd63-58cb-4e58-b005-0a464d1b1055; Proxy: null)
After closer inspection of the generated CFN template, I notice that the Lambda functions code property references the cdk S3 Bucket and Key (see below). The problem is that the S3 Bucket is empty. It doesn’t contain the Key!
The Question
How do I get the lambda assets from the build step uploaded to the S3 bucket so that CloudFormationCreateUpdateStackAction() can deploy the stack?
What am I missing here?
Or should I deploy my cloudformation using another codebuilld action with a cdk deploy
inside?
Environment
- CDK CLI Version: 1.69.0 (build 2b474b9)
- Module Version: 1.69.0
- Node.js Version: v10.15.0
- OS: OSX Catalina
- Language (Version): Python (3.7)
Other information
Action used to deploy the CloudFormation: The cdk.out content is passed via the artifact source_output_build.
action = codepipeline_actions.CloudFormationCreateUpdateStackAction(
action_name=action_name,
admin_permissions=True,
stack_name=stack_name,
replace_on_failure=True,
template_path= source_output_build.at_path(template_path),
capabilities=[
cloudformation.CloudFormationCapabilities.NAMED_IAM,
cloudformation.CloudFormationCapabilities.ANONYMOUS_IAM,
cloudformation.CloudFormationCapabilities.AUTO_EXPAND
],
run_order=1,
region=region,
extra_inputs=[source_output_build]
)
Output of template.json with S3Bucket referncnce (the key doesn’t exist - bucket is empty)
"IntegrationTestTriggerXXXX": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": "cdk-hnb6XXXXXX26-eu-west-1",
"S3Key": "da663XXXXXXXXbc09fa27e9.zip"
},
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:18 (7 by maintainers)
Top GitHub Comments
are you from this planet ? Did you read the problem ?
This happened to me when I forgot to update pipeline (didn’t enable selfMutation). Updating pipeline fixed the issue.
It turns out that some assets building action (in
Assets
stage) were missing. Redeploying creates those missing actions.