aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Bug: Converts stack tag name spaces to underscores

Open dacgray opened this issue 1 year ago • 6 comments

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 avatar Jan 30 '25 06:01 dacgray

After more experimenting, this pattern seems to work:

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

dacgray avatar Jan 30 '25 07:01 dacgray

⚠️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.

github-actions[bot] avatar Jan 30 '25 07:01 github-actions[bot]

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

dacgray avatar Jan 31 '25 03:01 dacgray

I assume the last working version for your was 1.131.0 Is that correct?

vicheey avatar Feb 15 '25 00:02 vicheey

That sounds about right.

dacgray avatar Feb 15 '25 03:02 dacgray

I mark this issue as stage/needs-feedback to collect more reaction from community.

vicheey avatar Mar 28 '25 23:03 vicheey