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

chore(ssm): latest parameter value with dynamic reference #14205

Merged
merged 20 commits into from
Apr 21, 2021

Conversation

jogold
Copy link
Contributor

@jogold jogold commented Apr 16, 2021

CloudFormation now allows referencing the latest Systems Manager parameter
values in templates without specifying parameter versions using dynamic
references.

Remove the "trick" with the Parameter using a default value.

See https://aws.amazon.com/about-aws/whats-new/2021/04/now-reference-latest-aws-systems-manager-parameter-values-in-aws-cloudformation-templates-without-specifying-parameter-versions/


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Apr 16, 2021

@github-actions github-actions bot added the @aws-cdk/aws-ssm Related to AWS Systems Manager label Apr 16, 2021
@jogold
Copy link
Contributor Author

jogold commented Apr 16, 2021

⚠️ This will influence the following behavior:

if (await canSkipDeploy(options, cloudFormationStack, stackParams.hasChanges(cloudFormationStack.parameters))) {
debug(`${deployName}: skipping deployment (use --force to override)`);
return {
noOp: true,
outputs: cloudFormationStack.outputs,
stackArn: cloudFormationStack.stackId,
stackArtifact,
};

and

public hasChanges(currentValues: Record<string, string>): boolean {
// If any of the parameters are SSM parameters, deploying must always happen
// because we can't predict what the values will be.
if (Object.values(this.formalParams).some(p => p.Type.startsWith('AWS::SSM::Parameter::'))) {
return true;
}

= stacks that previously had Parameters with default values to reference latest SSM parameters where never skipped now they will be...

@jogold
Copy link
Contributor Author

jogold commented Apr 19, 2021

⚠️ This will influence the following behavior:

if (await canSkipDeploy(options, cloudFormationStack, stackParams.hasChanges(cloudFormationStack.parameters))) {
debug(`${deployName}: skipping deployment (use --force to override)`);
return {
noOp: true,
outputs: cloudFormationStack.outputs,
stackArn: cloudFormationStack.stackId,
stackArtifact,
};

and

public hasChanges(currentValues: Record<string, string>): boolean {
// If any of the parameters are SSM parameters, deploying must always happen
// because we can't predict what the values will be.
if (Object.values(this.formalParams).some(p => p.Type.startsWith('AWS::SSM::Parameter::'))) {
return true;
}

= stacks that previously had Parameters with default values to reference latest SSM parameters where never skipped now they will be...

Decided to not skip deploy if a {{resolve:ssm:param}} is detected in the template.

@mergify
Copy link
Contributor

mergify bot commented Apr 21, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 13909c5
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Apr 21, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 9e421e5 into aws:master Apr 21, 2021
@mjgp2
Copy link

mjgp2 commented May 4, 2021

Hi @jogold

This change doesn't work if you are trying to update a stack without changing the template, because CF does not register these {{ssm}} template values as parameters, and so will not you create a changeset because it thinks nothing has changed as it doesn't seem to be smart enough to determine that there is a change? This fundamentally breaks a CI pattern we have where we are updating the SSM value for a ECR image, and then updating the stack using the current template via AWS CLI.

@jogold
Copy link
Contributor Author

jogold commented May 4, 2021

@MrArnoldPalmer what do you think?

I understand how it breaks things here for this use case but on the other hand the new behavior is more deterministic which is more in line with how the CDK normally behaves?

@mjgp2 how are you updating the SSM value? manually and then you don't want to copy the new version in your stack?

@mjgp2
Copy link

mjgp2 commented May 4, 2021

SSM values can be updated by a whole bunch of processes within Ops. The main thing for us it to be able to apply these SSM parameters to an existing cloudformation stack as part of automation (such as CI or release processes) but guarantee no change in the stack other than the parameters. Difference IAM roles are allowed to update certain SSM parameters than update a stack.

It seems fundamentally that perhaps this is a cloudformation issue, because my expectation (even without using CDK) would be that I can refresh the parameters in a stack. This inline syntax does not allow it.

As this is a breaking change I would very much suggest that there is the option for either underlying CF template to be generated while CF sorts out the differences between the parameter behaviour and the inline template behaviour.

jogold added a commit to jogold/aws-cdk that referenced this pull request May 4, 2021
mergify bot pushed a commit that referenced this pull request May 4, 2021
This reverts commit 9e421e5 (#14205).

Closes #14476


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@mjgp2
Copy link

mjgp2 commented May 5, 2021

Thanks for this @jogold - I'm not sure that the CF team realises this difference in behaviour. Seems very odd!

john-tipper pushed a commit to john-tipper/aws-cdk that referenced this pull request May 10, 2021
CloudFormation now allows referencing the latest Systems Manager parameter
values in templates without specifying parameter versions using dynamic
references.

Remove the "trick" with the `Parameter` using a default value.

See https://aws.amazon.com/about-aws/whats-new/2021/04/now-reference-latest-aws-systems-manager-parameter-values-in-aws-cloudformation-templates-without-specifying-parameter-versions/

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
john-tipper pushed a commit to john-tipper/aws-cdk that referenced this pull request May 10, 2021
This reverts commit 9e421e5 (aws#14205).

Closes aws#14476


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this pull request Aug 26, 2021
CloudFormation now allows referencing the latest Systems Manager parameter
values in templates without specifying parameter versions using dynamic
references.

Remove the "trick" with the `Parameter` using a default value.

See https://aws.amazon.com/about-aws/whats-new/2021/04/now-reference-latest-aws-systems-manager-parameter-values-in-aws-cloudformation-templates-without-specifying-parameter-versions/

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this pull request Aug 26, 2021
This reverts commit 9e421e5 (aws#14205).

Closes aws#14476


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ssm Related to AWS Systems Manager
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants