Skip to content

Commit

Permalink
Merge branch 'debug'
Browse files Browse the repository at this point in the history
  • Loading branch information
shashitnak committed Jun 24, 2024
2 parents 61af3b1 + 51fcd75 commit 4b31638
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 29 deletions.
4 changes: 4 additions & 0 deletions aws/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh -l

cd CONFIG_DIR
./tailcall
30 changes: 28 additions & 2 deletions 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 "TAILCALL_PATH" {
type = string
}

provider "aws" {
region = var.AWS_REGION
access_key = var.AWS_ACCESS_KEY_ID
Expand Down Expand Up @@ -89,8 +93,30 @@ data "http" "bootstrap" {
}

resource "local_sensitive_file" "bootstrap" {
content_base64 = filebase64("bootstrap")
filename = "config/bootstrap"
}

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

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

data "archive_file" "tailcall" {
type = "zip"
depends_on = [
local_sensitive_file.bootstrap,
local_sensitive_file.config,
local_sensitive_file.tailcall
]
source_dir = "config"
output_path = "tailcall.zip"
}

resource "aws_lambda_function" "tailcall" {
Expand All @@ -102,7 +128,7 @@ resource "aws_lambda_function" "tailcall" {
function_name = var.AWS_LAMBDA_FUNCTION_NAME
runtime = "provided.al2"
architectures = ["x86_64"]
handler = "bootstrap"
handler = "start"
filename = data.archive_file.tailcall.output_path
source_code_hash = data.archive_file.tailcall.output_base64sha256
}
Expand Down
21 changes: 0 additions & 21 deletions scripts/create-tf-zip.sh

This file was deleted.

14 changes: 8 additions & 6 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ get_latest_version() {
curl https://api.github.com/repos/$1/$2/releases/latest -s | jq .name -r
}

echo "DIRS: $(ls)"
echo "DIRS: $(ls -R)"
mkdir -p /app
cp -r ./* /app
TC_CONFIG_DIR_ROOT=/app
TC_CONFIG_DIR=$(dirname $TAILCALL_CONFIG)
TC_CONFIG_DIR=$(dirname $TAILCALL_CONFIG | sed 's|^\./||')
echo $TC_CONFIG_DIR
TC_CONFIG_NAME=$(basename $TAILCALL_CONFIG)
EXTENSION=$(echo $TC_CONFIG_NAME | tr '.' '\n' | tail -n 1)

Expand All @@ -38,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_VAR_TAILCALL_PATH="config/$TC_CONFIG_DIR/tailcall"

export TF_TOKEN_app_terraform_io=$TERRAFORM_API_TOKEN

Expand Down Expand Up @@ -79,15 +81,15 @@ deploy() {
# todo: handle name collisions
mkdir -p /aws/config
cp -r /app/* /aws/config
awk -v config_dir="$TC_CONFIG_DIR" "{sub(/CONFIG_DIR/,config_dir)}1" /aws/bootstrap > /tmp/bootstrap
mv /tmp/bootstrap /aws/bootstrap
cd /aws
echo "List: $(find /app -type f)"
/scripts/create-tf-zip.sh
echo "List: $(find /app -type f)"
setup_terraform
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 boot_strap_path="config/$TC_CONFIG_DIR/bootstrap" "{sub(/BOOTSTRAP_PATH/,workspace)}1" /tmp/temp2.tf > /tmp/temp3.tf
mv /tmp/temp3.tf tailcall.tf
mv /tmp/temp2.tf tailcall.tf
echo "list: $(ls -R)"
terraform init
echo "List: $(find /app -type f)"
TF_LOG=DEBUG terraform apply -auto-approve
Expand Down

0 comments on commit 4b31638

Please sign in to comment.