@@ -14,16 +14,50 @@ A serverless application that demos several AWS functionalities on LocalStack:
14
14
15
15
Moreover, the repo includes a GitHub actions workflow to demonstrate how to run end-to-end tests of your AWS apps using LocalStack in CI.
16
16
17
+ Here's the app in action:
18
+
17
19
## Overview
18
20
19
21
![ Screenshot at 2022-11-23 16-34-12] ( https://user-images.githubusercontent.com/3996682/203586505-e54ccb3e-5101-4ee8-917d-d6372ee965ef.png )
20
22
21
23
## Prerequisites
22
24
23
- Make sure you use the same version as the Python Lambdas to make Pillow work (3.9)
25
+ ### Dev environment
26
+
27
+ Make sure you use the same version as the Python Lambdas to make Pillow work.
28
+ If you use pyenv, then first install and activate Python 3.9:
29
+ ``` bash
30
+ pyenv install 3.9.16
31
+ pyenv global 3.9.16
32
+ ```
33
+
34
+ ``` console
35
+ % python --version
36
+ Python 3.9.16
37
+ ```
38
+
39
+ Create a virtualenv and install all the development dependencies there:
40
+
41
+ ``` bash
42
+ python -m venv .venv
43
+ source .venv/bin/activate
44
+ pip install -r requirements-dev.txt
45
+ ```
46
+
47
+ ### LocalStack
48
+
49
+ Start LocalStack Pro with the appropriate CORS configuration for the S3 Website:
50
+
51
+ ``` bash
52
+ export EXTRA_CORS_ALLOWED_ORIGINS=webapp.s3-website.localhost.localstack.cloud:4566
53
+ LOCALSTACK_API_KEY=... localstack start
54
+ ```
24
55
25
56
## Create the infrastructure manually
26
57
58
+ You can create the AWS infrastructure on LocalStack by running ` bin/deploy.sh ` .
59
+ Here are instructions to deploy it manually step-by-step.
60
+
27
61
### Create the buckets
28
62
29
63
The names are completely configurable via SSM:
@@ -36,8 +70,8 @@ awslocal s3 mb s3://localstack-thumbnails-app-resized
36
70
### Put the bucket names into the parameter store
37
71
38
72
``` bash
39
- awslocal ssm put-parameter --name /localstack-thumbnail-app/buckets/images --value " localstack-thumbnails-app-images"
40
- awslocal ssm put-parameter --name /localstack-thumbnail-app/buckets/resized --value " localstack-thumbnails-app-resized"
73
+ awslocal ssm put-parameter --name /localstack-thumbnail-app/buckets/images --type " String " -- value " localstack-thumbnails-app-images"
74
+ awslocal ssm put-parameter --name /localstack-thumbnail-app/buckets/resized --type " String " -- value " localstack-thumbnails-app-resized"
41
75
```
42
76
43
77
### Create the DLQ Topic for failed lambda invokes
@@ -81,7 +115,7 @@ awslocal lambda create-function-url-config \
81
115
--auth-type NONE
82
116
```
83
117
84
- Copy the ` FunctionUrl ` from the response!
118
+ Copy the ` FunctionUrl ` from the response, you will need it later to make the app work.
85
119
86
120
### Resizer Lambda
87
121
@@ -121,15 +155,27 @@ awslocal s3 sync --delete ./website s3://webapp
121
155
awslocal s3 website s3://webapp --index-document index.html
122
156
```
123
157
124
- Then visit http://webapp.s3-website.localhost.localstack.cloud:4566
158
+ ## Using the app
125
159
160
+ Once deployed, visit http://webapp.s3-website.localhost.localstack.cloud:4566
126
161
127
- ## Develop locally
162
+ Paste the Function URL of the presign Lambda you created earlier into the form field.
163
+ If you use LocalStack's v2 Lambda provider then you can also get the URL by running:
164
+ ``` bash
165
+ awslocal lambda list-function-url-configs --function-name presign
166
+ ```
128
167
129
- Create a virtualenv and install all the dependencies there:
168
+ After uploading a file, you can download the resized file from the ` localstack-thumbnails-app-resized ` bucket.
169
+
170
+ ## Run integration tests
171
+
172
+ Once all resource are created on LocalStack, you can run the automated integration tests.
130
173
131
174
``` bash
132
- python3 -m venv .venv
133
- source .venv/bin/activate
134
- pip install -r requirements-dev.txt
175
+ pytest tests/
135
176
```
177
+
178
+ ## GitHub Action
179
+
180
+ The demo LocalStack in CI, ` .github/workflows/integration-test.yml ` contains a GitHub Action that starts up LocalStack,
181
+ deploys the infrastructure to it, and then runs the integration tests.
0 commit comments