-
-
Save ZeroDeth/26b1d759e7a864f9110f2f9234c8493f to your computer and use it in GitHub Desktop.
A hack to generate a presigned url in terraform
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
variable "bucket_name" { | |
default = "max-bucket-for-testing" | |
} | |
provider "aws" { | |
region = var.aws_region | |
profile = var.aws_profile | |
} | |
resource "aws_s3_bucket" "artifacts" { | |
bucket = var.bucket_name | |
} | |
resource "aws_s3_bucket_object" "file" { | |
bucket = aws_s3_bucket.artifacts.id | |
key = "temp_file.txt" | |
content = "hey, bro" | |
} | |
resource "null_resource" "url" { | |
provisioner "local-exec" { | |
command = "aws s3 presign s3://${aws_s3_bucket.artifacts.id}/${aws_s3_bucket_object.file.key} >> url" | |
} | |
} | |
data "local_file" "url" { | |
depends_on = [ | |
null_resource.url | |
] | |
filename = "${path.module}/url" | |
} | |
output "url" { | |
value = data.local_file.url.content | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment