Storing and accessing files easily and in a scalable way is an essential part of a modern infrastructure. Amazon S3 is Amazon's answer to this need. S3 stores "objects" in "buckets" and has no storage limit (one exception is the bucket name: it has to be unique on Amazon's S3, the namespace being shared). We'll see how to make the best use of S3 with Terraform.
To step through this recipe, you will need the following:
A working Terraform installation
An AWS provider configured in Terraform (refer to the previous recipes)
An Internet connection
We'll start by creating a simple and explicitly public bucket on S3 named iac-book
, using the aws_s3_bucket
resource (and a tag for the sake of it):
resource "aws_s3_bucket" "iac_book" { bucket = "iac-book" acl = "public-read" tags { Name = "IAC Book Bucket in ${var.aws_region}" } }
After a terraform apply
, your bucket is immediately available for storing objects. You can see it...