Skip to content
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

The use of replacement variables like '#{var}' is not possible in the cdk to use with resource identifiers, making it impossible to use one single template for a deployment pipeline. #7000

Closed
begoloz opened this issue Mar 25, 2020 · 3 comments
Assignees
Labels
guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@begoloz
Copy link

begoloz commented Mar 25, 2020

❓ General Issue

The Question

How to use variable replacement on the output templates from the stacks of the cdk, when the resource identifiers or fields like the dashboardName do not allow or remove characters like #{ }, necessary for tools like octopus to reference variables assigned during pipeline deployment, which are specific to the stage/environment of delivery, like dev, test or prod ?
E.g.
DashboardName = 'Dashboard-#{environmentVariable}'
and in the deployment pipeline:
#{environmentVariable} would be replaced for values like 'dev', 'test', 'prod'.

Environment

  • CDK CLI Version: 1.22.0
  • Module Version: 1.31.0
  • OS: Windows
  • Language: TypeScript

Other information

I think being able to assign identifiers to the resourses at the moment of deployment is important for a pipeline delivery, and using a single template that can be deployed in different stages.

With changes like Fixes #2976 , it is not possible to assign the DashboardName a replacement variable for pipeline deployment.
I think the name should be able to accept characters like #{ }, for cases when its necessary to add a reference to things like deployment-environment variables to name the construct.
The current DashboardName string validation forces the deployment of multiple static Cloud Formation templates, each one specific to a deployment-environment, only to be able to have names that are environment specific. Instead a better approach would be to have a single template that can be deployed in each environment resulting in dashboards that can be created with names that reference their deployment-environment.

@begoloz begoloz changed the title String validation for CloudFormation DashboardName doesn't allow DashboardName to use replacement variables like '#{var}' use replacement variables like '#{var}' is not possible in the cdk to use with resource identifiers, making it impossible to use one single template for a deployment pipeline. Mar 29, 2020
@begoloz begoloz changed the title use replacement variables like '#{var}' is not possible in the cdk to use with resource identifiers, making it impossible to use one single template for a deployment pipeline. The use replacement variables like '#{var}' is not possible in the cdk to use with resource identifiers, making it impossible to use one single template for a deployment pipeline. Mar 29, 2020
@begoloz begoloz changed the title The use replacement variables like '#{var}' is not possible in the cdk to use with resource identifiers, making it impossible to use one single template for a deployment pipeline. The use of replacement variables like '#{var}' is not possible in the cdk to use with resource identifiers, making it impossible to use one single template for a deployment pipeline. Mar 29, 2020
@SomayaB SomayaB added the bug This issue is a bug. label Mar 30, 2020
@SomayaB SomayaB added the @aws-cdk/core Related to core CDK functionality label Mar 30, 2020
@eladb
Copy link
Contributor

eladb commented Mar 31, 2020

Is this specifically about dashboard names? Can you provide a minimal repro please?

@eladb eladb added @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch and removed @aws-cdk/core Related to core CDK functionality labels Mar 31, 2020
@eladb eladb removed their assignment Mar 31, 2020
@SomayaB SomayaB added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Mar 31, 2020
@SomayaB SomayaB assigned SomayaB and rix0rrr and unassigned SomayaB Mar 31, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Apr 1, 2020

Looks like you are planning to use CDK as a template generator which you intend to run through a template processor, am I getting the use case right?

I'm not sure we want to go to disabling our validations for the minority of people who intend to run the template through a processor, rather than deploy it directly.

We expect the CDK program itself to fill the function of the template processor.

and using a single template that can be deployed in different stages

We generally don't recommend doing this. Instead, trust the CDK app to generate 10 templates for 10 stages that only differ in the way you expect them to differ. If you must use a single template, use CFN parameters.

If you really want to use your own template preprocessor, I recommend using magic strings that pass through the CDK validators unharmed (xxxVARxxx) and using text substitution to replace those with #{var} so that your template processor will interpret them as you desire.

@rix0rrr rix0rrr added guidance Question that needs advice or information. and removed bug This issue is a bug. @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch labels Apr 1, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Apr 7, 2020

Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

4 participants