HomeToolsAbout

Terraform S3

Creating a folder in S3

Tags are not required

resource "aws_s3_bucket" "bucket_name" { bucket = "demo_bucket" tags = { Name = "My bucket" Environment = "Dev" } } resource "aws_s3_object" "folder_name" { bucket = aws_s3_bucket.bucket_name.id key = "demo/directory/" }

Uploading a file to S3

resource "aws_s3_object" "object" { bucket = "your_bucket_name" key = "new_object_key" source = "path/to/file" etag = filemd5("path/to/file") }

The filemd5() function is available in Terraform 0.11.12 and later

For Terraform 0.11.11 and earlier, use the md5() function and the file() function:

etag = "${md5(file("path/to/file"))}"
AboutContact