SamWSoftware / 7PracticalServerlessProjects

11 stars 9 forks source link

URL shortner - Serverless deploy error - cloudformation template #1

Open duffmanlight opened 1 year ago

duffmanlight commented 1 year ago

Working through the URL shortner project. The initial serverless deploy is failing with a validation error. I tried comparing my 'serverless.ts' locally with the GH version but can't find the error. It is probably a syntax error on my end but would appreciate some help.

Error: The CloudFormation template is invalid: 1 validation error detected: Value '[AWS::S3::BucketPolicy, AWS::ApiGatewayV2::Stage, AWS::S3::Bucket, AWS::DynamoTable, AWS::ApiGatewayV2::Route, AWS::IAM::Role, AWS::Logs::LogGroup, AWS::Lambda::Function, AWS::Lambda::Version, AWS::ApiGatewayV2::Integration, AWS::ApiGatewayV2::Api, AWS::Lambda::Permission]' at 'typeNameList' failed to satisfy constraint: Member must satisfy constraint: [Member must have length less than or equal to 204, Member must have length greater than or equal to 10, Member must satisfy regular expression pattern: [A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}(::MODULE){0,1}]

serverless.txt

SamWSoftware commented 1 year ago

After some googling I found the answer.

In your dynamo.ts file, you've set the type to be "AWS::DynamoTable", when it needs to be AWS::DynamoDB::Table

SamWSoftware commented 1 year ago

The error was basically saying that something in this array either is the wrong length or doesn't match the regex. In your case it was that AWS::DynamoTable doesn't match the regex of something::something::something

[AWS::S3::BucketPolicy, AWS::ApiGatewayV2::Stage, AWS::S3::Bucket, AWS::DynamoTable, AWS::ApiGatewayV2::Route, AWS::IAM::Role, AWS::Logs::LogGroup, AWS::Lambda::Function, AWS::Lambda::Version, AWS::ApiGatewayV2::Integration, AWS::ApiGatewayV2::Api, AWS::Lambda::Permission]

duffmanlight commented 1 year ago

Thank you Sam. That was the bug. The code now deploys correctly to AWS.