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.
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.