Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit 458e2c2

Browse files
committed
document CDK deployment
1 parent 16edfe0 commit 458e2c2

File tree

8 files changed

+61
-14
lines changed

8 files changed

+61
-14
lines changed

.github/actions/cdk-deploy/action.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
name: run cdk deploy
22
description: deploy example to AWS using CDK
33
inputs:
4-
AWS_SECRET_ACCESS_KEY:
5-
required: true
64
AWS_ACCESS_KEY_ID:
5+
description: AWS access key id to use
6+
required: true
7+
AWS_SECRET_ACCESS_KEY:
8+
description: AWS secret access key to use
79
required: true
810
AWS_ECR_REPOSITORY_ARN:
11+
description: AWS ECR repository to pull docker image from
912
required: true
1013
IMAGE_TAG_OR_DIGEST:
14+
description: docker image tag or digest to pull
1115
required: true
1216
BACKEND_NAME:
17+
description: STAPI-FastAPI backend implementation to use
1318
required: true
1419

1520
runs:
@@ -22,7 +27,7 @@ runs:
2227
shell: bash
2328
- run: poetry run cdk deploy --require-approval=never
2429
shell: bash
25-
working-directory: deployment
30+
working-directory: deploy_cdk
2631
env:
2732
AWS_SECRET_ACCESS_KEY: ${{ inputs.AWS_SECRET_ACCESS_KEY }}
2833
AWS_ACCESS_KEY_ID: ${{ inputs.AWS_ACCESS_KEY_ID }}

.gitignore

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
__pycache__
2+
.env
3+
.idea
4+
.python-version
5+
.venv
6+
.vscode
17
*.sqlite
28
/.coverage
39
/.pytest_cache
410
/.ruff_cache
5-
6-
# python
7-
.python-version
8-
.venv
9-
__pycache__
10-
.env
11-
12-
.idea

DEPLOYMENT.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Deployment
2+
3+
This repository provides a [AWS Cloud Development Kit][cdk] based deployment.
4+
5+
## Architecture
6+
7+
The deployment consists of an AWS Lambda behind an AWS API Gateway. The Lambda is using a Docker image for the service code, which must be pulled from an AWS ECR.
8+
9+
The CDK deployment code is _not_ managing the ECR, please provide it yourself.
10+
11+
```
12+
API Gateway -> Lambda -> Container Registry
13+
```
14+
15+
## Prerequisites
16+
17+
- AWS CDK CLI
18+
- AWS ECR with Docker image
19+
20+
## Deploying
21+
22+
### Configuration
23+
24+
Configuration is managed via environment variables:
25+
26+
- MEMORY: Lambda memory in megabytes, defaults to `1024`
27+
- TIMEOUT: Lambda timeout in seconds, defaults to `30`
28+
- AWS_ECR_REPOSITORY_ARN: ARN of the ECR to pull from
29+
- IMAGE_TAG_OR_DIGEST: Docker tag or digest to pull from ECR, defaults to `latest`
30+
- BACKEND_NAME: Backend name to use in service, defaults to `landsat`
31+
32+
As well, CDK will need an AWS profile to be configured.
33+
34+
### Execution
35+
36+
Having set up the configuration env vars as required, execute the CDK deployment with
37+
38+
```
39+
poetry run cdk deploy
40+
```
41+
42+
This will create a new CloudFormation stack named after the `BACKEND_NAME` configured, i.e. `StapiLandsatBackend`.
43+
44+
[cdk]: https://docs.aws.amazon.com/cdk/
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from aws_cdk.aws_ecr import Repository
77
from constructs import Construct
88

9-
from deployment.profile import DeploymentProfile
9+
from deploy_cdk.profile import DeploymentProfile
1010

1111

1212
class LambdaService(Construct):
@@ -49,7 +49,7 @@ def __init__(self, scope: Construct, id: str, profile: DeploymentProfile) -> Non
4949
)
5050

5151

52-
class STATDeploy(Stack):
52+
class StapiStack(Stack):
5353
def __init__(
5454
self,
5555
scope: Construct,
@@ -65,7 +65,7 @@ def __init__(
6565
def main():
6666
app = App()
6767
profile = DeploymentProfile()
68-
STATDeploy(app, f"Stat{profile.backend_name.capitalize()}Backend", profile)
68+
StapiStack(app, f"Stapi{profile.backend_name.capitalize()}Backend", profile)
6969
app.synth()
7070

7171

File renamed without changes.

0 commit comments

Comments
 (0)