gpt4 book ai didi

amazon-web-services - Cloudformation 组合 Sub 和 Join 以获得列表

转载 作者:行者123 更新时间:2023-12-03 07:23:30 25 4
gpt4 key购买 nike

我正在尝试在我的 Cloudformation 模板中创建一个列表。

受到这篇文章的启发:Sub and Join on Comma-Delimited List我已经有了这个想法,但它不起作用,因为 !Sub 行必须是一个字符串...

错误是:

Error: Failed to create changeset for the stack: STACKNAME, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state: For expression "Status" we matched expected path: "FAILED" Status: FAILED. Reason: Template error: every Fn::Join object requires two parameters, (1) a string delimiter and (2) a list of strings to be joined or a function that returns a list of strings (such as Fn::GetAZs) to be joined.

有什么想法吗?这可能吗?

  Accounts:
Type: CommaDelimitedList
Default: Acc1,Acc2,Acc3

pRedshiftUser:
Type: String
Default: arn:redshiftperson

...

Action: sts:AssumeRole
Condition:
StringEquals:
sts:ExternalId: !Split
- ','
- !Sub
- '${pRedshiftUser}/${user}'
- user: !Join
- !Sub ',${pRedshiftUser}/'
- Ref: "Accounts"

我的想法是尝试将其创建为输出:

  Action: sts:AssumeRole
Condition:
StringEquals:
sts:ExternalId:
- arn:redshiftperson/user1
- arn:redshiftperson/user2

最佳答案

遗憾的是你不能这样做。 Join 中的 Delimiter 必须是 explicit string .

For the Fn::Join delimiter, you can't use any functions. You must specify a string value.

因此您不能在 Delimiter 中使用 Sub

唯一的方法是创建自定义 macrocustom resource在 CloudFormation 中。在这两种方式中,您都需要开发一个 lambda 函数来处理将数据转换为所需的格式。

关于amazon-web-services - Cloudformation 组合 Sub 和 Join 以获得列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67397856/

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