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

gefragt vor 2 Jahren1269 Aufrufe
1 Antwort
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
EXPERTE
James_S
beantwortet vor 2 Jahren
  • can a DeletionPolicy: Retain and solve this problem in regards of resource replacement?

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen