Using tags with spaces with cloudformation deploy

0

Due to an unfortunate choice of tags for billing we are stuck with trying to tag all resources with a tag with a space in it. "OTAP Environment".
From documentation:
--tags (list) A list of tags to associate with the stack that is created or updated. AWS CloudFormation also propagates these tags to resources in the stack if the resource supports it. Syntax: TagKey1=TagValue1 TagKey2=TagValue2 ...

From my development laptop (Windows) it seems to work:
sam deploy --template-file serverless-output.yml --capabilities CAPABILITY_IAM --parameter-overrides Environment=t --tags "OTAP Environment=T" --stack-name myStack
(sam deploy = aws cloudformation deploy)

However, when running this in a linux docker (Alpine) via Gitlab it does not work. Of course I tried other quotes. ' and `. With the latter I expected it to work, were it not the tags seems to disappear because of the GitLab Runner.

This may be more a gitlab issue than an AWS CLI issue, but if tagging were possible without the space seperation (in json maybe?) I could automate it.

asked 5 years ago2089 views
5 Answers
0

spaces aren't supported
This is the regex for key names:
^([\p{L}\p{Z}\p{N}_.:/=+-@]*)$]

answered 5 years ago
0

It has worked on a windows machine, with the proper quotes, hence I know it is possible via AWS CLI. Still not sure about the GitLab + AWS CLI combination.

And it is possible from the console.

I found this in documentation:
The key name of the tag. You can specify a value that is 1 to 127 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -.

answered 5 years ago
0

My bad..I was referencing the incorrect regex.

The SAM cli is just a wrapper on top of the cloudformation cli..have you tried using the cf cli directly?

e.g.
aws cloudformation deploy

https://docs.aws.amazon.com/cli/latest/reference/cloudformation/deploy/index.html

answered 5 years ago
0

Yes, I have tried that as well. From a Windows laptop it is possible with the right quotes.

--tags "OTAP Environment=T"

Would work in that case. But haven't got it to run on a Gitlab runner. But the solution is no longer needed as the required tag has changed to a tag without a space :-D

answered 5 years ago
0

Answer is no longer needed as the required tag name changed.

answered 3 years ago

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