-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for directory type artifacts
- Loading branch information
Showing
20 changed files
with
162 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
6 changes: 4 additions & 2 deletions
6
example/aws-lambda-fn/README.md → examples/aws-lambda-fn/README.md
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
|
||
provider "docker" { | ||
host = "unix:///var/run/docker.sock" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
} | ||
docker = { | ||
source = "kreuzwerker/docker" | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Terraform Module Example | ||
|
||
## AWS S3 Bucket | ||
|
||
This example demonstrates how to use the Artifact Builder Terraform module to | ||
build and deploy a simple static website to AWS S3. | ||
|
||
In this example, we have a simple static website composed of HTML files. We use | ||
the Artifact Builder module with `artifact_src_type` set to "directory" to | ||
package the entire website directory as the artifact. This artifact is then | ||
deployed to an AWS S3 bucket, which is configured to host a static website. | ||
|
||
This example is intended to show the flexibility of the Artifact Builder module | ||
in handling different artifact types, including whole directories. It also shows | ||
how to integrate the module with other Terraform resources to create a complete | ||
deployment workflow. | ||
|
||
### Prerequisites | ||
|
||
- Terraform installed on your local machine | ||
- Docker installed on your local machine | ||
- AWS account with the necessary permissions to create Lambda functions and | ||
IAM roles | ||
- AWS CLI installed and configured with your AWS account |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM node:18 as build | ||
|
||
WORKDIR /opt/app | ||
|
||
COPY . . | ||
|
||
# additional build steps here (e.g. npm install) | ||
|
||
# ------------------------------------------------------------------ package --- | ||
|
||
FROM alpine:latest as package | ||
|
||
COPY --from=build /opt/app/assets/ /opt/app/dist/ | ||
|
||
RUN apk add zip \ | ||
&& cd /opt/app/dist |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>My Static Website</title> | ||
</head> | ||
|
||
<body> | ||
<h1>Welcome to my static website!</h1> | ||
<p>This is a simple static website hosted on AWS S3 and deployed using a Terraform module.</p> | ||
</body> | ||
|
||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
locals { | ||
mime_types = { | ||
".html" = "text/html" | ||
".css" = "text/css" | ||
".js" = "application/javascript" | ||
".json" = "application/json" | ||
".png" = "image/png" | ||
".jpg" = "image/jpeg" | ||
".gif" = "image/gif" | ||
".svg" = "image/svg+xml" | ||
} | ||
} | ||
|
||
module "artifact_builder" { | ||
source = "../../" | ||
|
||
docker_build_context = "${path.module}/fixtures/website" | ||
docker_build_target = "package" | ||
artifact_src_type = "directory" | ||
artifact_src_path = "/opt/app/dist/" | ||
artifact_dst_directory = "${path.module}/dist" | ||
} | ||
|
||
resource "random_string" "website_bucket_random_suffix" { | ||
length = 6 | ||
special = false | ||
upper = false | ||
} | ||
|
||
resource "aws_s3_bucket" "website_bucket" { | ||
bucket = "example-tf-docker-artifact-packager-${random_string.website_bucket_random_suffix.result}" | ||
acl = "public-read" | ||
|
||
website { | ||
index_document = "index.html" | ||
} | ||
} | ||
|
||
resource "aws_s3_bucket_object" "website_files" { | ||
for_each = fileset(module.artifact_builder.artifact_dst_directory, "**/*") | ||
|
||
bucket = aws_s3_bucket.website_bucket.bucket | ||
key = each.value | ||
source = "${module.artifact_builder.artifact_dst_directory}/${each.value}" | ||
content_type = lookup(local.mime_types, regex("\\.[^.]+$", each.value), "binary/octet-stream") | ||
acl = "public-read" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# provider "aws" { | ||
# region = "us-east-1" | ||
# } | ||
|
||
provider "docker" { | ||
|
||
host = "unix:///var/run/docker.sock" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
} | ||
docker = { | ||
source = "kreuzwerker/docker" | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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