StringAttributeProps Struct
Props for constructing a StringAttr.
| Source | aws-cognito/lib/user-pool-attr.ts |
|---|
Example
ts
new cognito.UserPool(this, 'myuserpool', {
// ...
standardAttributes: {
fullname: {
required: true,
mutable: false,
},
address: {
required: false,
mutable: true,
},
},
customAttributes: {
'myappid': new cognito.StringAttribute({ minLen: 5, maxLen: 15, mutable: false }),
'callingcode': new cognito.NumberAttribute({ min: 1, max: 3, mutable: true }),
'isEmployee': new cognito.BooleanAttribute({ mutable: true }),
'joinedOn': new cognito.DateTimeAttribute(),
},
});
python
cognito.UserPool(self, "myuserpool",
# ...
standard_attributes=cognito.StandardAttributes(
fullname=cognito.StandardAttribute(
required=True,
mutable=False
),
address=cognito.StandardAttribute(
required=False,
mutable=True
)
),
custom_attributes={
"myappid": cognito.StringAttribute(min_len=5, max_len=15, mutable=False),
"callingcode": cognito.NumberAttribute(min=1, max=3, mutable=True),
"isEmployee": cognito.BooleanAttribute(mutable=True),
"joinedOn": cognito.DateTimeAttribute()
}
)
java
UserPool.Builder.create(this, "myuserpool")
// ...
.standardAttributes(StandardAttributes.builder()
.fullname(StandardAttribute.builder()
.required(true)
.mutable(false)
.build())
.address(StandardAttribute.builder()
.required(false)
.mutable(true)
.build())
.build())
.customAttributes(Map.of(
"myappid", StringAttribute.Builder.create().minLen(5).maxLen(15).mutable(false).build(),
"callingcode", NumberAttribute.Builder.create().min(1).max(3).mutable(true).build(),
"isEmployee", BooleanAttribute.Builder.create().mutable(true).build(),
"joinedOn", new DateTimeAttribute()))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
new UserPool(this, "myuserpool", new UserPoolProps {
// ...
StandardAttributes = new StandardAttributes {
Fullname = new StandardAttribute {
Required = true,
Mutable = false
},
Address = new StandardAttribute {
Required = false,
Mutable = true
}
},
CustomAttributes = new Dictionary<string, ICustomAttribute> {
{ "myappid", new StringAttribute(new StringAttributeProps { MinLen = 5, MaxLen = 15, Mutable = false }) },
{ "callingcode", new NumberAttribute(new NumberAttributeProps { Min = 1, Max = 3, Mutable = true }) },
{ "isEmployee", new BooleanAttribute(new CustomAttributeProps { Mutable = true }) },
{ "joinedOn", new DateTimeAttribute() }
}
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
cognito.NewUserPool(this, jsii.String("myuserpool"), &UserPoolProps{
// ...
StandardAttributes: &StandardAttributes{
Fullname: &StandardAttribute{
Required: jsii.Boolean(true),
Mutable: jsii.Boolean(false),
},
Address: &StandardAttribute{
Required: jsii.Boolean(false),
Mutable: jsii.Boolean(true),
},
},
CustomAttributes: map[string]ICustomAttribute{
"myappid": cognito.NewStringAttribute(&StringAttributeProps{
"minLen": jsii.Number(5),
"maxLen": jsii.Number(15),
"mutable": jsii.Boolean(false),
}),
"callingcode": cognito.NewNumberAttribute(&NumberAttributeProps{
"min": jsii.Number(1),
"max": jsii.Number(3),
"mutable": jsii.Boolean(true),
}),
"isEmployee": cognito.NewBooleanAttribute(&CustomAttributeProps{
"mutable": jsii.Boolean(true),
}),
"joinedOn": cognito.NewDateTimeAttribute(),
},
})
Properties
maxLenoptionalnumbermax_lenoptionalint | floatmaxLenoptionalNumberMaxLenoptionaldoubleMaxLenoptional*float64 = 2048 #Maximum length of this attribute.
minLenoptionalnumbermin_lenoptionalint | floatminLenoptionalNumberMinLenoptionaldoubleMinLenoptional*float64 = 0 #Minimum length of this attribute.
mutableoptionalbooleanmutableoptionalboolmutableoptionalBooleanMutableoptionalboolMutableoptional*bool = false #Specifies whether the value of the attribute can be changed.
notes
For any user pool attribute that's mapped to an identity provider attribute, you must set this parameter to true. Amazon Cognito updates mapped attributes when users sign in to your application through an identity provider. If an attribute is immutable, Amazon Cognito throws an error when it attempts to update the attribute.