Skip to content

Instantly share code, notes, and snippets.

@devops-school
Created March 31, 2023 05:11
Show Gist options
  • Save devops-school/8b6edad241343fc735005498549f0a11 to your computer and use it in GitHub Desktop.
Save devops-school/8b6edad241343fc735005498549f0a11 to your computer and use it in GitHub Desktop.
Terraform Tutorials: Named Values – Filesystem and workspace info
provider "aws" {
region = "us-west-2"
}
resource "aws_s3_bucket" "example_bucket" {
bucket = "example-bucket"
acl = "private"
tags = {
Name = "Example Bucket"
Environment = "Production"
}
lifecycle {
prevent_destroy = true
}
versioning {
enabled = true
}
# create a file in the bucket with the contents of the local file
dynamic "object" {
for_each = fileset("${path.module}/files", "*")
content {
bucket = aws_s3_bucket.example_bucket.id
key = object.value
source = "${path.module}/files/${object.value}"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment