diff --git a/Makefile b/Makefile index 758dad6..5e974b3 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ # Use this tag to build a customized local image -SWIFT_VERSION=5.1 -LAYER_VERSION=5-1 +SWIFT_VERSION?=5.1 +LAYER_VERSION?=5-1 # SWIFT_VERSION=5.0.3 # LAYER_VERSION=5-0-3 DOCKER_TAG=nio-swift:$(SWIFT_VERSION) @@ -13,10 +13,10 @@ SWIFT_CONFIGURATION=release # Configuration # HelloWorld Example Configuration -SWIFT_EXECUTABLE=HelloWorld -SWIFT_PROJECT_PATH=Examples/HelloWorld -LAMBDA_FUNCTION_NAME=HelloWorld -LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).helloWorld +SWIFT_EXECUTABLE?=HelloWorld +SWIFT_PROJECT_PATH?=Examples/HelloWorld +LAMBDA_FUNCTION_NAME?=HelloWorld +LAMBDA_HANDLER?=$(SWIFT_EXECUTABLE).helloWorld # HTTPSRequest Example Configuration # SWIFT_EXECUTABLE=HTTPSRequest @@ -46,8 +46,8 @@ DOCKER_PROJECT_PATH=aws-lambda-swift-sprinter/$(SWIFT_PROJECT_PATH) # DOCKER_PROJECT_PATH=$(SWIFT_PROJECT_PATH) # AWS Configuration -AWS_PROFILE=default -AWS_BUCKET=my-s3-bucket +AWS_PROFILE?=default +AWS_BUCKET?=my-s3-bucket swift_test: docker run \ diff --git a/README.md b/README.md index 8b03274..b9c7fb5 100644 --- a/README.md +++ b/README.md @@ -140,16 +140,54 @@ make package_lambda ``` The output of this command is a ZIP file called `lambda.zip` under the folder `.build`. -**Note:** +# Lambda Configuration -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. +## Parametrized calls / Automation + +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. + +### Before `make` + +``` +SWIFT_EXECUTABLE=HTTPSRequest \ +SWIFT_PROJECT_PATH=Examples/HTTPSRequest \ +LAMBDA_FUNCTION_NAME=HTTPSRequest \ +LAMBDA_HANDLER=${SWIFT_EXECUTABLE}.getHttps \ + make invoke_lambda +``` + +### After `make` + +``` +make invoke_lambda \ + SWIFT_EXECUTABLE=HTTPSRequest \ + SWIFT_PROJECT_PATH=Examples/HTTPSRequest \ + LAMBDA_FUNCTION_NAME=HTTPSRequest \ + LAMBDA_HANDLER=HTTPSRequest.getHttps +``` + +### Parameters you can pass + +| Key | Usage | Default | +| --- | --- | --- | +| AWS_PROFILE | An AWS AIM profile you create to authenticate to your account. | default | +| SWIFT_VERSION | Version of Swift used / Matches Dockerfile location too from `docker/` folder. | 5.1 | +| LAYER_VERSION | Version of the Swift layer that will be created and uploaded for the Lambda to run on. | 5-1 | +| SWIFT_EXECUTABLE | Name of the binary file. | HelloWorld | +| SWIFT_PROJECT_PATH | Path to your Swift project. | Examples/HelloWorld | +| LAMBDA_FUNCTION_NAME | Display name of your Lambda in AWS. | HelloWorld | +| 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).helloWorld | + +## Manual change + +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. ``` ... -SWIFT_EXECUTABLE=HelloWorld -SWIFT_PROJECT_PATH=Examples/HelloWorld -LAMBDA_FUNCTION_NAME=HelloWorld -LAMBDA_HANDLER=$(SWIFT_EXECUTABLE).helloWorld +SWIFT_EXECUTABLE?=HelloWorld +SWIFT_PROJECT_PATH?=Examples/HelloWorld +LAMBDA_FUNCTION_NAME?=HelloWorld +LAMBDA_HANDLER?=$(SWIFT_EXECUTABLE).helloWorld ... ```