Last active
September 20, 2022 22:41
-
-
Save Pelirrojo/9503a60044d6c7e0671fd89930672a91 to your computer and use it in GitHub Desktop.
Iac Terraform Template for creating an AWS S3 Bucket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# terraform.tf | |
terraform { | |
required_version = ">= 1.2.5" | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = ">= 4.22.0" | |
} | |
} | |
} | |
# locals.tf | |
locals { | |
region = "eu-west-1" | |
} | |
data "aws_region" "current" {} | |
data "aws_caller_identity" "current" {} | |
# main.tf | |
provider "aws" { | |
region = "eu-west-1" | |
} | |
resource "aws_s3_bucket" "sample_bucket" { | |
bucket = "custom-tf-bucket-name-${data.aws_caller_identity.current.account_id}" | |
} | |
resource "aws_s3_bucket_public_access_block" "state_bucket_public_block" { | |
bucket = aws_s3_bucket.sample_bucket.id | |
block_public_acls = true | |
block_public_policy = true | |
ignore_public_acls = true | |
restrict_public_buckets = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment