provider "aws" {
region = "us-east-1" # Replace with your desired AWS region
}
resource "aws_s3_bucket" "terraform_state_bucket" {
bucket = "my-terraform-state-bucket" # Replace with your bucket name
acl = "private"
}
resource "aws_s3_bucket_versioning" "terraform_state_versioning" {
bucket = aws_s3_bucket.terraform_state_bucket.id
enabled = true
}
resource "aws_iam_user" "terraform_user" {
name = "terraform-user"
// Save Secret in Github and use it in here
}
resource "aws_iam_user_policy_attachment" "terraform_user_policy" {
user = aws_iam_user.terraform_user.name
policy_arn = "arn:aws:iam::aws:policy/AmazonS3FullAccess" # Example policy
}
resource "aws_s3_bucket" "terraform_locks_bucket" {
bucket = "my-terraform-locks-bucket" # Replace with your bucket name
acl = "private"
}
resource "aws_dynamodb_table" "terraform_locks_table" {
name = "terraform-locks"
billing_mode = "PAY_PER_REQUEST"
hash_key = "LockID"
attribute {
name = "LockID"
type = "S"
}
}
terraform init
terraform apply
Would you like a cup of coffee?