This repository contains a collection of Terraform modules for provisioning and managing various AWS resources. These modules are designed to be reusable, configurable, and follow best practices for AWS infrastructure deployment.
Each module follows a consistent file structure:
aws.tf- Standard AWS data sources (account_id, region, partition)main.tf- Primary resource definitionsvariables.tf- Input variable declarationsoutputs.tf- Output values followingthis_[service]_[attribute]namingterraform.tf- Version constraints (all modules require >= 0.12.0)- Additional service-specific files (e.g.,
vpc.tf,iam.tf,security_groups.tf)
The repository includes the following Terraform modules:
- ALB Webhook: AWS Application Load Balancer configuration for webhook endpoints
- API Gateway V2: REST API Gateway with caching
- API Gateway V2 No Cache: REST API Gateway without caching
- App IAM: IAM roles and policies for applications
- Elasticsearch: AWS Elasticsearch service configuration
- Kinesis: AWS Kinesis data streams
- Lambda: AWS Lambda functions with configurable parameters
- Redis: AWS ElastiCache for Redis
- S3: S3 buckets with various configuration options
- SNS: Simple Notification Service topics
- SQS: Simple Queue Service queues with dead-letter queue support
- Step Functions: AWS Step Functions state machines
Compute & Functions:
lambda/- Lambda functions with VPC, IAM, and S3 artifact supportstepfunctions/- Step Functions state machines
API & Integration:
api_gateway_v2/- HTTP API Gateway with Route53api_gateway_v2_nocache/- HTTP API Gateway without cachingalb-webhook/- Application Load Balancer for webhooks
Storage & Data:
s3/- S3 buckets with lifecycle rules and encryptionelasticsearch/- Managed Elasticsearch domainsredis/- ElastiCache Redis clusters
Messaging:
sqs/- SQS queues with dead-letter queue supportsns/- SNS topics and subscriptions (modular structure)kinesis/- Kinesis data streams
Security:
app_iam/- IAM roles and policies for applications
- Terraform >= 0.12
- AWS CLI configured with appropriate credentials
- Basic understanding of AWS services and Terraform
Each module can be used by referencing it in your Terraform configuration:
module "lambda_function" {
source = "github.com/castingnetworks/devops-public//terraform/lambda"
function_name = "my-lambda-function"
handler = "index.handler"
runtime = "nodejs20.x"
artifact_bucket = "my-artifact-bucket"
artifact_hash_key = "lambda/my-function/hash.txt"
artifact_zip_key = "lambda/my-function/function.zip"
# Optional parameters
memory_size = 256
timeout = 30
environment = {
variables = {
ENV_VAR_1 = "value1"
ENV_VAR_2 = "value2"
}
}
tags = {
Environment = "production"
Project = "my-project"
}
}Creates an AWS Lambda function with configurable parameters.
Required Variables:
function_name: Name of the Lambda functionhandler: Function handler (e.g., "index.handler")runtime: Runtime environment (e.g., "nodejs14.x")artifact_bucket: S3 bucket containing Lambda artifactsartifact_hash_key: S3 key for the artifact checksum hash fileartifact_zip_key: S3 key for the artifact zip file
Optional Variables:
description: Description of the Lambda functionmemory_size: Amount of memory allocated to the functiontimeout: Function execution timeoutenvironment: Environment variables for the functionvpc_config: VPC configuration for the function- And many more (see variables.tf for details)
Creates an S3 bucket with various configuration options.
Required Variables:
bucket: Name of the S3 bucket
Optional Variables:
acl: Access control list for the bucketforce_destroy: Whether to force destroy the bucket even if it contains objectsversioning: Configuration for versioninglifecycle_rules: Configuration for object lifecycle management- And many more (see variables.tf for details)
Creates an SQS queue with a dead-letter queue.
Required Variables:
name: Name of the SQS queue
Optional Variables:
visibility_timeout_seconds: Visibility timeout for messagesmessage_retention_seconds: Message retention periodmax_message_size: Maximum message sizedelay_seconds: Delay before messages become visiblemessage_max_receive: Maximum number of receives before sending to dead-letter queue- And many more (see variables.tf for details)
When using these modules, consider the following best practices:
- Always specify explicit versions when referencing modules
- Use variables to make your configurations reusable
- Follow the principle of least privilege when configuring IAM policies
- Use tags to organize and track your AWS resources
- Implement proper error handling and monitoring