如何将AWS漂移堆栈资源还原到预期状态

时间:2020-01-14 08:46:12

标签: amazon-web-services amazon-cloudformation

我有一个cloudformation堆栈,并编辑了resource属性,现在堆栈显示为漂移状态。我已经运行cli命令来查找漂移的资源并得到结果。现在,我需要使用资源属性的期望值来更新堆栈。但是在我的cloudformation堆栈中,我仅指定了资源参数。谁能告诉我如何使用资源及其属性更新堆栈。 我运行的命令

aws cloudformation describe-stack-resource-drifts --stack-name stack-test --query 'StackResourceDrifts[*].{LogicalResourceId: LogicalResourceId, PropertyDifferences: PropertyDifferences}

我得到的输出如下:

 [
     
      {
          "LogicalResourceId": "tsets3",
          "PropertyDifferences": [
                           
              {
                  "PropertyPath": "/PublicAccessBlockConfiguration/RestrictPublicBuckets",
                  "ExpectedValue": "true",
                  "ActualValue": "false",
                  "DifferenceType": "NOT_EQUAL"
              }
          ]
      }
  ]

当我尝试使用命令

aws cloudformation update-stack --stack-name stack-test --use-previous-template --resource-types="AWS::S3::*" --capabilities="CAPABILITY_NAMED_IAM"

我收到如下错误:

调用UpdateStack操作时发生错误(ValidationError):无法同时指定ResourceTypes和Capabilities。

有人可以帮我吗?

谢谢。

1 个答案:

答案 0 :(得分:0)

您必须使用控制台,CLI或SDK补救CloudFormation之外的漂移

本文应有助于补救该特定属性的漂移: https://aws.amazon.com/blogs/aws/amazon-s3-block-public-access-another-layer-of-protection-for-your-accounts-and-buckets/