Cloudformation + AWS Batch - stack-level tags -> EC2 tags

0

When creating an AWS Batch stack with CloudFormation, I'd like to be able to set tags to all resources, to track costs related to the stack. I noticed that it's possible to set a stack-level tag with aws cloudformation deploy ... --tags tagName=tagValue, and that the tag is added to all resources that support it. That's great, but there seems to be one crucial one missing: the EC2 tags in the ComputeEnvironment configuration. It seems to me that it's a crucial one when it comes to costs derived from the use of an AWS Batch stack.

Anyone has any idea how to do something like that, without going back to having to manually add tags within the template on all resources?

asked 2 years ago637 views
1 Answer
0

Hi, good question!

One way to do so is to use the Tags property of the AWS::Batch::ComputeEnvironment resource. Unfortunately, not all tags propogate by default at the Stack Level.

One those tags are set at the Compoute Resource, it will tag the EC2 instances: https://docs.aws.amazon.com/batch/latest/APIReference/API_ComputeResource.html#Batch-Type-ComputeResource-tags

For example, the AWS::Batch::JobDefinition resource will only propogate tags when the property, PropogateTags is set to true. Same goes for an Autoscaling group with TagProperty.

jsonc
answered 2 years ago
  • So, essentially, you are confirming that it's not possible to dynamically and meaningfully set tags on all significant resources, when deploying a Cloudformation stack. That's very sad, as it's going to make it significantly more complex to evaluate costs for my AWS Batch-based applications. If only because the tags on ComputeResource are in the format Name=Value (and not {Name=name, Value=value} as for tags on most resources), thereby not making it possible to have tag names defined via template parameters.

    AWS Batch and CFN teams, if you are reading, this is something you might want to improve on...

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions