Now that we have created the basic VPC structure, let's go ahead and create security groups. We need the following security groups:
- lambdaSecurityGroup: It should allow all outgoing traffic. This is to be attached to the lambda functions.
- databaseSecurityGroup: It should allow incoming traffic on port 5432 only from the lambdaSecurityGroup previously created.
Following code snippet shows the creation of the security groups:
lambdaSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: Security Group for Lambda VpcId: Ref: letsPollVPC Tags: - Key: Name Value: Lambda Security group databaseSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: Security Group for database VpcId: Ref: ...