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?

preguntada hace 2 años602 visualizaciones
1 Respuesta
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
respondido hace 2 años
  • 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...

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas