Loving the Cognito support that is coming day by day. Most of it is working well, however the custom attributes currently only allow you to create immutable custom attributes. I would like mine to be mutable but there appears to be no way to do this.
const userPool = new cognito.UserPool(this, userPoolName, {
signInAliases: { email: true },
autoVerify: { email: true, phone: true },
userPoolName,
passwordPolicy: {
minLength: 8,
requireDigits: true,
requireLowercase: true,
requireSymbols: false,
requireUppercase: true,
tempPasswordValidity: cdk.Duration.days(30),
},
emailSettings: {
from: "<email>",
replyTo: "<email>",
},
userVerification: {
emailStyle: VerificationEmailStyle.CODE,
emailBody: "Your verification code is {####}",
emailSubject: "Your verification code",
},
userInvitation: {
emailBody: "An account has been created for you. Your username is {username} and temporary password is {####}.",
emailSubject: "Account Created",
},
lambdaTriggers: {
userMigration: migrateUser,
},
requiredAttributes: {
email: true,
fullname: true,
},
customAttributes: {
company: new StringAttribute({ minLen: 1, maxLen: 255 }),
type: new StringAttribute({ maxLen: 2048 }),
custom1: new StringAttribute({ maxLen: 2048 }),
custom2: new StringAttribute({ maxLen: 2048 }),
},
selfSignUpEnabled: true,
mfa: Mfa.OPTIONAL,
mfaSecondFactor: {
sms: true,
otp: true,
},
});
Custom attributes are immutable

Can we get a mutable flag added back as per the old:
cfnUserPool.schema = [
{
name: "company",
attributeDataType: "String",
required: true,
mutable: false,
stringAttributeConstraints: { minLength: "1", maxLength: "1024" },
},
{
name: "type",
attributeDataType: "String",
required: false,
mutable: true,
stringAttributeConstraints: { maxLength: "2048" },
},
{
name: "custom1",
attributeDataType: "String",
required: false,
mutable: true,
stringAttributeConstraints: { maxLength: "2048" },
},
{
name: "custom2",
attributeDataType: "String",
required: false,
mutable: true,
stringAttributeConstraints: { maxLength: "2048" },
},
];
This is :bug: Bug Report
Thanks for filing this issue. I have re-classified this as a feature request.
The support for the Mutable property needs to be implemented.
You can work around this using property overrides via our escape hatches - https://docs.aws.amazon.com/cdk/latest/guide/cfn_layer.html#cfn_layer_raw - to directly inject this property into the CloudFormation template.
Hi, I think the solution might be to update the ICustomAttribute interface, by adding the mutable, required and developerOnly properties, matching the ones in the AWS::Cognito::UserPool::SchemaAttribute.
I will start working tomorrow on a proposed solution.
Most helpful comment
Thanks for filing this issue. I have re-classified this as a feature request.
The support for the
Mutableproperty needs to be implemented.You can work around this using property overrides via our escape hatches - https://docs.aws.amazon.com/cdk/latest/guide/cfn_layer.html#cfn_layer_raw - to directly inject this property into the CloudFormation template.