Skip to content

Commit 0978549

Browse files
ykethanjosefaidt
andauthored
update custom attribute and password policy example (#7635)
* update custom attribute example * update password policy example * Update src/pages/[platform]/build-a-backend/auth/modify-resources-with-cdk/index.mdx --------- Co-authored-by: josef <[email protected]>
1 parent 51ed316 commit 0978549

File tree

1 file changed

+19
-22
lines changed
  • src/pages/[platform]/build-a-backend/auth/modify-resources-with-cdk

1 file changed

+19
-22
lines changed

src/pages/[platform]/build-a-backend/auth/modify-resources-with-cdk/index.mdx

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,17 @@ const backend = defineBackend({
4444
});
4545
// extract L1 CfnUserPool resources
4646
const { cfnUserPool } = backend.auth.resources.cfnResources;
47-
// use CDK's `addPropertyOverride` to modify properties directly
48-
cfnUserPool.addPropertyOverride(
49-
"Policies",
50-
{
51-
PasswordPolicy: {
52-
MinimumLength: 10,
53-
RequireLowercase: true,
54-
RequireNumbers: true,
55-
RequireSymbols: true,
56-
RequireUppercase: true,
57-
TemporaryPasswordValidityDays: 20,
58-
},
59-
}
60-
);
47+
// modify cfnUserPool policies directly
48+
cfnUserPool.policies = {
49+
passwordPolicy: {
50+
minimumLength: 10,
51+
requireLowercase: true,
52+
requireNumbers: true,
53+
requireSymbols: true,
54+
requireUppercase: true,
55+
temporaryPasswordValidityDays: 20,
56+
},
57+
};
6158
```
6259

6360
## Custom Attributes
@@ -76,14 +73,14 @@ const backend = defineBackend({
7673

7774
// extract L1 CfnUserPool resources
7875
const { cfnUserPool } = backend.auth.resources.cfnResources;
79-
// use CDK's `addPropertyOverride` to modify properties directly
80-
cfnUserPool.addPropertyOverride("Schema", [
81-
{
82-
Name: "publicName",
83-
AttributeDataType: "String",
84-
Mutable: true,
85-
},
86-
]);
76+
// update the schema property to add custom attributes
77+
if (Array.isArray(cfnUserPool.schema)) {
78+
cfnUserPool.schema.push({
79+
name: 'policyName',
80+
attributeDataType: 'Boolean',
81+
developerOnlyAttribute: true,
82+
});
83+
}
8784
```
8885

8986
{/* token validity */}

0 commit comments

Comments
 (0)