-
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.
🛠️ Replace layer and zips with docker images.
- Loading branch information
Showing
10 changed files
with
146 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,9 +84,6 @@ kill: | |
|
||
# Deploy | ||
|
||
build-layer: | ||
./scripts/build_layer.sh | ||
|
||
update: | ||
cd tf; make update; | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,16 @@ | ||
ARG SRC_IMAGE | ||
ARG SRC_TAG | ||
|
||
FROM ${SRC_IMAGE}:${SRC_TAG} | ||
|
||
WORKDIR /tmp/build | ||
# Copy dependencies | ||
COPY requirements.lock . | ||
# Install dependencies | ||
RUN pip install --no-deps --target ${LAMBDA_TASK_ROOT} -r requirements.lock | ||
|
||
WORKDIR ${LAMBDA_TASK_ROOT} | ||
# Copy source code | ||
COPY src/ . | ||
# Point to lambda handler | ||
CMD [ "lambda_handler.handle"] |
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,81 @@ | ||
# Vars and data | ||
|
||
locals { | ||
lock_file = "${local.project_root}/poetry.lock" | ||
app_dockerfile = "${local.tf_root}/app.Dockerfile" | ||
} | ||
|
||
# ECR Repo | ||
|
||
resource "aws_ecr_repository" "ecr_repo" { | ||
name = "${local.service_name}-ecr" | ||
} | ||
|
||
resource "aws_ecr_lifecycle_policy" "ecr_lifecycle_policy" { | ||
repository = aws_ecr_repository.ecr_repo.name | ||
policy = <<EOF | ||
{ | ||
"rules": [ | ||
{ | ||
"rulePriority": 1, | ||
"description": "Keep last 3 images", | ||
"selection": { | ||
"tagStatus": "any", | ||
"countType": "imageCountMoreThan", | ||
"countNumber": 3 | ||
}, | ||
"action": { | ||
"type": "expire" | ||
} | ||
} | ||
] | ||
} | ||
EOF | ||
} | ||
|
||
# Prepare | ||
|
||
resource "null_resource" "lock_export" { | ||
triggers = { | ||
lock_file = filebase64sha256(local.lock_file) | ||
} | ||
|
||
provisioner "local-exec" { | ||
command = <<EOF | ||
cd ${local.project_root}; make lock-export || exit 1 | ||
EOF | ||
} | ||
} | ||
|
||
module "app_archive" { | ||
source = "github.com/asaf-kali/resources//tf/filtered_archive" | ||
name = "service" | ||
source_dir = local.lambda_src_root | ||
exclude_patterns = [ | ||
".coverage", | ||
"**/__pycache__/**", | ||
"**/.pytest_cache/**", | ||
] | ||
} | ||
|
||
# Image | ||
|
||
module "app_image" { | ||
name = "app" | ||
source = "github.com/asaf-kali/resources//tf/ecr_builder" | ||
aws_account_id = local.aws_account_id | ||
aws_region = var.aws_region | ||
build_dir = local.project_root | ||
docker_file = local.app_dockerfile | ||
ecr_name = aws_ecr_repository.ecr_repo.name | ||
ecr_url = aws_ecr_repository.ecr_repo.repository_url | ||
src_image = "public.ecr.aws/lambda/python" | ||
src_tag = local.python_version | ||
triggers = { | ||
docker_file = filebase64sha256(local.app_dockerfile) | ||
source_dir = module.app_archive.output_sha | ||
} | ||
depends_on = [ | ||
null_resource.lock_export | ||
] | ||
} |
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