Skip to content

Commit

Permalink
setting bootstrap with var, using fileset in terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
shashitnak committed Jun 19, 2024
1 parent a13bba1 commit 7e4930e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 11 additions & 1 deletion aws/tailcall.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ variable "TERRAFORM_WORKSPACE" {
type = string
}

variable "BOOTSTRAP_PATH" {
type = string
}

provider "aws" {
region = var.AWS_REGION
access_key = var.AWS_ACCESS_KEY_ID
Expand Down Expand Up @@ -90,7 +94,13 @@ data "http" "bootstrap" {

resource "local_sensitive_file" "bootstrap" {
content_base64 = data.http.bootstrap.response_body_base64
filename = "BOOTSTRAP_PATH"
filename = var.BOOTSTRAP_PATH
}

resource "local_sensitive_file" "archive_file" {
for_each = fileset(path.module, "config/**")
content_base64 = filebase64("${each.key}")
filename = "${each.key}"
}

resource "aws_lambda_function" "tailcall" {
Expand Down
8 changes: 3 additions & 5 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export TF_VAR_AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
export TF_VAR_AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
export TF_VAR_TERRAFORM_ORG=$TERRAFORM_ORG
export TF_VAR_TERRAFORM_WORKSPACE=$TERRAFORM_WORKSPACE
export TF_BOOTSTRAP_PATH="config/$TC_CONFIG_DIR/bootstrap"

export TF_TOKEN_app_terraform_io=$TERRAFORM_API_TOKEN

Expand Down Expand Up @@ -82,15 +83,12 @@ deploy() {
cp -r /app/* /aws/config
cd /aws
echo "List: $(find /app -type f)"
/scripts/create-tf-zip.sh
# /scripts/create-tf-zip.sh
echo "List: $(find /app -type f)"
setup_terraform
BOOTSTRAP_PATH="config/$TC_CONFIG_DIR/bootstrap"
echo "BOOTSTRAP_PATH: $BOOTSTRAP_PATH"
awk -v org="\"$TERRAFORM_ORG\"" "{sub(/var.TERRAFORM_ORG/,org)}1" /aws/tailcall.tf > /tmp/temp1.tf
awk -v workspace="\"$TERRAFORM_WORKSPACE\"" "{sub(/var.TERRAFORM_WORKSPACE/,workspace)}1" /tmp/temp1.tf > /tmp/temp2.tf
awk -v bootstrap_path="$BOOTSTRAP_PATH" "{sub(/BOOTSTRAP_PATH/,bootstrap_path)}1" /tmp/temp2.tf > /tmp/temp3.tf
mv /tmp/temp3.tf tailcall.tf
mv /tmp/temp2.tf tailcall.tf
echo "config: $(cat tailcall.tf)"
terraform init
echo "List: $(find /app -type f)"
Expand Down

0 comments on commit 7e4930e

Please sign in to comment.