Skip to content

Conversation

ShivamMishra828
Copy link

Add Terraform setup for AWS EC2 with remote state management

Overview

This PR introduces Terraform code to provision an AWS EC2 instance that can be used for deploying Jenkins and other DevOps tools. It also sets up remote state management using S3 (for state storage) and DynamoDB (for state locking), ensuring safe collaboration and consistency.

Changes Introduced

  • Added Terraform configuration to:
    • Create an EC2 instance in the default VPC with SSH access.
    • Attach a key pair for SSH login.
    • Configure a security group allowing SSH (22), HTTP (80), and HTTPS (443) ingress.
    • Provision root volume with customizable size and type.
  • Configured remote backend:
    • S3 bucket to store Terraform state.
    • DynamoDB table for state lock and release mechanism.

How to Use

  1. Update terraform.tfvars with your values:

    • public_key
    • ami_id
    • instance_type
    • s3_bucket_name
    • dynamodb_table_name (ensure they exist)
  2. Initialize Terraform:

    terraform init
  3. Apply infrastructure changes:

    terraform apply

Why This Change?

  • Provides infrastructure-as-code for consistent EC2 provisioning.
  • Ensures safe collaboration with remote state management.
  • Lays the foundation for CI/CD pipeline setup with Jenkins on EC2.

Notes

  • This PR is not related to any existing issue.
  • Tools like Jenkins will be installed manually via SSH after provisioning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant