【发布时间】:2018-08-06 06:50:35
【问题描述】:
我有这个角色附件资源,可以很好地部署:
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 属性,它实际上是我的 CognitoUserPool ProviderName 附加到我的 Cognito 用户池客户端 ID,所以我需要这个属性有一个动态名称。
但是,查看文档,我找不到在对象键上实际使用内部函数的方法。当我尝试这个时:
RoleMappings:
!Sub '${CognitoUserPool.ProviderName}:${CognitoUserPoolClient}':
Type: Token
AmbiguousRoleResolution: AuthenticatedRole
我收到一个无效的模板错误。我是否缺少允许您定义键而不是属性的特殊语法?还是我必须以其他方式做到这一点?
【问题讨论】:
-
我认为这里最简单的解决方案是使用外部脚本生成模板。您还可以尝试创建一个自定义资源来生成模板,然后从该模板创建一个堆栈,使用
AWS::CloudFormation::Stack和该资源的结果。
标签: amazon-web-services amazon-cloudformation amazon-cognito