pulumi / pulumi-terraform-bridge

A library allowing Terraform providers to be bridged into Pulumi.
Apache License 2.0
196 stars 43 forks source link

error: failed to auto-generate value for "roleName" #1039

Open schnipseljagd opened 1 year ago

schnipseljagd commented 1 year ago

What happened?

I've been trying to use CrossAccountZoneDelegationRecord and adapted the example slightly to work with the pulumi cdk.

pulumi up

created the following error:

error: failed to auto-generate value for "roleName". Prefix: "CustomCrossAccountZoneDelegationCustomResourceProviderRoleED64687B-" is too large to fix max length constraint of 64. Please provide a value for "roleName"

roleName is always autogenerated by the cdk lib here so I can't provide it myself.

Expected Behavior

Probably Pulumi should truncate the name and make sure it's still unique.

Steps to reproduce

use this snippet and maybe replace my-domain.de and account: '999999999' with real values:

export class DnsStack extends pulumicdk.Stack {
  hostedZoneName: pulumi.Output<string>;

  constructor(id: string, options?: pulumicdk.StackOptions) {
    super(id, { ...options });

    const subZone = new route53.PublicHostedZone(this, 'SubZone', {
      zoneName: 'dns-test.my-domain.de',
    })

    // import the delegation role by constructing the roleArn
    const delegationRoleArn = Stack.of(this).formatArn({
      region: '', // IAM is global in each partition
      service: 'iam',
      account: '999999999',
      resource: 'role',
      resourceName: 'MyDelegationRole',
    })
    const delegationRole = iam.Role.fromRoleArn(
      this,
      'DelegationRole',
      delegationRoleArn,
    )

    // create the record
    new route53.CrossAccountZoneDelegationRecord(this, 'DelegateToParent', {
      delegatedZone: subZone,
      parentHostedZoneName: 'my-domain.de', // or you can use parentHostedZoneId
      delegationRole,
    })

    this.hostedZoneName = this.asOutput(subZone.zoneName);

    this.synth();
  }
}

Output of pulumi about

pulumi about
CLI          
Version      3.64.0
Go Version   go1.20.3
Go Compiler  gc

Plugins
NAME    VERSION
nodejs  unknown

Host     
OS       ubuntu
Version  22.04
Arch     x86_64

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

iwahbe commented 1 year ago

Hey @schnipseljagd. Thanks for bringing up this issue! I agree that we should truncate.

lukehoban commented 1 year ago

This is similar to https://github.com/pulumi/pulumi-cdk/issues/62. This issue hits the error in AWS Native, the other hits it in AWS Classic. I think in both cases, we might actually want to change the behaviour of autonaming in those providers (and all providers) to not hard fail here.

iwahbe commented 1 year ago

Good catch that the underlying problem is from AWS native! I'll move this over to the bridge. We can set up some logic to truncate over-long autonames.