Skip to content

feat(runners): reference launch template $Latest version in ASG - #1118

Merged
coderbirju merged 1 commit into
mainfrom
asg-launch-template-latest
Sep 9, 2026
Merged

coderbirju merged 1 commit into
mainfrom
asg-launch-template-latest

Conversation

@coderbirju

Copy link
Copy Markdown
Contributor

What

Add a CFN escape hatch in lib/asg-runner-stack.ts so each runner ASG references its launch template by id at the $Latest version, instead of the version number pinned at synth time.

const cfnAsg = asg.node.defaultChild as autoscaling.CfnAutoScalingGroup;
cfnAsg.addPropertyOverride('LaunchTemplate.LaunchTemplateId', lt.launchTemplateId);
cfnAsg.addPropertyOverride('LaunchTemplate.Version', '$Latest');
cfnAsg.addPropertyDeletionOverride('LaunchTemplate.LaunchTemplateName');

Why

The L2 AutoScalingGroup pins Version to LatestVersionNumber captured at deploy time. By overriding to the literal $Latest, new instance launches, scale-outs, and instance refreshes always pick up the newest launch template version whenever a change is deployed (or a new LT version is created out-of-band), rather than a synth-time-pinned number. Applies to all runner ASGs (mac/windows/linux).

Tradeoff

$Latest affects new instance launches. Existing instances are replaced by the rolling UpdatePolicy on deploy. A deploy that changes only the launch template may not by itself force a rolling replacement (the ASG's Version string stays "$Latest", so CloudFormation sees no ASG diff) — those instances pick up the latest version when they next cycle/refresh.

Testing

  • npm run build (tsc) passes.
  • npm test (jest): 12 suites / 18 tests pass.
  • Added a focused unit assertion in test/asg-runner-stack.test.ts verifying the ASG's LaunchTemplate has Version: '$Latest', a LaunchTemplateId, and no LaunchTemplateName. No existing assertions were weakened (the prior suite did not assert an ASG LaunchTemplate version).
  • npx cdk synth of a linux ASG stack renders LaunchTemplate: { LaunchTemplateId: { Ref: ... }, Version: "$Latest" }.

ASG previously pinned the launch template Version at synth time; override
to $Latest so new launches / scale-outs / instance refreshes always use the
newest LT version whenever a change is deployed. Applies to all runner ASGs
(mac/windows/linux).

Note tradeoff: $Latest affects NEW instance launches; existing instances are
replaced by the rolling UpdatePolicy on deploy, and a deploy that changes ONLY
the launch template may not by itself force a rolling replacement (the ASG's
Version string stays "$Latest") -- instances pick up latest when they next
cycle/refresh.

Signed-off-by: Arjun Yogidas <arjunry@amazon.com>
@coderbirju
coderbirju requested a review from a team as a code owner September 9, 2026 20:49
@coderbirju
coderbirju merged commit c711043 into main Sep 9, 2026
6 checks passed
@coderbirju
coderbirju deleted the asg-launch-template-latest branch September 9, 2026 21:31
coderbirju added a commit that referenced this pull request Sep 9, 2026
…SG (#1118)" (#1119)

This reverts commit c711043.

#1118 set the ASG LaunchTemplate.Version to the literal "$Latest", which
CloudFormation rejects ("does not support using $Latest or $Default for
LaunchTemplate version"), failing every ASG deploy in the pipeline (Beta
stage). Revert to the CDK default (ASG references the launch template's
LatestVersionNumber, a valid deploy-time version number that still tracks
the newest version on each deploy).

Signed-off-by: Arjun Yogidas <arjunry@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants