我有这个角色附件资源,部署得很好:
CognitoIdentityPoolRoleAttachment:
DependsOn: [ CognitoIdentityPool, CognitoIdentityPoolAuthRole, CognitoIdentityPoolUnauthRole ]
Type: "AWS::Cognito::IdentityPoolRoleAttachment"
Properties:
IdentityPoolId: !Ref CognitoIdentityPool
RoleMappings:
'cognito-idp.us-west-2.amazonaws.com/us-west-2_naEXQTLxD:44rd7mu8dncna2kqimd74f7u98':
Type: Token
AmbiguousRoleResolution: AuthenticatedRole
Roles:
unauthenticated: !GetAtt CognitoIdentityPoolUnauthRole.Arn
authenticated: !GetAtt CognitoIdentityPoolAuthRole.Arn
但是,正如您所看到的,我有一个 RoleMappings 属性,它实际上是附加到我的 Cognito 用户池客户端 ID 的 CognitoUserPool ProviderName,因此我需要此属性具有动态名称。
但是,查看文档,我找不到在对象键上实际使用内部函数的方法。当我尝试这个时:
RoleMappings:
!Sub '${CognitoUserPool.ProviderName}:${CognitoUserPoolClient}':
Type: Token
AmbiguousRoleResolution: AuthenticatedRole
我收到无效模板错误。我是否缺少一种特殊的语法,可以让您定义键而不是属性?或者我必须以其他方式做到这一点?
最佳答案
使用 CloudFormation 无法开箱即用地执行此操作。 然而,this thread建议一种涉及 Lambda 支持的自定义资源的解决方法。
关于amazon-web-services - AWS CloudFormation - 有什么方法可以使用内部函数作为对象键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48994868/