gpt4 book ai didi

aws-cloudformation - Cloudformation 模板中的 Fn::Split 和 Fn::Select 组合

转载 作者:行者123 更新时间:2023-12-02 02:48:55 25 4
gpt4 key购买 nike

我正在尝试将 Fn::Select 和 Fn::Split 与 Stack 模板中的 Fn::ImportValue 函数结合起来,如下所示:

 Resources:
ALBDashboard:
Type: AWS::CloudWatch::Dashboard
Properties:
DashboardName: ALB-Dashboard
DashboardBody: !Sub
- |
{
"widgets": [
{
"type": "metric",
"x": 0,
"y": 21,
"width": 9,
"height": 3,
"properties": {
"metrics": [
[ "AWS/ApplicationELB", "RequestCount", "TargetGroup", "targetgroup/GeneratorTG/ca775e3193d3b120", "LoadBalancer", "app/Dev-Invoicegen-ALB-Internet/8ac95b5b6900fa0c", "AvailabilityZone", "${AvailabilityZone1}", { "stat": "Sum" } ],
[ "...", "${AvailabilityZone2}", { "stat": "Sum" } ],
[ "...", "${AvailabilityZone3}", { "stat": "Sum" } ]
],
"view": "singleValue",
"region": "${AWS::Region}",
"period": 300,
"title": "Request Count GeneratorTG 5 min - Sum"
}
},
- TargetGroup:
Fn::Select: [5, Fn::Split: [":", Fn::ImportValue: !Sub "${EnvironmentName}-WebTGARN" ]]

但不断收到以下错误:

Template format error: YAML not well-formed

但根据这个博客,它似乎是正确的:

https://garbe.io/blog/2017/07/17/cloudformation-hacks/

另一方面,如果我尝试这个,它会起作用:

  -  TargetGroup1:
Fn::Select:
- 5
- Fn::Split:
- ":"
- Fn::ImportValue: !Sub "${EnvironmentName}-WebTGARN"

谁能告诉我错误出在哪里吗?

感谢A

最佳答案

这对我有用。

TemplatesS3BucketName: !Select [2, !Split ["/", !Select [0, !Split [".", !Ref TemplatesS3BucketURL]]]]

使用 YAML CFN 模板时,我倾向于使用 !而不是 Fn::并且运气更好。

关于aws-cloudformation - Cloudformation 模板中的 Fn::Split 和 Fn::Select 组合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53034099/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com