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

pulumi convert --from terraform does not preserve casing for keys in HCL maps (like tags) #100

Closed
jkodroff opened this issue Jan 29, 2024 · 2 comments · Fixed by #101
Closed
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@jkodroff
Copy link
Member

jkodroff commented Jan 29, 2024

What happened?

When converting TF to TS (at least - haven't checked in other languages), casing is not preserved on maps (like tags). This diff is a problem because the Name tag (case-sensitive) controls how many resources display in the AWS console:

image

Example

resource "aws_subnet" "private" {
  count             = length(local.private_subnet_cidrs)
  vpc_id            = aws_vpc.main.id
  availability_zone = element(local.azs, count.index)
  cidr_block        = element(local.private_subnet_cidrs, count.index)
  tags = {
    Name = "convert-tf-private-${count.index + 1}"
  }
}

Converts to:

const _private: aws.ec2.Subnet[] = [];
for (const range = {value: 0}; range.value < privateSubnetCidrs.length; range.value++) {
    _private.push(new aws.ec2.Subnet(`private-${range.value}`, {
        vpcId: main.id,
        availabilityZone: azs[range.value],
        cidrBlock: privateSubnetCidrs[range.value],
        tags: {
            name: `convert-tf-private-${range.value + 1}`, // <-- This should be `Name`, not `name`.
        },
    }));
}

Output of pulumi about

CLI          
Version      3.103.1
Go Version   go1.21.6
Go Compiler  gc

Plugins
NAME    VERSION
aws     6.18.1
nodejs  unknown

Host     
OS       darwin
Version  14.2.1
Arch     arm64

This project is written in nodejs: executable='/opt/homebrew/bin/node' version='v21.2.0'

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/josh-pulumi-corp
User           josh-pulumi-corp
Organizations  josh-pulumi-corp, pulumi-gitlab-demo2, jkodrofftest, zephyr, pulumi
Token type     personal

Dependencies:
NAME            VERSION
@types/node     14.18.63
typescript      4.9.5
@pulumi/aws     6.18.1
@pulumi/pulumi  3.103.1

Pulumi locates its logs in /var/folders/5m/4n1x3f8151s35wc80w06z5k80000gn/T/ by default

Also probably helpful:

$ pulumi plugin ls | grep terraform
terraform          converter  1.0.11                            44 MB   6 days ago     6 days ago
terraform          converter  1.0.4                             58 MB   5 months ago   5 months ago

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@jkodroff jkodroff added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jan 29, 2024
@Frassle Frassle transferred this issue from pulumi/pulumi Jan 29, 2024
@Frassle
Copy link
Member

Frassle commented Jan 29, 2024

Similar to #53. I think the converters losing track of maps vs objects, TF doesn't always make that easy to determine.

@jkodroff
Copy link
Member Author

@Frassle If you specifically look for the "tags" key, and assume that's always a map, I believe that would handle the issue from a practical perspective. It's not scaleable, and it's not addressing the root cause, but off the top of my head I can't think of any scenarios where this solution would make the output worse.

@justinvp justinvp removed the needs-triage Needs attention from the triage team label Jan 30, 2024
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants