cf2tf icon indicating copy to clipboard operation
cf2tf copied to clipboard

Tag conversion issue

Open robomnis opened this issue 2 years ago • 1 comments

Super minor, but for resource tags need some slight tweak to make them generate in the right format.

Input (CloudFormation):

      Tags:
        - Key: Network
          Value: Public
        - Key: Name
          Value: Production VPC

Output:

  tags = [{'Key': '"Network"', 'Value': '"Public"'}, {'Key': '"Name"', 'Value': '"Production VPC"'}]

Should be:

tags = {
    Network = "Public"
    Name = "Production VPC"
    }

Current output errors for tags on terraform plan:

╷
│ Error: Invalid character
│ 
│   on vpc.tf line 104, in resource "aws_vpc" "vpc":
│  104:   tags = [{'Key': '"Network"', 'Value': '"Public"'}, {'Key': '"Name"', 'Value': '"Production VPC"'}]
│ 
│ Single quotes are not valid. Use double quotes (") to enclose strings.
╵

robomnis avatar Aug 28 '22 15:08 robomnis

Duplicate of #23 but I will keep this open because this will likely require a different solution.

shadycuz avatar Sep 06 '22 03:09 shadycuz

In version 0.4 we released an override feature https://github.com/DontShaveTheYak/cf2tf/pull/86. This feature is meant to add override behavior for specific resources but I think could be easily adapted to add an override behavior for every resource. That means it should now be pretty simple to reformat the tags property in a way that is compatible with Terraform.

shadycuz avatar Apr 14 '23 14:04 shadycuz