Skip to content
v2.273.0

NumberAttribute Class ​

The Number custom attribute type.

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(),
	},
})

Initializer ​

ts
new NumberAttribute(props?: NumberAttributeProps)
python
NumberAttribute(props: typing.Optional[NumberAttributeProps] = None)
java
new NumberAttribute(NumberAttributeProps props)
csharp
new NumberAttribute(NumberAttributeProps? props = null)
go
NewNumberAttribute(Props NumberAttributeProps)

Methods ​

bind(): CustomAttributeConfigdef bind(self, ) -> CustomAttributeConfigpublic CustomAttributeConfig bind()public CustomAttributeConfig Bind()func Bind() CustomAttributeConfig#
Bind this custom attribute type to the values as expected by CloudFormation.