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

Bug: Converts stack tag name spaces to underscores #7856

Open
dacgray opened this issue Jan 30, 2025 · 3 comments
Open

Bug: Converts stack tag name spaces to underscores #7856

dacgray opened this issue Jan 30, 2025 · 3 comments
Labels
stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Comments

@dacgray
Copy link

dacgray commented Jan 30, 2025

Description:

In a recent version we were able to add tags in the toml file with spaces in the names -> these tags were added with no modification to resources.

In the current version it replaces spaces with an underscore:

Image

samconfig.toml

[staging]
[staging.deploy]
[staging.deploy.parameters]
stack_name = "shop-restack-ecs-stack"
region = "eu-central-1"
confirm_changeset = true
capabilities = "CAPABILITY_NAMED_IAM"
tags = 'Env=staging Repo=shop-restack Stack=shop-restack-ecs-stack "Cost Group"=Restack'

I have tried with various formats of the tags arg with the same or worse results.

eg:

tags = "Env=staging Repo=shop-restack Stack=shop-restack-ecs-stack \"Cost Group\"=Restack"
tags = "Env=staging Repo=shop-restack Stack=shop-restack-ecs-stack 'Cost Group'=Restack"
tags = "Env=staging Repo=shop-restack Stack=shop-restack-ecs-stack Cost Group=Restack"

Note: spaces are explicitly allowed: https://docs.aws.amazon.com/tag-editor/latest/userguide/best-practices-and-strats.html#:~:text=For%20information%20about%20what%20characters,and%20values%20are%20case%20sensitive.

This change is breaking out cost allocation tags, and breaking our CI scripts.

Steps to reproduce:

Using 1.132.0 Windows.

  1. Add tags to the toml file with a space in a tag name.
  2. Deploy with sam deploy

Observed result:

Replaces the tag with an underscore.

Cost Group -> Cost_Group

Expected result:

Creates the tag with the same name set in the samconfig.toml file.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Windows
  2. sam --version: 1.132.0
  3. AWS region: eu-central-1
{
  "version": "1.132.0",
  "system": {
    "python": "3.12.6",
    "os": "Windows-10-10.0.19045-SP0"
  },
  "additional_dependencies": {
    "docker_engine": "24.0.7",
    "aws_cdk": "Not available",
    "terraform": "1.3.5"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}
@dacgray dacgray added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Jan 30, 2025
@dacgray dacgray changed the title Bug: tags names with spaces converted to underscore Bug: Converts stack tag name spaces to underscores Jan 30, 2025
@dacgray
Copy link
Author

dacgray commented Jan 30, 2025

After more experimenting, this pattern seems to work:

tags = [
    "Env=prod",
    "Repo=shop-restack",
    "Stack=shop-restack-ecs-stack",
    "Cost Group=Restack"
]

@dacgray dacgray closed this as completed Jan 30, 2025
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dacgray
Copy link
Author

dacgray commented Jan 31, 2025

On second thought, best to keep this open since behaviour is not as expected.

@dacgray dacgray reopened this Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.
Projects
None yet
Development

No branches or pull requests

1 participant