Is it possible to customise the name of s3 auto delete custom resource currently I find the below {prefix}-custom-s3-auto-delete-objects-custom-resource-provider-{suffix} generated

0

Is it possible to customise the name of s3 auto delete custom resource currently I find the below {prefix}-custom-s3-auto-delete-objects-custom-resource-provider-{suffix} generated I am having 2 stacks in the same environment and the prefix and suffix are same for both hence I am getting an error like the specific resource already exists in another stack while i deploy in cdk v2

1개 답변
0

Aravind,

Unfortunately, I have not found a straightforward way to customize the name of those types of resources. However, since the {prefix} and {suffix} you're seeing are likely derived from the logical ID of the resource in your CDK application (auto-generated hash to ensure uniqueness), you should be able to work around the issue by differentiating the resources between the two stacks by assigning different logical IDs or adding another level of nesting.

For example, you can put each of your stack instances in a different CDK Stage, or you can differentiate the resources by adding a unique identifier to the logical IDs or to the stack names.

Here is an example using stages:

class MyStage extends cdk.Stage {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StageProps) {
    super(scope, id, props);

    new MyStack(this, 'MyStack');
  }
}

const app = new cdk.App();
new MyStage(app, 'Prod', { env: { region: 'us-west-2' } });
new MyStage(app, 'Dev', { env: { region: 'us-west-2' } });

Hope that helps!

-Zac

profile picture
Zac Dan
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠