How to prevent AWS Cognito App Client recreation when using Cloudformation?

Viewed 16

We are maintaining Cognito App clients via cdk. When altering App client attributes we have noticed that sometimes CloudFormation recreates App Clients and sometimes just modifies existing app client without recreating new one.

Recreating app clients is a problem in our case since there are external applications that use authentication and a changed App client id breaks authentication.

For example when adding new optional attribute generateSecret with value generateSecret:false (default value) CF decided to re-create App client. When changing i.e token expiration values re-creation is not going to happen.

How to prevent re-creation OR how to identify cases when re-creation is going to happen beforehand?

1 Answers

This information is available in the CloudFormation documentation for the relevant resource. In the Attributes section, each attribute has an Update requires: field that describes what happens when that particular attribute is updated.

From the docs for AWS::Cognito::UserPoolClient's GenerateSecret attribute:

Update requires: Replacement

So this is a limitation of CloudFormation - you cannot avoid resource replacement when updating an attribute that requires replacement.

Related