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?

質問済み 2年前602ビュー
1回答
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
回答済み 2年前
  • 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...

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ