Skip to content

feat(lambda): add PropagateTags to CapacityProvider for tag propagation#38180

Open
vicheey wants to merge 4 commits into
aws:mainfrom
vicheey:feat/capacity-provider-propagate-tags
Open

feat(lambda): add PropagateTags to CapacityProvider for tag propagation#38180
vicheey wants to merge 4 commits into
aws:mainfrom
vicheey:feat/capacity-provider-propagate-tags

Conversation

@vicheey

@vicheey vicheey commented Jun 19, 2026

Copy link
Copy Markdown

Issue # (if applicable)

Closes #38181

N/A

Reason for this change

Lambda CapacityProvider now supports PropagateTags in CloudFormation, allowing customers to propagate tags to managed EC2 instances, ENIs, and EBS volumes. This enables tag-based security policies and cost allocation on managed infrastructure. The L1 property exists but there's no L2 support yet.

Description of changes

Adds a propagateTags prop to CapacityProviderProps using the static factory class pattern (matching ScalingOptions and InstanceTypeFilter already on this construct):

new lambda.CapacityProvider(this, 'CP', {
  subnets: vpc.privateSubnets,
  securityGroups: [securityGroup],
  propagateTags: lambda.PropagateTags.explicit([
    { key: 'CostCenter', value: 'Engineering' },
  ]),
});

Available factories:

  • PropagateTags.none() — explicitly disable propagation (emits Mode: None)
  • PropagateTags.explicit(tags) — propagate specified tags (emits Mode: Explicit + ExplicitTags)

When omitted, nothing is emitted to CloudFormation (API default applies).

The PropagateTags class uses a private constructor so users cannot construct invalid configurations. The class is structurally compatible with the L1 PropagateTagsConfigProperty, enabling direct passthrough without manual object mapping.

Validation: max 40 explicit tags (enforced at synth time).

Describe any new or updated permissions being added

None.

Description of how you validated changes

  • Unit tests: 4 new test cases (explicit mode, none mode, omitted prop, max tags validation)
  • Integration test: deployed to personal account, snapshot committed
  • Build: jsii + eslint + awslint all pass
  • All 37 capacity-provider unit tests pass

Checklist


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

Add support for propagating explicit tags to managed resources (EC2 instances,
ENIs, EBS volumes) via the PropagateTags CFN property on CapacityProvider.

Uses the static factory class pattern (matching ScalingOptions and
InstanceTypeFilter on the same construct):
- PropagateTags.none() - No tag propagation (defensive default)
- PropagateTags.explicit(tags) - Propagate specified tags (max 40)

Single prop: propagateTags?: PropagateTags
Defensively emits Mode=None when not specified.
Phase 2 extension: add PropagateTags.fromCapacityProvider() static method.

Includes:
- Unit tests (4 cases)
- Integration test with deployed snapshot
- README usage example
@github-actions github-actions Bot added p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Jun 19, 2026
@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 Jun 19, 2026
Comment thread packages/aws-cdk-lib/aws-lambda/lib/capacity-provider.ts Outdated
Comment thread packages/aws-cdk-lib/aws-lambda/lib/capacity-provider.ts
Comment thread packages/aws-cdk-lib/aws-lambda/lib/capacity-provider.ts
State the actual default behavior instead of vaguely referencing
CloudFormation API default.
@vicheey vicheey force-pushed the feat/capacity-provider-propagate-tags branch from 4e2c472 to 488d9e2 Compare June 19, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(lambda): add PropagateTags support to CapacityProvider L2 construct

3 participants