Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 0a8edbf

Browse files
Merge pull request #7 from CodingNagger/outside-params-makefile
Resolve #10 Allow external variables override
2 parents fdac57d + b3bb204 commit 0a8edbf

File tree

2 files changed

+52
-14
lines changed

2 files changed

+52
-14
lines changed

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
# Use this tag to build a customized local image
33

4-
SWIFT_VERSION=5.1
5-
LAYER_VERSION=5-1
4+
SWIFT_VERSION?=5.1
5+
LAYER_VERSION?=5-1
66
# SWIFT_VERSION=5.0.3
77
# LAYER_VERSION=5-0-3
88
DOCKER_TAG=nio-swift:$(SWIFT_VERSION)
@@ -13,10 +13,10 @@ SWIFT_CONFIGURATION=release
1313
# Configuration
1414

1515
# HelloWorld Example Configuration
16-
SWIFT_EXECUTABLE=HelloWorld
17-
SWIFT_PROJECT_PATH=Examples/HelloWorld
18-
LAMBDA_FUNCTION_NAME=HelloWorld
19-
LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).helloWorld
16+
SWIFT_EXECUTABLE?=HelloWorld
17+
SWIFT_PROJECT_PATH?=Examples/HelloWorld
18+
LAMBDA_FUNCTION_NAME?=HelloWorld
19+
LAMBDA_HANDLER?=$(SWIFT_EXECUTABLE).helloWorld
2020

2121
# HTTPSRequest Example Configuration
2222
# SWIFT_EXECUTABLE=HTTPSRequest
@@ -46,8 +46,8 @@ DOCKER_PROJECT_PATH=aws-lambda-swift-sprinter/$(SWIFT_PROJECT_PATH)
4646
# DOCKER_PROJECT_PATH=$(SWIFT_PROJECT_PATH)
4747

4848
# AWS Configuration
49-
AWS_PROFILE=default
50-
AWS_BUCKET=my-s3-bucket
49+
AWS_PROFILE?=default
50+
AWS_BUCKET?=my-s3-bucket
5151

5252
swift_test:
5353
docker run \

README.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,54 @@ make package_lambda
140140
```
141141
The output of this command is a ZIP file called `lambda.zip` under the folder `.build`.
142142

143-
**Note:**
143+
# Lambda Configuration
144144

145-
Edit the `Makefile` to build a different Example by commenting the following lines and uncommenting the line relateted to the example you want to build.
145+
## Parametrized calls / Automation
146+
147+
Can pass values to your `make` command either before or after the call like below. This will fit better in a script per example to setup continuous integration in your project.
148+
149+
### Before `make`
150+
151+
```
152+
SWIFT_EXECUTABLE=HTTPSRequest \
153+
SWIFT_PROJECT_PATH=Examples/HTTPSRequest \
154+
LAMBDA_FUNCTION_NAME=HTTPSRequest \
155+
LAMBDA_HANDLER=${SWIFT_EXECUTABLE}.getHttps \
156+
make invoke_lambda
157+
```
158+
159+
### After `make`
160+
161+
```
162+
make invoke_lambda \
163+
SWIFT_EXECUTABLE=HTTPSRequest \
164+
SWIFT_PROJECT_PATH=Examples/HTTPSRequest \
165+
LAMBDA_FUNCTION_NAME=HTTPSRequest \
166+
LAMBDA_HANDLER=HTTPSRequest.getHttps
167+
```
168+
169+
### Parameters you can pass
170+
171+
| Key | Usage | Default |
172+
| --- | --- | --- |
173+
| AWS_PROFILE | An AWS AIM profile you create to authenticate to your account. | default |
174+
| SWIFT_VERSION | Version of Swift used / Matches Dockerfile location too from `docker/` folder. | 5.1 |
175+
| LAYER_VERSION | Version of the Swift layer that will be created and uploaded for the Lambda to run on. | 5-1 |
176+
| SWIFT_EXECUTABLE | Name of the binary file. | HelloWorld |
177+
| SWIFT_PROJECT_PATH | Path to your Swift project. | Examples/HelloWorld |
178+
| LAMBDA_FUNCTION_NAME | Display name of your Lambda in AWS. | HelloWorld |
179+
| LAMBDA_HANDLER | Name of your lambda handler function. If you declare it using `sprinter.register(handler: "FUNCTION_NAME", lambda: syncLambda)` you should declare it as `<SWIFT_EXECUTABLE>.<FUNCTION_NAME>`. | $(SWIFT_EXECUTABLE).helloWorld |
180+
181+
## Manual change
182+
183+
You can also edit the `Makefile` to build a different Example by commenting the following lines and uncommenting the line relateted to the example you want to build.
146184
```
147185
...
148186
149-
SWIFT_EXECUTABLE=HelloWorld
150-
SWIFT_PROJECT_PATH=Examples/HelloWorld
151-
LAMBDA_FUNCTION_NAME=HelloWorld
152-
LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).helloWorld
187+
SWIFT_EXECUTABLE?=HelloWorld
188+
SWIFT_PROJECT_PATH?=Examples/HelloWorld
189+
LAMBDA_FUNCTION_NAME?=HelloWorld
190+
LAMBDA_HANDLER?=$(SWIFT_EXECUTABLE).helloWorld
153191
154192
...
155193
```

0 commit comments

Comments
 (0)