首页 > 解决方案 > 用于执行 CloudFormation 更改集的直接 URL

问题描述

在 AWS CloudFormation 中,我有一些更改集:

{
  "eks-alb-ingress-private-security-groups": [
    {
      "StackId": "arn:aws:cloudformation:ap-southeast-2:111111111111:stack/eks-alb-ingress-private-security-groups/f452e940-3fe0-11ea-a91a-0a564743ac36",
      "StackName": "eks-alb-ingress-private-security-groups",
      "ChangeSetId": "arn:aws:cloudformation:ap-southeast-2:111111111111:changeSet/sceptre-change-set-eks-cluster-addons/2d497c25-2a02-4373-96c2-9f099076d264",
      "ChangeSetName": "sceptre-change-set-eks-cluster-addons",
      "ExecutionStatus": "AVAILABLE",
      "Status": "CREATE_COMPLETE",
      "CreationTime": "2020-03-17 08:05:53.943000+00:00"
    }
  ]
}

文档中很好地解释了我如何执行该更改集。

但是,当应用许多更改集时,如果我可以在运行aws cloudformation list-change-sets. 这将节省我很多点击!

我尝试从以下开始:

https://ap-southeast-2.console.aws.amazon.com/cloudformation/home?region=ap-southeast-2#/stacks/events?

然后使用https://www.url-encode-decode.com进行 URL 编码:

encoded_stack_id=...
encoded_change_set_id=...

导致生成的 URL:

url="https://ap-southeast-2.console.aws.amazon.com/cloudformation/home?region=ap-southeast-2#/stacks/events?StackId=${encoded_stack_id}&ChangeSetId=${encoded_change_set_id}"

但这会导致发出此错误:

You must specify a Stack ID. Displaying your Stacks page.

The URL specified is invalid.
You must specify both a Stack ID and a Change Set ID. Displaying your Stacks page.

有可能做我想做的事吗?如果是这样,怎么做?

标签: amazon-cloudformation

解决方案


经过多次试验和错误,我终于得到了这个工作:

首先,我安装了gridsite-clients

apt-get install gridsite-clients

然后:

main_part="https://ap-southeast-2.console.aws.amazon.com/cloudformation/home?region=ap-southeast-2#/stacks/changesets/changes"

stack_id=$(urlencode \
  "arn:aws:cloudformation:ap-southeast-2:111111111111:stack/eks-alb-ingress-private-security-groups/f452e940-3fe0-11ea-a91a-0a564743ac36")

change_set_id=$(urlencode \
  "arn:aws:cloudformation:ap-southeast-2:111111111111:changeSet/sceptre-change-set-eks-cluster-addons/2d497c25-2a02-4373-96c2-9f099076d264")

url="$main_part?stackId=$stack_id&changeSetId=$change_set_id"

然后,该变量$url包含将您带到 AWS 控制台中的更改集执行页面的直接 URL。


推荐阅读