aws-samples / amazon-cloudwatch-auto-alarms

Automatically create and configure Amazon CloudWatch alarms for EC2 instances, RDS, and AWS Lambda using tags for standard and custom CloudWatch Metrics.
MIT No Attribution
90 stars 84 forks source link

Allow substitution of unsupported characters in tags with alternative character. #44

Open skrausedxccom opened 1 year ago

skrausedxccom commented 1 year ago

according the documentation, Forward-Slash can be used for AWS/EC2 metrics. But AWS EC2 tagging does not allow foward slash.

knizami commented 1 year ago

Hello, thanks for creating this issue. I believe forward slashes are allowed unless tag retrieval via instance metadata is being used: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#work-with-tags-in-IMDS

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-restrictions

I have updated the issue so that the solution will allow you to provide a dictionary for character substitutions. For example, provided a dictionary:

substitution_map = { '@': '\' }

The solution will create the alarm substituting the '@' sign found in the tag with a '\' before processing the tag: