vpc_config

Type object({ subnet_ids = list(string) security_group_ids = list(string) })
Default null

VPC configuration for private network access

VPC Configuration Structure

vpc_config = {
  subnet_ids         = ["subnet-abc123", "subnet-def456"]
  security_group_ids = ["sg-123456"]
}

When to Use VPC

  • Access to RDS, ElastiCache, or other VPC resources
  • Compliance requirements for data isolation
  • Integration with on-premises resources via VPN/Direct Connect

Important Considerations

  • Cold starts: VPC-enabled functions have longer cold starts
  • Internet access: Requires NAT Gateway for outbound internet
  • IP addresses: Functions use Elastic Network Interfaces (ENIs)
  • Concurrency: ENI limits may affect scaling

Best Practices

  • Use private subnets for Lambda functions
  • Create dedicated security groups for Lambda
  • Place functions in multiple AZs for availability
  • Consider AWS PrivateLink for AWS service access

Full Module Example

module "lambda_function" {
  source  = "registry.patterneddesigns.ca/patterneddesigns/lambda-function/aws"
  version = "0.1.0"

  # vpc_config
  vpc_config = "..."

  # Other required inputs
  function_name = my-resource
  runtime = python3.9
  handler = example-value
  source_path = /path/to/resource
}