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

Case sensitive tags are incorrectly downcased #75

Closed
topfunky opened this issue May 12, 2020 · 6 comments · Fixed by #136
Closed

Case sensitive tags are incorrectly downcased #75

topfunky opened this issue May 12, 2020 · 6 comments · Fixed by #136
Assignees
Labels
bug Something isn't working

Comments

@topfunky
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

cdktf & Language Versions

Affected Resource(s)

  • AWS provider
  • Typescript example

Debug Output

Expected Behavior

I created a tag in my AWS resource. It successfully compiles and deploys, and it appears in the AWS console. However, it downcases all key names, so the AWS-specific "Name" tag deploys as "name" and doesn't display correctly in the AWS console (it should show as the "Name" of the resource in the table view of my AWS instances).

My Typescript:

import { Construct } from 'constructs';
import { App, TerraformStack } from 'cdktf';
import { Instance } from './.gen/providers/aws/instance';

class MyStack extends TerraformStack {
  constructor(scope: Construct, id: string) {
    super(scope, id);

    new Instance(this, 'Hello', {
      ami: "ami-0d6621c01e8c2de2c",
      instanceType: "t2.micro",
      tags: {
        "Name": "Geoffrey"
      }
    });
  }
}

const app = new App();
new MyStack(app, 'example');
app.synth();

Actual Behavior

The generated JSON has a "name" key, not "Name":

{
  "resource": {
    "aws_instance": {
      "exampleHello0912C9B5": {
        "ami": "ami-0d6621c01e8c2de2c",
        "instance_type": "t2.micro",
        "tags": {
          "name": "Geoffrey"
        }
      }
    }
  }
}

Steps to Reproduce

Use the Typescript as shown above, then

$ yarn compile
$ cdktf synth
$ cd dist
$ terraform apply

Important Factoids

References

  • #0000
@topfunky topfunky added the bug Something isn't working label May 12, 2020
@skorfmann
Copy link
Contributor

We could wrap tags in a similar concept as the TagManager in the aws-cdk. While we probably don't have to support various tagging formats, this would allow us to produce a resolvable value, which would be ignored when transforming the object keys during synth.

Something like this:

public get tags(): {[key: string]: any} {
  return Lazy.anyValue({ produce: () => this._tags.renderTags() })
}

@topfunky
Copy link
Contributor Author

@skorfmann Thanks for the commit and test suite!

Unfortunately, it doesn't fix the bug. If I run the code above, it retains the capitalization of the value, but not the key. So when I specify "Name: Geoffrey" it gives me "name: Geoffrey".

Should I open a new issue?

3f905ab

@skorfmann
Copy link
Contributor

Unfortunately, it doesn't fix the bug. If I run the code above, it retains the capitalization of the value, but not the key. So when I specify "Name: Geoffrey" it gives me "name: Geoffrey".

Just tried it locally and I can't reproduce it.

  "resource": {
    "aws_instance": {
      "helloterra_HelloF_F96C4813": {
        "ami": "ami-0d6621c01e8c2de2c",
        "instance_type": "t2.micro",
        "tags": {
          "Name": "Geoffrey"
        },
  • Which commit / version are you using?
  • If you're using it from the git repo, could you run yarn build in the project root folder and try again?

@skorfmann
Copy link
Contributor

skorfmann commented Jul 14, 2020

I've just realised that the fix is in cdktf@next only since there hasn't been an actual release since #136 got merged. I'm sorry for the confusion.

@anubhavmishra
Copy link
Member

We can close this as this is fixed in the next version of cdktf.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2022

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants