CloudFormation可选映射属性- DeadLetterQueue



我需要'AWS::Serverless::Function'中的DeadLetterQueue属性仅在Env=ppd或Env=prod时创建

Conditions:
IsPpdOrPrdEnv: !Or [!Equals [!Ref "Env", ppd], !Equals [!Ref "Env", prod]]
<...>
Resources:
<...>
TestFunction:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: !Sub '${Env}-Test-Function'
DeadLetterQueue: 
TargetArn: !If [IsPpdOrPrdEnv, !Ref TestSNSTopic, !Ref "AWS::NoValue"]
Type: !If [IsPpdOrPrdEnv, SNS, !Ref "AWS::NoValue"]
<...>

错误:

Transform AWS::Serverless-2016-10-31 failed with: Internal Transform failure.

我也试过:

DeadLetterQueue: 
!If
- IsPpdOrPrdEnv
- 
TargetArn: !Ref TestSNSTopic
Type: SNS
- !Ref "AWS::NoValue"

错误:

Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification文档。发现的错误数:1。id为[TestFunction]的资源无效。'DeadLetterQueue'需要指定Type和TargetArn属性。

有什么建议吗?

这似乎是错误/限制地对空导弹。github中有一些公开的问题(这里和这里)描述了你所遇到的问题。

由于这两个问题都是打开的,它们未解决. 提供的唯一解决方法是:

我们最终需要添加一个(手动或脚本)预部署步骤,如果不需要[DeadLetterQueue],则只需删除整个[DeadLetterQueue]配置部分。

最新更新