CDK construct level1 Vs level2

0

Hi team,

I want to automate the creation of our Cognito user pool with CDK,

I would like to know what is the recommended CDK level to use for codifying: CDK level1 using cfnxxx or CDK level2?

Since I read it's better to avoid using level1 (cfnResources) whenever possible.

It's easier for me to use CDK level 1 (low level of abstraction)

Since I use AWS CLI to get the JSON spec of my resource (via AWS CLI get/describe command),

aws cognito-idp describe-user-pool --user-pool-id cognito_id > myUserPoolSpec.json --profile test

I can then do 1x1 property mappings from the generated JSON to the cfnResource construct.

(since I have everything I need in the generated JSON via AWS CLI.)

If level 2 CDK is recommended instead of level 1, is there a way/tool that can help me find the equivalent of attributes from cfnResource/my JSON file with CDK level 2 construct props?

2개 답변
0

You can use L1 constructs instead of L2 and sometimes it is an easier approach. There are resources that don't have a corresponding L2 construct and in such cases, it is easier to use L1 constructs. Reviewing the construct best practices, there is nothing specifically for L1 vs. L2. Often, L2 constructs make it easier to deploy multiple resources within a single construct.

Speaking of getting attributes, you can take a look at the package source code or run cdk synth to generate a CloudFormation template to identify resources/parameters.

AWS
Taka_M
답변함 2년 전
0

The higher Construct level you go, the more abstraction you will see ie. more parameters are pre-defined in the underlying Construct Resources so it is easier for you to create a resource.

No particular best practice that I know of, but you can see more L1 Construct options rather than L2.

Here you go for reference: https://docs.aws.amazon.com/cdk/v2/guide/cfn_layer.html

profile pictureAWS
답변함 2년 전

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

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

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

관련 콘텐츠