Skip to content

Commit

Permalink
dev: fix all issues with s3-website example
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtoj committed Jul 17, 2023
1 parent 8507146 commit 3661487
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion examples/s3-website/fixtures/website/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ FROM alpine:latest as package
COPY --from=build /opt/app/assets/ /opt/app/dist/

RUN apk add zip \
&& cd /opt/app/dist
&& cd /opt/app/dist \
&& zip -r /tmp/package.zip .

17 changes: 12 additions & 5 deletions examples/s3-website/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ module "artifact_packager" {

docker_build_context = "${path.module}/fixtures/website"
docker_build_target = "package"
artifact_src_type = "directory"
artifact_src_path = "/opt/app/dist/"
artifact_src_path = "/tmp/package.zip"
artifact_dst_directory = "${path.module}/dist"
}

Expand All @@ -16,8 +15,8 @@ resource "random_string" "website_bucket_random_suffix" {
}

resource "aws_s3_bucket" "website_bucket" {
bucket = "example-tf-aws-zip-uploader-${random_string.website_bucket_random_suffix.result}"
acl = "public-read"
bucket = "example-tf-aws-zip-uploader-${random_string.website_bucket_random_suffix.result}"
force_destroy = true

website {
index_document = "index.html"
Expand All @@ -27,6 +26,14 @@ resource "aws_s3_bucket" "website_bucket" {
module "s3_zip_uploader" {
source = "../../"

artifact_src_local_path = module.artifact_packager.artifact_dst_path
artifact_src_local_path = module.artifact_packager.artifact_package_path
artifact_dst_bucket_arn = aws_s3_bucket.website_bucket.arn

depends_on = [
module.artifact_packager
]
}

data "aws_s3_objects" "website_assets" {
bucket = aws_s3_bucket.website_bucket.id
}
3 changes: 3 additions & 0 deletions examples/s3-website/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "bucket_objects" {
value = data.aws_s3_objects.website_assets.keys
}

0 comments on commit 3661487

Please sign in to comment.