Cloudformation模板格式错误:每个DeletionPolicy成员必须是一个字符串 [英] Cloudformation Template format error: Every DeletionPolicy member must be a string

查看:179
本文介绍了Cloudformation模板格式错误:每个DeletionPolicy成员必须是一个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 IF函数,就像RDS DeletionPolicy的云形成文档中提到的那样,但是由于某种原因,它说我的函数没有返回字符串。

Hi I am trying to use the "IF" Function just like mentioned in cloud formation documentation for RDS DeletionPolicy, but for some reason it says that my function does not return a string.

AWS文档在条件语句

这是条件:

 "DeletionPolicy" : {
    "Fn::If" : [
      "CreateProdResources",
      "Snapshot",
      "Delete"
    ]}

错误是标题中的一个:

Template validation error: Template format error: Every DeletionPolicy member must be a string.

其他无效的尝试:

使用地图:

 "RdsDeletionPolicyMap" :{
      "production" : {
          "policy" : "Snapshot"
      },
      "staging" : {
          "policy" : "Delete"
      }
   }

然后:

   "DeletionPolicy" : {
      "Fn::FindInMap" : [ "RdsDeletionPolicyMap", {"Ref": "RailsEnvironment"}, "policy" ]
   }

以及简单的 Ref:... 也不起作用。我高度怀疑这是cloudformation的错误

As well as a Simple "Ref": ... didn't work as well. I highly suspect this is a bug with cloudformation

推荐答案

问题是必须将DeletionPolicy设置为三个字符串之一。而且,尽管您的If支票将返回其中的一个,但从系统的角度来看,它仅知道它正在返回一个String-但不能保证它是有效的字符串(与您的map和parameter检查相同),因此它仅接受

The issue is that DeletionPolicy must be set to one of three strings. And, though your If check will return one of them, from a systematic perspective, it only knows that it's returning a String - but is not guaranteed to be a valid string (same with your map and parameter checks), and thus it only accepts a string literal and not something that resolves to string.

我相信此限制以前是对AWS工程团队提出的,因为这很麻烦。

I believe that this limitation has been raised to the AWS Engineering team previously, as it is a nuisance.

这篇关于Cloudformation模板格式错误:每个DeletionPolicy成员必须是一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆