Skip to main content
In this step, we’ll deploy AWS Security Groups and Key Pairs across multiple environments using community-maintained Terraform modules and Terragrunt.

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

Each environment (development and production) contains its own terragrunt.hcl to customize inputs and lifecycle settings.

terragrunt.hcl Example

Deployment Steps

  1. Change into the environment folder:
  2. Initialize Terragrunt (which also initializes Terraform):
  3. Review the execution plan:
  4. 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.

Watch Video