hcl2cdktf icon indicating copy to clipboard operation
hcl2cdktf copied to clipboard

Attribute References should be Camel Cased

Open skorfmann opened this issue 4 years ago • 3 comments

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"
          }]
      }],

skorfmann avatar Aug 08 '20 19:08 skorfmann

Fixed in d7bb111ef796705ee5adc23b6e81cfe415159f21

iann0036 avatar Aug 09 '20 01:08 iann0036

 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.

skorfmann avatar Aug 11 '20 19:08 skorfmann

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?

iann0036 avatar Aug 11 '20 23:08 iann0036