A developer is managing an application deployed via AWS CloudFormation. The application's database credentials are stored in AWS Secrets Manager and referenced in the CloudFormation template using the dynamic reference `{{resolve:secretsmanager:ProductionDBSecret:SecretString:Password}}` within the `UserData` property of an `AWS::EC2::LaunchTemplate` resource.
The database administrator rotates the database password in AWS Secrets Manager. Subsequently, the developer initiates a stack update to increase the `MaxSize` property of the `AWS::AutoScaling::AutoScalingGroup` resource that uses this launch template. The stack update completes successfully, but the newly launched EC2 instances fail to connect to the database, while existing instances continue to function until their cached credentials expire.
What is the cause of this issue, and how should the developer resolve it?
- AThe developer should store the password in Systems Manager Parameter Store as a SecureString and use the `{{resolve:ssm-secure:ParameterName:Version}}` dynamic reference instead, as Parameter Store parameters automatically trigger a stack update and resource replacement whenever the parameter value changes.
- BThe manual update of the database password created a drift condition between the stack template and the deployed resources, preventing CloudFormation from resolving the secret. The developer must run drift detection on the stack, resolve the drift, and perform a stack import.
- The Launch Template resource was not modified during the stack update, so CloudFormation did not re-resolve the dynamic reference to fetch the new password. The developer must update the template by appending the new secret's version ID or version stage to the dynamic reference to force a Launch Template update.Answer
- DThe stack update failed during the Auto Scaling group scaling activity due to the incorrect credential, placing the stack in the `UPDATE_ROLLBACK_IN_PROGRESS` state. The developer must manually delete the newly created EC2 instances and use the `ContinueUpdateRollback` CLI command to force the stack back to `UPDATE_COMPLETE`.