簡體   English   中英

AWS SAM:調用 CreateChangeSet 操作時發生錯誤 (ValidationError):參數“MaxAllowedPacket”必須是數字

[英]AWS SAM: An error occurred (ValidationError) when calling the CreateChangeSet operation: Parameter 'MaxAllowedPacket' must be a number

我正在向我的 AWS RDS aurora-mysql CloudFormation 模板添加一個新參數。 但是我在運行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 片段:

  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的類型設置為帶有數字最小值最大值Number ,默認值也是數字。 所以不清楚為什么會拋出此錯誤: 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 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

我確實看過 SO 上的其他類似帖子,例如this ,但沒有幫助。

我發現了問題。 發生這種情況是因為我之前將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

將其更改為Number后,嘗試更新相同的 CloudFormation 堆棧時失敗,因為該堆棧將MaxAllowedPacket作為字符串。 為確保這是問題所在,我使用我的新代碼(如此處的問題所示)創建了一個新的 CF 堆棧(並因此創建了新資源)並且它運行良好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM