Overview
Security Groups act as virtual firewalls controlling inbound and outbound traffic for your resources. Fjall automatically creates and manages security groups when you useComputeFactory - you rarely need to create them manually.
Automatic Management
Fjall’sComputeFactory automatically:
- Creates security groups for ECS services and Lambda
- Configures ingress rules for load balancers
- Sets up service-to-service communication via the
connectionsarray - Opens required ports based on
containerPort
Service-to-Service Communication
Automatic Connection Setup
Theconnections array automatically configures security group rules:
- Creates security groups for both API and database
- Adds ingress rule to database security group allowing API traffic
- Configures correct ports (3306 for MySQL, 5432 for Postgres, etc.)
Multiple Connections
Connect to multiple services:Manual Security Group Creation
Only create explicit security groups when you need:- Shared security groups across applications
- Custom rules beyond Fjall’s automatic configuration
- External service access
Common Patterns
Allow Lambda to Access RDS
Allow Specific IP Range
Allow Between ECS Services
Network Configuration
VPC and Subnets
Security groups work within your VPC configuration:Custom VPC
Use a specific VPC:Troubleshooting
Connection Timeouts
If services can’t communicate:- Check connections array - Did you add the target to
connections? - Verify ports match - Is
containerPortcorrect? - Check VPC configuration - Are services in the same VPC?
- Review security group rules in AWS Console
Database Connection Issues
Lambda VPC Configuration
Lambda needs VPC access to use security groups:Port Reference
Common ports Fjall uses:| Service | Port | Protocol |
|---|---|---|
| HTTP | 80 | TCP |
| HTTPS | 443 | TCP |
| PostgreSQL | 5432 | TCP |
| MySQL | 3306 | TCP |
| Redis | 6379 | TCP |
| Custom Container | containerPort | TCP |
Best Practices
- Use the connections array instead of manual security group rules
- Let Fjall manage security groups for standard deployments
- Use Network Configuration to control VPC settings
- Follow least privilege - only open required ports
- Document custom rules if you add them manually
- Test connectivity after deployment
- Use VPC Flow Logs to troubleshoot traffic issues
See Also
- ComputeFactory - Automatic security group management
- Network Configuration - VPC and network settings
- DatabaseFactory - Database security groups
- VPC - Virtual private cloud configuration