gpt4 book ai didi

amazon-web-services - 如何使用 cloudformation 生成 AWS 字符串条件

转载 作者:行者123 更新时间:2023-12-03 07:33:44 24 4
gpt4 key购买 nike

我有以下代码,但无法使用 StringEquals 获取结束部分来打印运行 cloudformation 的正确值。

Parameters:
OpenIDClientIdList:
Type: String
Description: Open ID client ID
Default: urn:dev.aws.services.xxxxx.com

OpenIDURL:
Type: String
Description: Open ID URL
Default: "sts.windows.net/dddddd-rr444-ssss-94c3-7484898492d/"

Resources:
OpenIDCAssumeReadOnlyRole:
Type: AWS::IAM::Role
Properties:
RoleName: OpenIDCAssumeReadOnlyRole
ManagedPolicyArns: [arn:aws:iam::aws:policy/ReadOnlyAccess]
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Federated: !Sub arn:aws:iam::${AWS::AccountId}:oidc-provider/${OpenIDURL}
Action: sts:AssumeRoleWithWebIdentity
Condition:
StringEquals: !Sub
- ''
- - '${OpenIDURL}:aud:'
- '${OpenIDClientIdList}'

预期条件字符串值

         "Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"sts.windows.net/dddddd-rr444-ssss-94c3-7484898492d/:aud": "urn:dev.aws.services.xxxxx.com"
}
}

最佳答案

您没有正确使用!Sub。条件应如下所示:

Condition:
StringEquals:
Fn::Base64: !Sub
- |
"${OPENIDURL}:aud": "${OPENIDCLIENTIDLIST}"
- OPENIDURL: !Ref OpenIDURL
OPENIDCLIENTIDLIST: !Ref OpenIDClientIdList

关于amazon-web-services - 如何使用 cloudformation 生成 AWS 字符串条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71740483/

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