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

feat(ec2): support using ssm parameter to resolve AMI ID at instance launch time #26273

Merged
merged 8 commits into from
Jul 10, 2023

Conversation

pahud
Copy link
Contributor

@pahud pahud commented Jul 7, 2023

Launch Template and EC2 instance support using SSM parameter to resolve the AMI ID at instance launch time(resolve:ssm:parameter) rather than the CFN deploy time(CfnDynamicReference). This PR introduces a new support for that.

Remove latestAmazonLinux2022() from the integ test as it does not return any valid al2022 images anymore as described in #26274

Closes #24551


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 Jul 7, 2023

@aws-cdk-automation aws-cdk-automation requested a review from a team July 7, 2023 04:20
@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1 labels Jul 7, 2023
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jul 7, 2023
@pahud pahud marked this pull request as draft July 7, 2023 05:09
@pahud pahud marked this pull request as ready for review July 7, 2023 12:49
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jul 7, 2023
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jul 7, 2023
@pahud pahud requested a review from mrgrain July 7, 2023 20:27
@mergify
Copy link
Contributor

mergify bot commented Jul 10, 2023

Thank you for contributing! Your pull request will be updated from main 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: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: b5e9f59
  • 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 2462b0b into aws:main Jul 10, 2023
@mergify
Copy link
Contributor

mergify bot commented Jul 10, 2023

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

bmoffatt pushed a commit to bmoffatt/aws-cdk that referenced this pull request Jul 29, 2023
…launch time (aws#26273)

Launch Template and EC2 instance support using SSM parameter to resolve the AMI ID at instance launch time(`resolve:ssm:parameter`) rather than the CFN deploy time(`CfnDynamicReference`). This PR introduces a new support for that.

- [Using SSM Parameter with Autoscaling and Launch Template](https://docs.aws.amazon.com/autoscaling/ec2/userguide/using-systems-manager-parameters.html)
- [Launch an instance using a Systems Manager parameter](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html#using-systems-manager-parameter-to-find-AMI)

Remove `latestAmazonLinux2022()` from the integ test as it does not return any valid al2022 images anymore as described in aws#26274

Closes aws#24551

----

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

Any code examples to use this feature? Thanks

@robertd
Copy link
Contributor

robertd commented Jan 24, 2024

@racheliurui

const launchTemplate = new ec2.LaunchTemplate(stack, 'LaunchTemplate', {
  machineImage: ec2.MachineImage.resolveSsmParameterAtLaunch('parameterName');
});

@robertd
Copy link
Contributor

robertd commented Jan 24, 2024

@racheliurui

Make sure your SSM Param is of aws:ec2:image DataType (see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ssm-parameter.html) and not of text.

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. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EC2: Allow launch templates to use launch-time lookups of AMI functionality
5 participants