假设我创建了
CognitoUserPoolIdentityProviderGoogle:
Type: AWS::Cognito::UserPoolIdentityProvider
Properties:
ProviderName: Google
AttributeMapping:
email: emailAddress
ProviderDetails:
client_id: xxxx
client_secret: yyyy
authorize_scopes: profile email openid phone
ProviderType: Google
UserPoolId:
Ref: CognitoUserPoolUserPool
后来有人手动将 client_id
和 client_secret
更新为 1111
和 2222
。重新运行 CloudFormation 将导致覆盖手动更改并将值恢复为 xxxx
和 yyyy
。
我该如何避免这种情况? AWS::Cognito::UserPoolIdentityProvider
只是一个示例 - 这可以是任何资源。
我正在寻找的基本上是 ignore_changes 的功能在地形中
最佳答案
CFN 中不存在“忽略更改”。在 CFN 无法控制的情况下手动修改 CFN 管理的任何资源是一种不好的做法。手动更改可能会导致很多问题,您正在描述其中之一。
您所观察到的内容的技术术语是 stack drift 。管理它的方法很少。但当您怀疑它时,您要做的第一件事就是运行 drift detection在任何更新之前在您的堆栈上。
由于在您的情况下漂移并没有那么糟糕,因此您有两个选择:
- 手动更新 CFN 模板以匹配手动更改,并更新堆栈
- 手动将资源修改回其原始状态,然后通过 CFN 应用所有更新。
关于amazon-web-services - AWS CloudFormation - 忽略属性更改 - `ignore_changes` 来自 Terraform 等效项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64858871/