Control CDK generic names generation

0

Currently working with CDK v1 python

When creating any of the resources and passing the resource id name I am controlled and reflected. However when creating the AWS:IAM:Policy the policy name it self looses all underscore/dashes and any capitalization is lost. (also the tool appends a hash)

Within Severless, the name of the policy desired will be 100% mapped.

Is there in CDK a field that will respect the Physical ID assigned for any of the given resources?

The following list of resources were tested:

  • IAM:Policy
  • Lambda::EventSourcingMapping
  • Lambda::Permission
  • ApiGateway::Restpi (and Deployment)
  • IAM::Role and more.

Example:

[+] AWS::ApiGateway::RestApi legacy-api/api-legacy-api 
legacyapiapilegacyapi4645BE99

this is the resource_id and physical id that CDK resolve to (when performing cdk diff) : legacy-api/api-legacy-api however in the cdk.out and print out I get legacyapiapilegacyapi4645BE99. Severless framework does not do this

질문됨 2년 전1269회 조회
1개 답변
1

Per the CDK docs at https://docs.aws.amazon.com/cdk/v2/guide/resources.html#resources_physical_names, you can set the physical name for some resources using the *_name property. The list of resources which support this is in the CloudFormation docs (since CDK is beholden to CFN's resource model, so you can't just do this on any resource).

It would be worth bearing in mind the warnings in both those pieces of documentation around the impact of fixing a resource's physical name: if you later need to perform an update which requires replacement of the resource, you won't be able to. (This is because CFN creates a new resource, then deletes the old one, and you can't have two resources with the same physical id.)

profile pictureAWS
전문가
James_S
답변함 2년 전
  • can a DeletionPolicy: Retain and solve this problem in regards of resource replacement?

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

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

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

관련 콘텐츠