iann0036 / hcl2cdktf

Converts HCL to Terraform CDK
MIT License
40 stars 4 forks source link

Attribute References should be Camel Cased #5

Open skorfmann opened 4 years ago

skorfmann commented 4 years ago

That's how it's generated:

  const b = new S3Bucket(this, 'b', {
    acl: "private",
    bucket: "mybucket",
    tags: {
        Name: "My bucket"
    }
});
//...
      origin: [{
          domainName: b.bucket_regional_domain_name!,
          originId: s3_origin_id!,
          s3OriginConfig: [{
              originAccessIdentity: "origin-access-identity/cloudfront/ABCDEFG1234567"
          }]
      }],

That's how it should be:

  const b = new S3Bucket(this, 'b', {
    acl: "private",
    bucket: "mybucket",
    tags: {
        Name: "My bucket"
    }
});
//...
      origin: [{
          domainName: b.bucketRegionalDomainName!,
          originId: s3_origin_id!,
          s3OriginConfig: [{
              originAccessIdentity: "origin-access-identity/cloudfront/ABCDEFG1234567"
          }]
      }],
iann0036 commented 4 years ago

Fixed in d7bb111ef796705ee5adc23b6e81cfe415159f21

skorfmann commented 4 years ago
 domainName: "${aws_s3_bucket.b.bucket_regional_domain_name}",
// ...

 const b = new S3Bucket(this, 'b', {
            acl: "private",
            bucket: "mybucket",
            tags: {
                Name: "My bucket"
            }
        });

Unfortunately, this doesn't work since the reference wont be a static b but something like stackName_b_252335.

iann0036 commented 4 years ago

Assume the above comment was more for #7. Updated logic to detect if an unseen reference is found and if so, will bump the resource to the back of a list.

Opinions?