This Terraform project creates:
- An Amazon S3 bucket
- An IAM user
terraform-aws-setup/
├── aws-report.sh # <--- bonus script!
├── main.tf
├── provider.tf
├── modules/
│ ├── s3_bucket/
│ │ ├── main.tf
│ └── iam_user/
│ ├── main.tf
S3 Bucket - Creates a bucket named unique-name-set-by-you:
IAM User - Creates an IAM user named test-user.
- Terraform installed (Install guide)
- AWS account + valid access credentials
- AWS region:
eu-west-2(London) - AWS S3 Bucket Name: Change to a
uniquename.
git clone https://github.com/rscrafted/terraform-aws-setup.git
cd terraform-aws-setup/- 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 defaultVerify details using below command:
cat ~/.aws/credentials
cat ~/.aws/configterraform fmt # Format code
terraform init # Initialize project
terraform plan # Preview changes
terraform apply -auto-approve # Apply infrastructureterraform destroy- 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.
This project includes a shell script - aws-report.sh to report current AWS resource usage for:
- S3 buckets
- EC2 instances
- Lambda functions
- IAM users
chmod +x aws-report.sh
./aws-report.shAlternatively, 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
jqexpressions will returnnullor fail silently — check syntax carefully when modifying the script.