Skip to content

Commit

Permalink
add context around L1 and L2 constructs
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardfoyle committed Dec 7, 2023
1 parent ce44fe2 commit 530da92
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ lambdaFunction.addEnvironment('USER_POOL_ID', userPool.userPoolId);

## Example - Mutate synthesized CloudFormation

It's possible to reach all the way down to the raw CloudFormation to mutate properties using `addPropertyOverride` on a CDK Construct. To edit the password policies of the UserPool in `defineAuth`, you can use the following code.
It's possible to reach all the way down to the raw CloudFormation to mutate properties using `addPropertyOverride` on a CDK Construct. To edit the password policies of the Cognito UserPool in `defineAuth`, you can use the following code.

```ts
// amplify/backend.ts
Expand All @@ -122,6 +122,12 @@ backend.resources.auth.resources.cfnResources.cfnUserPool.addPropertyOverride(
);
```

Note the usage of `auth.resources.cfnResources`. This property exposes [L1 CDK Constructs](https://docs.aws.amazon.com/cdk/v2/guide/constructs.html#constructs_l1_using). These are constructs that map 1:1 with the underlying CloudFormation properties.

The `auth.resources.cfnResources.cfnUserPool` property in the above example directly maps to the [AWS::Cognito::UserPool CloudFormation resource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpool.html).

This is different than `auth.resources.userPool` in the first example which is an [L2 CDK Construct](https://docs.aws.amazon.com/cdk/v2/guide/constructs.html#constructs_using). These are constructs that provide a convenient interface around several related L1 constructs.

## Example - Add tags to resources

```ts title="amplify/backend.ts"
Expand Down

0 comments on commit 530da92

Please sign in to comment.