[英]AWS SAM: An error occurred (ValidationError) when calling the CreateChangeSet operation: Parameter 'MaxAllowedPacket' must be a number
I am adding a new parameter to my AWS RDS aurora-mysql CloudFormation template.我正在向我的 AWS RDS aurora-mysql CloudFormation 模板添加一个新参数。 But I am getting following error when running
sam deploy
.但是我在运行
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: 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
I have set the type for MaxAllowedPacket
as Number
with a numeric min and max and the default value is also numeric.我已将
MaxAllowedPacket
的类型设置为带有数字最小值和最大值的Number
,默认值也是数字。 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
所以不清楚为什么会抛出此错误:
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
I did look at other similar post on SO such as this , but it did not help.我确实看过 SO 上的其他类似帖子,例如this ,但没有帮助。
I found the issue.我发现了问题。 This was happening because I had earlier defined
MaxAllowedPacket
as String
and had created the resource with that.发生这种情况是因为我之前将
MaxAllowedPacket
定义为String
并使用它创建了资源。
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.将其更改为
Number
后,尝试更新相同的 CloudFormation 堆栈时失败,因为该堆栈将MaxAllowedPacket
作为字符串。 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.为确保这是问题所在,我使用我的新代码(如此处的问题所示)创建了一个新的 CF 堆栈(并因此创建了新资源)并且它运行良好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.