Skip to main content

Overview

The Security Group resource is a virtual firewall for controlling inbound and outbound traffic to AWS resources.
This is a thin wrapper over the standard CDK SecurityGroup. The only Fjall addition is a default description (${id} Security Group) when you omit one. Every other property and method behaves exactly as the CDK construct.

Resource Class

Basic Usage

Configuration Options

Core Properties

All standard CDK SecurityGroup properties are supported through the extending class.

Default Behaviour

  • Description: Automatically set to ${id} Security Group if not provided
  • Outbound Rules: All traffic allowed by default
  • Inbound Rules: No inbound traffic allowed by default (deny all)

Common Patterns

Web Server Security Group

Application Server Security Group

Database Security Group

Working with Connections

Using Connections Interface

Bi-directional Connections

Advanced Rules

IP-based Rules

Port Ranges

Prefix Lists

Security Group Chaining

Three-Tier Architecture

Egress Rules

Restrict Outbound Traffic

Service-Specific Egress

Integration Examples

With ECS

With Lambda

With RDS

Best Practices

Least Privilege

Rule Documentation

Avoid Circular Dependencies

Monitoring and Compliance

VPC Flow Logs

AWS Config Rules

Complete Example

Troubleshooting

Common Issues

  1. Connection timeouts: Check both ingress and egress rules
  2. Circular dependencies: Use connections interface
  3. Rule limits: Maximum 60 inbound and 60 outbound rules
  4. ICMP traffic: Remember to allow for ping/traceroute

Debug Commands

Next Steps

VPC

Define the network the security group attaches to

ECS Cluster

Attach security groups to container services

RDS Instance

Restrict database access by tier

Lambda Function

Place functions inside a secured VPC