amazon-web-services - AWS CloudFormation - 有什么方法可以使用内部函数作为对象键?

标签 amazon-web-services aws-cloudformation amazon-cognito

我有这个角色附件资源,部署得很好:

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/

相关文章:

oauth - AWS API Gateway - 将访问 token 与 Cognito 用户池授权方一起使用?

javascript - 有没有办法在 AWS Lambda 中获取 Cognito 用户名?

ruby - 在 AWS elastic map/reduce 上运行 MRToolkit hadoop 作业

aws-cloudformation - 为什么 GetAttr 不适用于 cloudformation 模板参数?

json - 创建堆栈中的 Cloudformation 错误 : "ELB cannot be attached to multiple subnets in the same AZ"

amazon-web-services - CDK 将预先存在的存储桶用于 CI CD Pipeline for Artifacts

amazon-web-services - 如何使用 CloudFormation 允许使用用户名和电子邮件登录的 AWS Cognito 配置?

python - 尝试使用子进程将特定文件从 S3 存储桶下载到 EC2 时参数类型无效

amazon-web-services - 使用 AWS API Gateway 继承 OpenAPI/Swagger 模型

python-3.x - 如何使用 AWS 证书管理器验证域