Creating a S3 bucket using Terraform (AWS)
This article has not been completed yet. However, it may already contain helpful information and therefore it has been published at this stage.
https://it-infrastructure.solutions/terraform/
main.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
profile = "default"
region = "eu-central-1"
}
resource "aws_s3_bucket" "itinfrasolbucket" {
bucket = var.bucket_name
acl = var.acl
tags = {
Name = var.bucket_name
}
}
variable.tf
variable "bucket_name" {
type = string
}
variable "acl" {
type = string
}
terraform.tfvars
bucket_name = "itinfrasols3bucket"
acl = "private"
terraform init
terraform plan
terraform apply
Result:
terraform.tfvars
bucket_name = "itinfrasols3bucket"
acl = "public-read"
terraform plan
terraform apply
Clean up:
terraform destroy