AWS SAM:呼叫CreateChangeset操作时发生错误(验证)必须是一个数字

发布于 2025-01-25 16:19:04 字数 2102 浏览 11 评论 0原文

我正在为AWS RDS Aurora-Mysql云形式模板添加一个新参数。但是运行SAM部署时,我会遇到以下错误。

sam deploy \
          --region us-west-2 \
          --stack-name xxxx \
          --template-file build/product.yaml \
          --capabilities CAPABILITY_IAM \
          --capabilities CAPABILITY_NAMED_IAM \
          --parameter-overrides \
            VpcId=vpc-123456789 \
      LambdaCodeBucket=artifacts-123456789

        Deploying with following values
        ===============================
        Stack name                   : xxxx
        Region                       : us-west-2
        Confirm changeset            : False
        Deployment s3 bucket         : None
        Capabilities                 : ["CAPABILITY_NAMED_IAM"]
        Parameter overrides          : {"VpcId": "vpc-123456789", "LambdaCodeBucket": "artifacts-123456789"}
        Signing Profiles             : {}

Initiating deployment
=====================
Error: Failed to create changeset for the stack: xxxx, An error occurred (ValidationError) when calling the CreateChangeSet operation: Parameter 'MaxAllowedPacket' must be a number.
make: *** [deploy] Error 1

product.yaml代码:

  MaxAllowedPacket:
    Description: >-
      This parameter indicates the maximum size of packet in bytes. Allowed values are between 1024 to 1073741824.
      The default value is 4194304 (4 MB).
    Type: Number
    MinValue: 1024
    MaxValue: 1073741824
    Default: 4194304

....
Resources:
  ...
  DBParameterGroup:
    Type: AWS::RDS::DBParameterGroup
    Properties:
      Description: !Ref AWS::StackName
      Family: aurora-mysql5.7
      Parameters:
        max_allowed_packet: !Ref MaxAllowedPacket

我已经将maxallowedpacket的类型设置为numbern用数字 min Max ,默认值也是数字。因此,不清楚为什么要抛出此错误:错误:无法为堆栈创建更改:XXXX,在调用CreateChangeSet操作时发生错误(verialationError):参数“ maxloweredpacket”必须是数字。 make:*** [部署]错误1

我确实在其他类似的帖子上查看了 this ,但这无济于事。

I am adding a new parameter to my AWS RDS aurora-mysql CloudFormation template. But I am getting following error when running sam deploy.

sam deploy \
          --region us-west-2 \
          --stack-name xxxx \
          --template-file build/product.yaml \
          --capabilities CAPABILITY_IAM \
          --capabilities CAPABILITY_NAMED_IAM \
          --parameter-overrides \
            VpcId=vpc-123456789 \
      LambdaCodeBucket=artifacts-123456789

        Deploying with following values
        ===============================
        Stack name                   : xxxx
        Region                       : us-west-2
        Confirm changeset            : False
        Deployment s3 bucket         : None
        Capabilities                 : ["CAPABILITY_NAMED_IAM"]
        Parameter overrides          : {"VpcId": "vpc-123456789", "LambdaCodeBucket": "artifacts-123456789"}
        Signing Profiles             : {}

Initiating deployment
=====================
Error: Failed to create changeset for the stack: xxxx, An error occurred (ValidationError) when calling the CreateChangeSet operation: Parameter 'MaxAllowedPacket' must be a number.
make: *** [deploy] Error 1

product.yaml snippet:

  MaxAllowedPacket:
    Description: >-
      This parameter indicates the maximum size of packet in bytes. Allowed values are between 1024 to 1073741824.
      The default value is 4194304 (4 MB).
    Type: Number
    MinValue: 1024
    MaxValue: 1073741824
    Default: 4194304

....
Resources:
  ...
  DBParameterGroup:
    Type: AWS::RDS::DBParameterGroup
    Properties:
      Description: !Ref AWS::StackName
      Family: aurora-mysql5.7
      Parameters:
        max_allowed_packet: !Ref MaxAllowedPacket

I have set the type for MaxAllowedPacket as Number with a numeric min and max and the default value is also numeric. So not clear why is it throwing this error: Error: Failed to create changeset for the stack: xxxx, An error occurred (ValidationError) when calling the CreateChangeSet operation: Parameter 'MaxAllowedPacket' must be a number. make: *** [deploy] Error 1

I did look at other similar post on SO such as this, but it did not help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑饮青盏花 2025-02-01 16:19:04

我找到了这个问题。之所以发生这种情况,是因为我早些时候已将maxallowedpacket定义为String,并创建了资源。

旧代码:

  MaxAllowedPacket:
    AllowedPattern: ^(Auto|102[4-9]|10[3-9][0-9]|1[1-9][0-9]{2}|[2-9][0-9]{3}|[1-9][0-9]{4,8}|10[0-6][0-9]{7}|107[0-2][0-9]{6}|1073[0-6][0-9]{5}|10737[0-3][0-9]{4}|1073740[0-9]{3}|1073741[0-7][0-9]{2}|10737418[01][0-9]|107374182[0-4])$
    Default: Auto
    Description: >-
      This parameter indicates the maximum size of packet in bytes. The default value is 4194304 (4 MB).
      Allowed values are between 1024 to 1073741824, or "Auto" to use the default value
    Type: String

将其更改为号码,试图更新相同的CloudFormation堆栈时它是失败的,因为该堆栈具有maxallowedPacket作为字符串。
为了确保这是问题,我用我的新代码(如下所示)创建了一个新的CF堆栈(以及新的资源),并且效果很好。

I found the issue. This was happening because I had earlier defined MaxAllowedPacket as String and had created the resource with that.

Old Code:

  MaxAllowedPacket:
    AllowedPattern: ^(Auto|102[4-9]|10[3-9][0-9]|1[1-9][0-9]{2}|[2-9][0-9]{3}|[1-9][0-9]{4,8}|10[0-6][0-9]{7}|107[0-2][0-9]{6}|1073[0-6][0-9]{5}|10737[0-3][0-9]{4}|1073740[0-9]{3}|1073741[0-7][0-9]{2}|10737418[01][0-9]|107374182[0-4])$
    Default: Auto
    Description: >-
      This parameter indicates the maximum size of packet in bytes. The default value is 4194304 (4 MB).
      Allowed values are between 1024 to 1073741824, or "Auto" to use the default value
    Type: String

After changing it to Number, it was failing when trying to update the same CloudFormation Stack because that Stack was having MaxAllowedPacket as String.
To ensure this was the issue, I created a new CF Stack (and hence new resource) with my new code (as shown on the question here) and it worked fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文