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

Getting latest version of the SSM parameter #1587

Closed
farminf opened this issue Jan 21, 2019 · 4 comments · Fixed by #1768
Closed

Getting latest version of the SSM parameter #1587

farminf opened this issue Jan 21, 2019 · 4 comments · Fixed by #1768
Labels
feature-request A feature should be added or improved.

Comments

@farminf
Copy link

farminf commented Jan 21, 2019

Version for ParameterStoreStringProps is mandatory and number.
https://awslabs.github.io/aws-cdk/refs/_aws-cdk_aws-ssm.html#parameterstorestringprops-interface
I want to get the latest version of the parameter value.

@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 21, 2019

This is unfortunately not supported by CloudFormation using that construct for it. If you use a Secrets Manager value, you can retrieve the latest version.

However, you may be able to use a Parameter configured for reading values from SSMPS.

@rix0rrr rix0rrr added the feature-request A feature should be added or improved. label Jan 21, 2019
@farminf
Copy link
Author

farminf commented Jan 22, 2019

Thanks,
Anyway, I got it without specifying version, like this:

const { SSMParameterProvider } = require("@aws-cdk/cdk");

    value = new SSMParameterProvider(this, {
      parameterName: "/xxx/xxx",
    }).parameterValue();

@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 22, 2019

Ah yes, forgot about that one. It does something slightly different: it caches the retrieved value in cdk.json, so be aware of that when you want to update.

@bskarda
Copy link

bskarda commented Jan 24, 2019

Here's an example of how to use a parameter to read the latest version from the SSMPS.

const amiId = new cdk.Parameter(this,
  'AmiId',
  {
    type: 'AWS::SSM::Parameter::Value<String>',
    default: '/ami/sandbox/spark-standalone'
  }).ref;

rix0rrr pushed a commit that referenced this issue Feb 14, 2019
There are many requests from people to integrate with SSM parameter
store in same way, and in particular to get the latest version of
a parameter.

The mechanisms to get a specific version or the latest version
at deployment time are very different, but both are now supported
by and hidden in the ssm.ParameterStoreString class.

Make the naming around properties that return a (potentially
Tokenized) value consistent. All properties of objects that return
a string value are `stringValue`, all properties of objects taht
return a list value are `stringListValue`.

Fixes #1587.

BREAKING CHANGE: Rename `parameter.valueAsString` =>
`parameter.stringValue`, rename `parameter.valueAsList` =>
`parameter.stringListValue`, rename `ssmParameter.parameterValue` =>
`ssmParameter.stringValue` or `ssmParameter.stringListValue` depending
on type, rename `secretString.value` => `secretString.stringValue`.
rix0rrr added a commit that referenced this issue Feb 16, 2019
There are many requests from people to integrate with SSM parameter
store in same way, and in particular to get the latest version of
a parameter.

The mechanisms to get a specific version or the latest version
at deployment time are very different, but both are now supported
by and hidden in the ssm.ParameterStoreString class.

Make the naming around properties that return a (potentially
tokenized) value consistent. All properties of objects that return
a string value are `stringValue`, all properties of objects that
return a list value are `stringListValue`.

Fixes #1587.

BREAKING CHANGE: Rename `parameter.valueAsString` =>
`parameter.stringValue`, rename `parameter.valueAsList` =>
`parameter.stringListValue`, rename `ssmParameter.parameterValue` =>
`ssmParameter.stringValue` or `ssmParameter.stringListValue` depending
on type, rename `secretString.value` => `secretString.stringValue`,
rename `secret.toSecretString()` =>`secret.secretString`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants