Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow colons in tag names #1753

Open
nitrocode opened this issue Sep 28, 2023 · 0 comments · May be fixed by #1759
Open

Allow colons in tag names #1753

nitrocode opened this issue Sep 28, 2023 · 0 comments · May be fixed by #1759

Comments

@nitrocode
Copy link
Contributor

nitrocode commented Sep 28, 2023

I work with a client that uses colons in tag names as part of aws best tagging practices.

I tried to do this and I could not get it to work with tag corp:env and value prod

aws-gate session corp:env:prod
aws-gate session corp\:env:prod
aws-gate session "corp:env":prod
aws-gate session "corp\:env":prod

Seems like colons in tag names aren't supported by aws-gate yet. However, they are supported by aws.

Thank you for considering this

def getinstanceidbytag(name, ec2=None):
# One of the allowed characters in tags is ":", which might break tag
# parsing. For this reason,we have to differentiate 2 cases for
# provided name:
# - aws: special prefixed tags in the form of aws:<service>:<tag_name>:<tag_value>
# - regular cases in the form <tag_name>:<tag_value>
if name.startswith("aws:"):
key, value = ":".join(name.split(":", 3)[:3]), name.split(":", 3)[-1]
else:
key, value = name.split(":", 1)
filters = [{"Name": f"tag:{key}", "Values": [value]}]
return _query_aws_api(filters=filters, ec2=ec2)

@nitrocode nitrocode linked a pull request Oct 6, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant