Skip to content

(aws-batch): Allow specifying ComputeResource tags in managed EC2 compute environments #36615

@tvoipio

Description

@tvoipio

Describe the feature

Managed EC compute environments allow specifying a tags attribute in ComputeResource (see https://docs.aws.amazon.com/batch/latest/APIReference/API_ComputeResource.html) to apply specific tags to EC2 instances launched by Batch/ECS. These are used e.g. for cost allocation.

The CloudFormation resource does support providing tags in ComputeResource: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-batch-computeenvironment-computeresources.html

The functionality seems to be available in aws_cdk.aws_batch.CfnComputeEnvironment via CfnComputeEnvironment.ComputeResourcesProperty's tags kwarg/property, but not exposed to the L2 construct.

I could hack my way around this using an escape hatch, but as there seems to be no reason not to expose the ComputeResource tags to the L2 construct, could this be provided directly by CDK?

Use Case

I need to use an escape hatch to provide necessary tags to managed EC2 environment compute resources in order to e.g. allocate costs correctly and get the Name tag set properly to be able to identify Batch EC2 instances in the EC2 console

Proposed Solution

Add a property/keyword argument (excuse my Python vocabulary) to the L2 construct ManagedEc2EcsComputeEnvironment. Based on my limited understanding of the construct code, in https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-batch/lib/managed-compute-environment.ts add a property computeResourceTags to ManagedEc2EcsComputeEnvironmentProps and use it instead of/in addition to this.tags.renderedTags in

(and to apply the same to EKS based environments?)

Other Information

No response

Acknowledgements

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

AWS CDK Library version (aws-cdk-lib)

2.225.0 (Python package version)

AWS CDK CLI version

2.1033.0 (build 1ec3310)

Environment details (OS name and version, etc.)

macOS Sequoia 15.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-batchRelated to AWS Batchclosing-soonThis issue will automatically close in 4 days unless further comments are made.effort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.good first issueRelated to contributions. See CONTRIBUTING.mdp2response-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 7 days.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions