Skip to content

Commit 04719fb

Browse files
committed
chore: move botfpdf to lambda-src/api-render-pdf/
tested: - `make test` - `make test-json` - `make script-gmv` Removed old terraform stuff, and the www/ directory.
1 parent 048756a commit 04719fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+133
-2055
lines changed

.bumpversion.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ current_version = 0.3.5
55

66
[bumpversion:file:README.md]
77

8-
[bumpversion:file:pyproject.toml]
8+
[bumpversion:file:lambda-src/api-render-pdf/pyproject.toml]
99
search = version = "{current_version}"
1010
replace = version = "{new_version}"

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,5 @@ terraform/poetry-version.json
308308
templates/generated.css
309309
.envrc
310310
test-results.xml
311+
generated.css
312+
builds/

Makefile

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.ONESHELL: # Applies to every targets in the file!
2+
13
INPUT_FILE=
24

35
.PHONY: all
@@ -13,7 +15,9 @@ variations: install-dev
1315
clean:
1416
@find . -type f \( -iname "*.pdf" -o -iname "*.html" \) -exec rm -vf {} \;
1517

18+
APP_DIR=lambda-src/api-render-pdf
1619
POETRY=poetry
20+
POETRY_QUIET=--verbose
1721
POETRY_OK:=$(shell command -v $(POETRY) 2> /dev/null)
1822
PYSRC=botcpdf
1923
MAKE_PDF=bin/make-pdf --format sample
@@ -25,7 +29,7 @@ endif
2529

2630
install-dev: poetry
2731
@$(POETRY) config virtualenvs.in-project true
28-
@$(POETRY) install --quiet
32+
@$(POETRY) --directory=$(APP_DIR) $(POETRY_QUIET) install
2933

3034
fmt: install-dev
3135
@$(POETRY) run black -t py311 $(PYSRC)
@@ -34,10 +38,16 @@ lint: install-dev
3438
@$(POETRY) run pylint $(PYSRC)
3539

3640
test: install-dev
37-
@$(POETRY) run poetry run pytest -v --junit-xml=test-results.xml botcpdf/tests/
41+
# for some reason -C doesn't work here
42+
cd $(APP_DIR) && \
43+
pwd && \
44+
$(POETRY) run pytest -v --junit-xml=test-results.xml botcpdf/tests/
3845

3946
test-json: install-dev
40-
@$(POETRY) run poetry run pytest -v botcpdf/tests/test_external_json.py
47+
# for some reason -C doesn't work here
48+
cd $(APP_DIR) && \
49+
pwd && \
50+
$(POETRY) run pytest -v botcpdf/tests/test_external_json.py
4151

4252
# some quick helpers to (quickly) generate some pdfs
4353
script-tb: TARGET:="Trouble Brewing"
@@ -47,7 +57,7 @@ script-cs: TARGET:="Clean Sweep"
4757
script-jinx: TARGET="Let's Test Some Jinxes"
4858

4959
script-tb script-nrb script-gmv script-cs script-jinx: poetry
50-
$(MAKE_PDF) scripts/$(TARGET).json
60+
$(MAKE_PDF) ../../scripts/$(TARGET).json
5161
ifeq ($(shell uname),Darwin)
5262
@open -a Preview "pdfs/just-baked.pdf"
5363
endif
@@ -101,7 +111,7 @@ release: fmt lint changelog
101111
@git push --tags
102112

103113
fetch-combined-json:
104-
@curl --silent --create-dirs -o data/imported/roles-combined.json https://raw.githubusercontent.com/chizmw/json-on-the-clocktower/main/data/generated/roles-combined.json
114+
@curl --silent --create-dirs -o lambda-src/api-render-pdf/data/imported/roles-combined.json https://raw.githubusercontent.com/chizmw/json-on-the-clocktower/main/data/generated/roles-combined.json
105115

106116
grab-some-scripts:
107117
# make certain we have a scripts directory

bin/make-pdf

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/usr/bin/env bash
2+
cd "$(dirname "$0")/../lambda-src/api-render-pdf" || exit 1
23
poetry run python -m botcpdf.cli make-pdf "$@"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lambda-src/api-render-pdf/data/imported/.gitkeep

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

serverless.yml

-49
This file was deleted.

terraform/_data.tf

+34-31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
data "aws_caller_identity" "current" {}
2+
data "aws_region" "current" {}
3+
14

25
# the dummy file we used when working through the CORS api
36
# https://mrponath.medium.com/terraform-and-aws-api-gateway-a137ee48a8ac
@@ -9,34 +12,34 @@ data "archive_file" "lambda" {
912

1013
# this allows us to rely on existing information to specify the lambda function name
1114
# supporting serverless config options and terraform workspaces
12-
data "aws_lambda_function" "api_render_pdf" {
13-
provider = aws.default
14-
function_name = "${var.sls_service_name}-${terraform.workspace}-${var.sls_function_name}"
15-
}
16-
17-
data "aws_lambda_function" "lambda_invalidate_cache" {
18-
provider = aws.default
19-
function_name = "invalidate-cache"
20-
}
21-
22-
data "aws_iam_role" "iam_for_lambda" {
23-
provider = aws.default
24-
name = "deploy_json2pdf"
25-
}
26-
27-
28-
data "aws_lambda_function" "invalidate_cache" {
29-
provider = aws.default
30-
function_name = "invalidate-cache"
31-
}
32-
33-
data "aws_api_gateway_rest_api" "json2pdf_api" {
34-
provider = aws.default
35-
name = local.pdf_api_name
36-
}
37-
38-
data "aws_api_gateway_resource" "json2pdf_resource" {
39-
provider = aws.default
40-
rest_api_id = data.aws_api_gateway_rest_api.json2pdf_api.id
41-
path = "/${local.pdf_render_path}"
42-
}
15+
#data "aws_lambda_function" "api_render_pdf" {
16+
#provider = aws.default
17+
#function_name = "${var.sls_service_name}-${terraform.workspace}-${var.sls_function_name}"
18+
#}
19+
20+
#data "aws_lambda_function" "lambda_invalidate_cache" {
21+
#provider = aws.default
22+
#function_name = "invalidate-cache"
23+
#}
24+
25+
#data "aws_iam_role" "iam_for_lambda" {
26+
#provider = aws.default
27+
#name = "deploy_json2pdf"
28+
#}
29+
30+
31+
#data "aws_lambda_function" "invalidate_cache" {
32+
#provider = aws.default
33+
#function_name = "invalidate-cache"
34+
#}
35+
36+
#data "aws_api_gateway_rest_api" "json2pdf_api" {
37+
#provider = aws.default
38+
#name = local.pdf_api_name
39+
#}
40+
41+
#data "aws_api_gateway_resource" "json2pdf_resource" {
42+
#provider = aws.default
43+
#rest_api_id = data.aws_api_gateway_rest_api.json2pdf_api.id
44+
#path = "/${local.pdf_render_path}"
45+
#}

terraform/_locals.tf

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
locals {
2+
project_name = "arcane-scripts-api"
3+
4+
aws_default_region = "eu-west-2"
5+
6+
# we want a lookup of region to secrets lambda ARN
7+
# https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_lambda.html#retrieving-secrets_lambda_ARNs
8+
secrets_layer_arns = {
9+
"eu-west-1" = "arn:aws:lambda:eu-west-1:015030872274:layer:AWS-Parameters-and-Secrets-Lambda-Extension:10"
10+
"eu-west-2" = "arn:aws:lambda:eu-west-2:133256977650:layer:AWS-Parameters-and-Secrets-Lambda-Extension:10"
11+
}
12+
13+
# secret_layer_arn is the lookup for the current region, or a default message of "ARN Missing For Region"
14+
secrets_layer_arn = lookup(local.secrets_layer_arns, data.aws_region.current.name, "ARN Missing For Region")
15+
}
16+
17+
18+
19+
20+
## ORIGINAL LOCALS - CLEANUP REQUIRED
121
locals {
222

323
tag_defaults = {
@@ -10,8 +30,9 @@ locals {
1030

1131
# wkspc_site_name is based on the workspace name; if it's 'prod' we use 'make', if it's 'dev' we use 'preview'
1232
wkspc_site_name = {
13-
prod = "make"
14-
dev = "beta"
33+
prod = "make"
34+
dev = "beta"
35+
default = "alpha"
1536
}
1637

1738
# get the lookup value from the wkspc_site_name map based on the workspace name

terraform/_outputs.tf

-13
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,3 @@ output "commit_version" {
1010
output "project_dir" {
1111
value = data.external.useful_version_info.result.project_dir
1212
}
13-
14-
output "stage_function_name" {
15-
value = "${var.sls_service_name}-${terraform.workspace}-${var.sls_function_name}"
16-
}
17-
18-
output "stage_url" {
19-
value = aws_api_gateway_deployment.deployment.invoke_url
20-
}
21-
22-
23-
output "www-a" {
24-
value = aws_route53_record.wkspc_www-a.fqdn
25-
}

terraform/api-pdf.tf

-118
This file was deleted.

terraform/get-useful-information.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -e
33

44
commit_version="$(git describe --tags --always)"
55
project_dir="$(basename "$(git rev-parse --show-toplevel)")"
6-
poetry_version="$(poetry version --short)"
6+
poetry_version="$(cd "../lambda-src/api-render-pdf/" && poetry version --short)"
77

88
jq -n \
99
--arg commit_version "$commit_version" \

0 commit comments

Comments
 (0)