brianz/serverless-design-patterns

Error when deploying--invalid subnets

Opened this issue · 2 comments

Really enjoying the book, but when I try to deploy, I keep getting this error message:

Error message:

An error occurred: RDSSubnetGroup - Some input subnets in :[subnet-04cb33f4001924f59, subnet-084fb5fd9987a0cf7] are invalid. (Service: AmazonRDS; Status Code: 400; Error Code: InvalidParameterValue; Request ID: 60ac3262-5b4c-43b8-b924-7043d6299e62).

I've tried manually creating new VPCs and subnets per the AWS docs, but nothing is working for me.

Any thoughts? Thanks!

Hi @mwebdev1

Thanks for this, I'll take a look. Which chapter's code were you seeing this error?

Thanks for this, I'll take a look. Which chapter's code were you seeing this error?

Chapter 2. I'm getting the error when I try to deploy with a yml file based off of yours:

`functions:
createuser:
handler: api/handlers.createuser
events:
- http:
path: /createuser
method: post
cors: true
getuser:
handler: api/handlers.getuser
events:
- http:
path: /getuser/{id}
method: get
cors: true

plugins:

  • serverless-offline

resources:
Resources:
ServerlessSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: SecurityGroup for Serverless Functions
VpcId: ${file(./config/config.${self:provider.stage}.json):VPC_ID}
RDSSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Ingress for RDS Instance
VpcId: ${file(./config/config.${self:provider.stage}.json):VPC_ID}
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '5432'
ToPort: '5432'
SourceSecurityGroupId:
Ref: ServerlessSecurityGroup
RDSSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: RDS Subnet Group
SubnetIds:
- ${file(./config/config.${self:provider.stage}.json):SUBNET_ID_A}
- ${file(./config/config.${self:provider.stage}.json):SUBNET_ID_B}
RDSPostgresInstance:
Type: AWS::RDS::DBInstance
Properties:
AllocatedStorage: 100
AutoMinorVersionUpgrade: true
AvailabilityZone: us-west-2a
DBInstanceClass: db.t2.micro
DBName: ${file(./config/config.${self:provider.stage}.json):DATABASE}
DBSubnetGroupName:
Ref: RDSSubnetGroup
Engine: postgres
EngineVersion: 9.6.2
MasterUsername: ${file(./config/config.${self:provider.stage}.json):USER}
MasterUserPassword: ${file(./config/config.${self:provider.stage}.json):DB_PASSWORD}
PubliclyAccessible: false
VPCSecurityGroups:
- Fn::GetAtt: RDSSecurityGroup.GroupId`

Thanks!