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.

gefragt vor 5 Jahren2110 Aufrufe
5 Antworten
0

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

beantwortet vor 5 Jahren
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 -.

beantwortet vor 5 Jahren
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

beantwortet vor 5 Jahren
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

beantwortet vor 5 Jahren
0

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

beantwortet vor 3 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen