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

fix(ssm): StringParameter accepts ParameterType.AWS_EC2_IMAGE_ID as type #16884

Merged
merged 8 commits into from
Oct 13, 2021
Merged

fix(ssm): StringParameter accepts ParameterType.AWS_EC2_IMAGE_ID as type #16884

merged 8 commits into from
Oct 13, 2021

Conversation

kaizencc
Copy link
Contributor

@kaizencc kaizencc commented Oct 8, 2021

Fixes #16806. Now, setting type: ssm.ParameterType.AWS_EC2_IMAGE_ID throws an error and instead, you can set dataType: 'aws:ec2:image'. Specifically, the ssm.ParameterType.AWS_EC2_IMAGE_ID value is used internally (original PR) in a few places and really shouldn't be exposed to the customer. But I'm not sure what else we can do, especially since this is a stable module.

Original code using CfnParameter:

const parameter = ssm.CfnParameter(this, "ImageBuilderAMI", {
  type: "String",
  dataType: "aws:ec2:image",
  name: "/ec2-imagebuilder/latest",
  description: "Latest AMI Image",
  value: self.node.try_get_context(env_context)["LinuxAmi"] 
});

Can now use StringParameter:

const parameter = ssm.StringParameter(this, 'ImageBuilderAMI', {
  dataType: 'aws:ec2:image',
  parameterName: '/ec2-imagebuilder/latest',
  description: "Latest AMI Image",
  stringValue: self.node.try_get_context(env_context)["LinuxAmi"]
});

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 Oct 8, 2021

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 8, 2021
@kaizencc kaizencc requested a review from njlynch October 8, 2021 21:53
@njlynch njlynch added pr/do-not-merge This PR should not be merged at this time. and removed pr/do-not-merge This PR should not be merged at this time. labels Oct 13, 2021
Copy link
Contributor

@njlynch njlynch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to argument about the enum, but I think it's the cleaner experience.

*
* @default - 'text'
*/
readonly dataType?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about creating a ParameterDataType enum for this property? Just to avoid people having to remember/hard-coded 'aws:ec2:image' in their code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum it is. My original worry was that the docs do not specify that the dataType is exactly text | aws:ec2:image. Theoretically it could accept other data types as well...

But my thoughts are that we are likely covering 99.9% of the use case for dataType with this enum, so I think it is fine.

packages/@aws-cdk/aws-ssm/lib/parameter.ts Outdated Show resolved Hide resolved
@kaizencc kaizencc requested a review from njlynch October 13, 2021 13:42
@mergify
Copy link
Contributor

mergify bot commented Oct 13, 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: dc768b3
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify mergify bot merged commit 2b353be into aws:master Oct 13, 2021
@mergify
Copy link
Contributor

mergify bot commented Oct 13, 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).

@kaizencc kaizencc deleted the bug/ssm branch October 13, 2021 16:39
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
…ype (aws#16884)

Fixes aws#16806. Now, setting `type: ssm.ParameterType.AWS_EC2_IMAGE_ID` throws an error and instead, you can set `dataType: 'aws:ec2:image'`. Specifically, the `ssm.ParameterType.AWS_EC2_IMAGE_ID` value is used internally (original [PR](aws#4161)) in a few places and really shouldn't be exposed to the customer. But I'm not sure what else we can do, especially since this is a stable module.

Original code using `CfnParameter`: 
```ts
const parameter = ssm.CfnParameter(this, "ImageBuilderAMI", {
  type: "String",
  dataType: "aws:ec2:image",
  name: "/ec2-imagebuilder/latest",
  description: "Latest AMI Image",
  value: self.node.try_get_context(env_context)["LinuxAmi"] 
});
```

Can now use `StringParameter`: 
```ts
const parameter = ssm.StringParameter(this, 'ImageBuilderAMI', {
  dataType: 'aws:ec2:image',
  parameterName: '/ec2-imagebuilder/latest',
  description: "Latest AMI Image",
  stringValue: self.node.try_get_context(env_context)["LinuxAmi"]
});
```

----

*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
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-ssm: StringParameter Doesn't support data_type=ssm.ParameterType.AWS_EC2_IMAGE_ID
3 participants