Lambda Parameters are missing when deploying with CodeDeploy
See original GitHub issueNote: for support questions, please first reference our documentation, then use Stackoverflow. This repository’s issues are intended for feature requests and bug reports.
-
I’m submitting a …
- 🪲 bug report
- 🚀 feature request
- 📚 construct library gap
- ☎️ security issue or vulnerability => Please see policy
- ❓ support request => Please see note at the top of this template.
-
What is the current behavior? If the current behavior is a 🪲bug🪲: Please provide the steps to reproduce
Can’t deploy a golang-lambda function through CodeDeploy. CloudFormationCreateUpdateStackAction and CloudFormationCreateReplaceChangeSetAction + CloudFormationExecuteChangeSetAction both don’t work. But when I deploy with cdk deploy from my local machine everything works as intended
Error Message:
Parameters: [getPictureCodeS3VersionKey7D69AA08, getPictureCodeArtifactHash67916A64, getPictureCodeS3Bucket4AE043CC] must have values (Service: AmazonCloudFormation; Status Code: 400; Error Code: ValidationError; Request ID: f89c844e-aeed-11e9-a28d-0f1fe7196728)
I double checked the generated cfn template and it contains the custom parameters for the lambda
"Parameters": {
"getPictureCodeS3Bucket4AE043CC": {
"Type": "String",
"Description": "S3 bucket for asset \"FirstCdkStackStack/getPicture/Code\""
},
"getPictureCodeS3VersionKey7D69AA08": {
"Type": "String",
"Description": "S3 key for asset version \"FirstCdkStackStack/getPicture/Code\""
},
"getPictureCodeArtifactHash67916A64": {
"Type": "String",
"Description": "Artifact hash for asset \"FirstCdkStackStack/getPicture/Code\""
}
}
this is my cdk code. I added all the files to the artifacts in case something was missing.
const getPicture = new lambda.Function(this, 'getPicture', {
code: lambda.Code.asset('handler'),
handler: 'main',
runtime: lambda.Runtime.GO_1_X,
})
const repo = new codecommit.Repository(this, 'Repo', {
repositoryName: 'FirstCDKStackStack'
});
const sourceOutput = new codepipeline.Artifact();
const sourceAction = new codepipeline_actions.CodeCommitSourceAction({
actionName: 'CodeCommit',
repository: repo,
output: sourceOutput,
});
var project = new codebuild.PipelineProject(this, 'MyProject2', {
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
install: {
commands: [
"go get github.com/aws/aws-lambda-go/events",
"go get github.com/aws/aws-lambda-go/lambda",
]
},
build: {
commands: [
"go build -o handler/main handler/get-picture.go",
"ls",
],
},
},
artifacts: {
files: ["*", "bin/*", "lib/*", "handler/*" ],
}
}),
});
const goBuildOutput = new codepipeline.Artifact();
const goBuildAction = new codepipeline_actions.CodeBuildAction({
actionName: 'goBuild',
project,
input: sourceOutput,
outputs: [goBuildOutput],
});
var project = new codebuild.PipelineProject(this, 'MyProject', {
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
install: {
commands: [
"npm install",
"npm install -g cdk",
"npm install -g typescript",
]
},
build: {
commands: [
"tsc",
"cdk synth",
],
},
},
artifacts: {
files: ["*", "bin/*", "lib/*", "cdk.out/*", "handler/*" ],
}
}),
});
const cfnBuildOutput = new codepipeline.Artifact();
const cfnBuildAction = new codepipeline_actions.CodeBuildAction({
actionName: 'cfnBuild',
project,
input: goBuildOutput,
outputs: [cfnBuildOutput],
});
const pipeline = new codepipeline.Pipeline(this, 'MyPipeline', {
stages: [
{
stageName: 'source',
actions: [sourceAction],
},
{
stageName: 'build-go',
actions: [goBuildAction],
},
{
stageName: 'build-cfn',
actions: [cfnBuildAction],
},
],
});
const changeSetOutput = new codepipeline.Artifact();
pipeline.addStage({
stageName: 'changeset',
actions: [
new codepipeline_actions.CloudFormationCreateUpdateStackAction({
templatePath: cfnBuildOutput.atPath('cdk.out/FirstCdkStackStack.template.json'),
adminPermissions: true,
stackName: 'FirstCdkStackStack',
actionName: 'create_update_stack',
output: changeSetOutput,
})
]
})
//this doesnt work either
// pipeline.addStage({
// stageName: 'changeset',
// actions: [
// new codepipeline_actions.CloudFormationCreateReplaceChangeSetAction({
// templatePath: cfnBuildOutput.atPath('cdk.out/FirstCdkStackStack.template.json'),
// adminPermissions: true,
// stackName: 'FirstCdkStackStack',
// actionName: 'create_change_set',
// output: changeSetOutput,
// changeSetName: 'changeset',
// })
// ]
// })
// pipeline.addStage({
// stageName: 'deploy',
// actions: [
// new codepipeline_actions.CloudFormationExecuteChangeSetAction({
// stackName: 'FirstCdkStackStack',
// actionName: 'execute_change_set',
// changeSetName: 'changeset',
// })
// ]
// })
}
}
- What is the expected behavior (or behavior of feature suggested)?
CloudDeploy should behave like cdk deploy
- What is the motivation / use case for changing the behavior or adding this feature?
-
Please tell us about your environment:
- CDK CLI Version: 1.1.0 (build 1a11e96)
- Module Version: xx.xx.xx
- OS: Windows10 locally, the default image in CodeBuild
- Language: TypeScript
-
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
DQIkGGp.zip this is the output that gets passed to the deploy stage.
Issue Analytics
- State:
- Created 4 years ago
- Comments:20 (8 by maintainers)
Top GitHub Comments
Multiple Lambdas are very similar to one Lambda, and depend on whether your functions share the same bundle, or not.
CfnParametersCode
instance for theircode
property, but just differ in the entrypoint. So, like @wange011 said, you would have:All of the rest is the same as the example.
CfnParametersCode
for each, and then a separate build artifact in your lambda-bundling CodeBuild project; so, something like this:You can check out this example as well.
Thanks, Adam
@skinny85 I went with the original proposal after all, it works as expected.
But I’m unclear how to handle multiple lambdas, normally I would specify the path in the code property.
For reference, I’m building a stepfunction that is triggered on putObject in a bucket, the first lambda is downloading the csv converting it to parquet and uploading the file to another bucket, with the second lambda I want to query the parquet file with athena. The last step would be to read the result and write it to dynamodb.