terraform-cdk icon indicating copy to clipboard operation
terraform-cdk copied to clipboard

Convert: Nested named structs are not properly addressed (JSII upstream issue)

Open ansgarm opened this issue 1 year ago • 2 comments

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

Expected Behavior

convert should return:

aws.s3_bucket.S3Bucket(self, "bucket",
    logging=aws.s3_bucket.S3BucketLogging(
        target_bucket="target"
    )
)

Actual Behavior

convert returns no proper access for S3BucketLogging

aws.s3_bucket.S3Bucket(self, "bucket",
    logging=S3BucketLogging(
        target_bucket="target"
    )
)

Steps to Reproduce

Convert the following snippet to e.g. Python

resource "aws_s3_bucket" "bucket" {
  logging {
    target_bucket = "target"
  }
}

Important Factoids

More details (e.g. for other languages) can be found in the upstream issue linked below

References

  • https://github.com/aws/jsii/pull/4056
  • #0000

ansgarm avatar Apr 13 '23 12:04 ansgarm

This might also be fixable by doing granular imports rather than star imports

mutahhir avatar Jun 13 '23 12:06 mutahhir

Granular imports were implemented, but they don't help in this specific case.

When we generate TypeScript, we don't import types as they're implicitly handled. When JSII/Rosetta converts the code to the destination language, it doesn't add import statements to the newly added types.

There are two ways of doing this. One is to fix this on the JSII side (recommended), and the other is to make the convert code know about this issue and have it add type imports (possibly faster to implement / easier).

mutahhir avatar Aug 10 '23 08:08 mutahhir