【问题标题】:Value of property does not match type Number YML属性值与类型 Number YML 不匹配
【发布时间】:2021-10-15 14:45:14
【问题描述】:

我正在尝试通过aws cloudformation deploy 命令传递参数,如下所示:

aws cloudformation deploy --template-file sam-template.packaged.yaml --parameter-overrides ExcTime=12345

但它部署失败,因为它抱怨ExcTime 参数是一个字符串,它需要是一个数字。是将所有参数转换为字符串的命令吗?如果是这样,我如何通过该命令将 number 类型的参数传递给 YML 文件?

yml 文件:

  ApiKey:
      Type: AWS::AppSync::ApiKey
      Properties:
        ApiId: !GetAtt AppSyncApi.ApiId
        Expires: ${ExcTime}

谢谢大家!

【问题讨论】:

  • 我已经发布了答案:)
  • 谢谢,但是你的答案和我的有什么不同呢?我写的应该是Expires: !Ref ExcTime?所以在我看来,您复制并粘贴了我的答案,添加了一些额外的文本,却没有确认我的答案是正确的,也没有被接受?

标签: amazon-web-services yaml amazon-cloudformation aws-sam


【解决方案1】:

所以我想出了原因。 --parameter-overrides Param=value 只接受字符串

--parameter-overrides (list) 参数结构的列表 为您的堆栈模板指定输入参数。如果你正在更新 堆栈并且您没有指定参数,该命令使用 堆栈的现有值。对于新堆栈,您必须指定参数 没有默认值。句法: ParameterKey1=ParameterValue1 ParameterKey2=ParameterValue2 ...(字符串)。 https://docs.aws.amazon.com/cli/latest/reference/cloudformation/deploy/index.html

要传递一个数字,您需要在 sam 模板中指定该值是一个数字,如下所示:

Parameters:
  YourParam:
    Type: Number
    Description: Bla bla bla

然后您可以将其用作模板中的数字。例如

Expires: !Ref YourParam

【讨论】:

    【解决方案2】:

    要引用您的参数,您应该使用:

    Expires: !Ref ExcTime
    

    【讨论】:

      猜你喜欢
      • 2013-12-22
      • 1970-01-01
      • 2014-09-18
      • 2013-03-22
      • 2021-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-08
      相关资源
      最近更新 更多