Skip to content

EC2: Allow launch templates to use launch-time lookups of AMI functionality #24551

@JimNero009

Description

@JimNero009

Describe the feature

As discussed in the cloudformation docs on the resource, the ImageId here can be a directive to an SSM resolve statement. The effect of doing this is that the Launch Template, when used to launch new instances, looks up the AMI ID from a given SSM parameter and uses that. This avoids the need to re-deploy/renew a config every time you want to update an AMI.

Use Case

We want to script the build and deployment of an AMI without the need for a full redeploy of stacks, and this is a featured already offered by direct Cloudformation.

Note one can work around this by doing e.g.

  launch_template.node.default_child.add_override(
      "Properties.LaunchTemplateData.ImageId", f"resolve:ssm:{ami_ssm_parameter}"
  )

Proposed Solution

Not dug into the code as a whole, but the Cloudformation 'hack' is very simple, so I'd perhaps work at it from the point of view of a new parameter, exclusive with machine image, that simply updates the image id here with a resolve:ssm directive on the passed input string.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.67.0

Environment details (OS name and version, etc.)

Ubuntu Kinetic, Python 3.10.7, Node 18.14.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ec2Related to Amazon Elastic Compute Cloudeffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions