-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CodePipeline construct doesn't allow naming Stages/Action from CFN parameters #6275
Comments
Hey @t04glovern , thanks for opening the issue. Due to some technical reasons, you cannot use deploy-time values like parameters for the names of stages and actions in the CodePipeline construct. However, you can use escape hatches to work around this limitation. Try this: // this part is the same as your code
const actionName = new cdk.CfnParameter(this, 'action-name', {
type: 'String',
description: `Action name`,
}).valueAsString;
const temp_lambda = new lambda.Function(this, 'temp-lambda', {
runtime: lambda.Runtime.NODEJS_10_X,
handler: 'index.handler',
code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
});
const s3_source_bucket = new s3.Bucket(this, 'source-bucket', {
versioned: true
});
const source_output = new codepipeline.Artifact();
const source_action = new codepipeline_actions.S3SourceAction({
actionName: 's3_source',
bucket: s3_source_bucket,
output: source_output,
bucketKey: 'app.zip'
});
const deployStage = new codepipeline_actions.LambdaInvokeAction({
lambda: temp_lambda,
actionName: 'Deploy', // just use a specific name here
});
const pipeline = new codepipeline.Pipeline(this, 'pipeline', {
pipelineName: `pipeline`,
stages: [
{
stageName: 'Source',
actions: [
source_action
]
},
{
stageName: 'Deploy',
actions: [
deployStage
]
}
]
});
// this is the escape hatch
const cfnPipeline = pipeline.node.defaultChild as codepipeline.CfnPipeline;
cfnPipeline.addPropertyOverride('Stages.1.Actions.0.ActionName', actionName); And the resulting template (fragment): pipelineDBECAE49:
Type: AWS::CodePipeline::Pipeline
Properties:
RoleArn:
Fn::GetAtt:
- pipelineRole55399C5D
- Arn
Stages:
- Actions:
- ActionTypeId:
Category: Source
Owner: AWS
Provider: S3
Version: "1"
Configuration:
S3Bucket:
Ref: sourcebucketE323AAE3
S3ObjectKey: app.zip
Name: s3_source
OutputArtifacts:
- Name: Artifact_Source_s3_source
RoleArn:
Fn::GetAtt:
- pipelineSources3sourceCodePipelineActionRoleBB7011C1
- Arn
RunOrder: 1
Name: Source
- Actions:
- ActionTypeId:
Category: Invoke
Owner: AWS
Provider: Lambda
Version: "1"
Configuration:
FunctionName:
Ref: templambdaD9BF7305
Name: Deploy
RoleArn:
Fn::GetAtt:
- pipelineDeployCodePipelineActionRole251092A7
- Arn
RunOrder: 1
ActionName:
Ref: actionname
Name: Deploy Note that until #1237 lands, you won't be able to deploy this template using Thanks, |
Closing for now since there hasn't been a response in a while. Feel free to reopen. |
We are trying to introduce a parameterised name for a pipeline stage action. However when trying to synth out the replace, we are receiving the following error
Cannot use tokens in construct ID: ${Token[TOKEN.11]}
.We've tried to reference the parameter in other places in the template to confirm it's a problem exclusive to the
Pipeline
construct.Reproduction Steps
Error Log
Environment
Other
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: