jsii icon indicating copy to clipboard operation
jsii copied to clipboard

Rosetta: Incorrect transliteration for namespace/submodule usage in Go

Open jsteinich opened this issue 3 years ago • 0 comments

Describe the bug

Translating a reference to a namespaced resource results in #error# being output in the resulting Go code.

Expected Behavior

The namespace should be maintained or separate import statements should be generated.

Current Behavior

The namespace is lost and #error# is generated instead.

Reproduction Steps

import * as aws from "./.gen/providers/aws";
const awsKmsKeyExamplekms = new aws.kms.KmsKey(this, "examplekms", {
  deletionWindowInDays: 7,
  description: "KMS key 1",
});

results in

"import aws "github.com/aws-samples/dummy/genprovidersaws"
awsKmsKeyExamplekms := #error#.NewKmsKey(this, jsii.String("examplekms"), map[string]interface{}{
	"deletionWindowInDays": jsii.Number(7),
	"description": jsii.String("KMS key 1"),
})

Possible Solution

https://github.com/aws/jsii/pull/3508 tackled a similar issue, so there maybe a similar solution available; however, I haven't checked the code.

Additional Information/Context

This came up while working onhttps://github.com/hashicorp/terraform-cdk/pull/1782. There is a snapshot test that illustrates the issue.

SDK version used

1.55.1, also observed in 1.58.0

Environment details (OS name and version, etc.)

docker.mirror.hashicorp.services/hashicorp/jsii-terraform (based on jsii/superchain)

jsteinich avatar May 19 '22 03:05 jsteinich