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年前1270ビュー
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?

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ