Skip to content

AWS Infrasturcure Provisioning using modules structure for effective management. Includes aws report shell script.

Notifications You must be signed in to change notification settings

RScrafted/terraform-aws-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform AWS Infrastructure Setup

This Terraform project creates:

  • An Amazon S3 bucket
  • An IAM user

Project Structure

terraform-aws-setup/
├── aws-report.sh         # <--- bonus script!
├── main.tf
├── provider.tf
├── modules/
│   ├── s3_bucket/
│   │   ├── main.tf
│   └── iam_user/
│       ├── main.tf

What It Deploys

S3 Bucket - Creates a bucket named unique-name-set-by-you:

IAM User - Creates an IAM user named test-user.

Requirements

  • Terraform installed (Install guide)
  • AWS account + valid access credentials
  • AWS region: eu-west-2 (London)
  • AWS S3 Bucket Name: Change to a unique name.

How to Use This Setup

1. Clone the Repo

git clone https://github.com/rscrafted/terraform-aws-setup.git
cd terraform-aws-setup/

2. Configure AWS Credentials

  • Login to AWS Portal
  • Go to AWS Management Console
  • Go to Security Credentials
  • Create Access Key

Set the following environment variables in your terminal:

export AWS_ACCESS_KEY_ID="your-access-key-id"
export AWS_SECRET_ACCESS_KEY="your-secret-access-key"
export AWS_DEFAULT_REGION="eu-west-2"

Alternatively, you can configure using the AWS CLI:

aws configure --profile default

Verify details using below command:

cat ~/.aws/credentials
cat ~/.aws/config

3. Terraform Commands

terraform fmt                   # Format code
terraform init                  # Initialize project
terraform plan                  # Preview changes
terraform apply -auto-approve   # Apply infrastructure

Destroy After Testing

terraform destroy

Notes

  • Credentials are not stored in this repo — make sure you set them via environment variables or using AWS CLI.
  • To change the bucket name or user name, update the module files in modules/.

Important

Always run terraform destroy after testing to avoid unexpected AWS charges.

Bonus: AWS Resource Report Script

This project includes a shell script - aws-report.sh to report current AWS resource usage for:

  • S3 buckets
  • EC2 instances
  • Lambda functions
  • IAM users

Assign the execute permission & Run the Script

chmod +x aws-report.sh
./aws-report.sh

Alternatively, if you want to skip assigning executable permission to aws-report.sh, use bash aws-report.sh directly to run the script.

  • Make sure your AWS credentials are configured before running.
  • Tip: Any typo in jq expressions will return null or fail silently — check syntax carefully when modifying the script.

About

AWS Infrasturcure Provisioning using modules structure for effective management. Includes aws report shell script.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published