amazon-web-services - !GetAtt 无法与 cloudformation 中的 !Sub 一起使用

标签 amazon-web-services aws-cloudformation serverless-framework

我正在尝试使用 Cloudformation 和无服务器框架创建一些资源,其中我需要替换另一个资源中的资源名称。尝试使用 !Sub 但仍然无法创建另一个资源的 Arn。

尝试了此 stackoverflow 问题 How to use Sub and GetAtt functions at the same time in CloudFormation template? 中的所有方法无济于事。

我很感激任何帮助。

Resources:
  BasicParameter:
    Type: AWS::SSM::Parameter
    Properties:
      Name: /data/config-name
      Type: String
      Value:
        Fn::Base64:
          !Sub |

            {
                "filter_configs": [{
                    "stream_name": !GetAtt tpRecordDeliveryStream.Arn,
                    "events": [
                        {
                            "name": "event_name1",
                            "stream": "streamname1"
                        },
                        {
                            "name": "event_name2"
                        }
                    ]
                }]
            }
      Description: Configuration for stream filters
      Tags:
        project: projectname
        team: data
        owner: owner_name

最佳答案

这是通过使用serverless-pseudo-parameters无服务器插件解决的。 Serverless 框架还使用 ${} 占位符,它与 Cloudformation 占位符冲突。 serverless-pseudo-parameters 解决了这个问题,它允许我们用 #{} 替换这些占位符,这些占位符在 sls 部署 期间替换为云形成模板

Resources:
  streamConfig:
    Type: AWS::SSM::Parameter
    Properties:
      Name: config_name
      Type: String
      Value:
        Fn::Base64: |
          {
              "filter_configs": [{
                  "firehose_stream_arn": "#{tpRecordDeliveryStream.Arn}",
                  "events": [
                      {
                          "name": "config0",
                          "filter1": "value1"
                      },
                      {
                          "name": "config1"
                      }
                  ]
              }]
          }
      Description: Configuration for stream filters

关于amazon-web-services - !GetAtt 无法与 cloudformation 中的 !Sub 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62323975/

相关文章:

amazon-web-services - yaml 中的 Cloudformation 嵌套堆栈输出

amazon-web-services - EC2 Cloudformation 模板的 Cloud-init 中的用户数据脚本错误

aws-cloudformation - 如何通过cloudformation在sagemaker中创建无服务器端点?

aws-lambda - 如何在 serverless.yml 中配置 eventbridge 规则(使用无服务器框架)以在特定时间调用 lambda

amazon-web-services - 尽管有关于 lambda 的资源策略声明,EventBridge 规则不会触发 Lambda

unix - 有没有办法在 Unix 中安装特定版本的 AWS CLI 实用程序?

amazon-web-services - 调用 aws cli 的用户数据脚本

amazon-web-services - 弹性Beanstalk : storing a bullet proof docker container

node.js - 上传的文件必须是非空的 zip(服务 : AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException;

amazon-web-services - SNS 主题说它需要一个字符串