gpt4 book ai didi

amazon-web-services - 如何在信任关系中导入值(value)

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

我从另一个堆栈导出了一个值,并尝试在 cloudformation 角色中导入“AssumeRolePolicyDocument”,尝试了很多方法,但出现了以下错误

“位置 (1,195) 处出现语法错误(服务:AmazonIdentityManagement;状态代码:400;错误代码:MalformedPolicyDocument;请求 ID:b1b4b5ef-88ef-444b-8aa7-0548ce0002a6;代理:null)”

  EksAutoscalerRole: 
Type: AWS::IAM::Role
Properties:
RoleName: Eks-Autoscaler-Role
Path: "/"
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Federated:
'Fn::Sub':
- 'arn:aws:iam::1122334455:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/${oidc}'
- oidc:
"Fn::ImportValue": EksOidc
Action: 'sts:AssumeRoleWithWebIdentity'
Condition:
StringEquals:
'Fn::Sub':
- 'oidc.eks.us-east-1.amazonaws.com/id/${oidc}:sub: system:serviceaccount:kube-system:cluster-autoscaler'
- oidc:
"Fn::ImportValue": EksOidc
ManagedPolicyArns:
- !Ref EksAutoscalerPolicy

也尝试过以下方法: Insert a CloudFormation ImportValue similar to how you can insert a Parameter?

已更新尝试了下面的代码现在可以工作了。

  EksAutoscalerRole: 
Type: AWS::IAM::Role
Properties:
RoleName: Eks-Autoscaler-Role
Path: /
AssumeRolePolicyDocument:
"Fn::Sub":
- '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "${EksAutoscalerProvider}"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"oidc.eks.${AWS::Region}.amazonaws.com/id/${oidcNo}:sub": "system:serviceaccount:kube-system:cluster-autoscaler"
}
}
}
]
}'
- oidcNo: !Select [0, !Split [".", !Select [1, !Split ["//", !GetAtt EksCluster.Endpoint]]]]
ManagedPolicyArns:
- !Ref EksAutoscalerPolicy

最佳答案

检查你的缩进。 Sub 函数应该按照 documentation 像这样缩进:

Fn::Sub:
- String
- Var1Name: Var1Value
Var2Name: Var2Value

关于amazon-web-services - 如何在信任关系中导入值(value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71471921/

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