Overview
Security Groups and Key Pairs are fundamental for protecting your AWS infrastructure and managing SSH access. By leveraging well-tested community modules, you can apply best practices without reinventing the wheel.Prerequisites
- Terraform v1.0+ installed
- Terragrunt v0.35+ installed
- AWS CLI configured with proper credentials
- Existing VPC and networking resources deployed
Community Terraform Modules
Directory Structure
development and production) contains its own terragrunt.hcl to customize inputs and lifecycle settings.
terragrunt.hcl Example
Deployment Steps
- Change into the environment folder:
- Initialize Terragrunt (which also initializes Terraform):
- Review the execution plan:
- Apply changes to provision resources:
Repeat these steps in each environment directory (
development, production) to maintain isolation and environment-specific configurations.Customizing Input Variables
Adjust the following inputs for each environment:Never commit your private SSH keys (
~/.ssh/id_rsa) to version control. Always reference only the public key in Terraform.Links and References
- Terraform AWS Security Group Module
- Terraform AWS Key Pair Module
- Terragrunt Documentation
- AWS Security Groups