Skip to content

Commit 5f1fb8a

Browse files
Refactor Examples folder and scripts
- Move scripts to Examples - Add a common config.sh script - Move SAM templates to Examples/scripts/SAM - Move Serverless templates to Examples/scripts/serverless - Update the scripts to work with new folder structure and config.sh - Move Dockerfile to Examples
1 parent 6345332 commit 5f1fb8a

21 files changed

+73
-73
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
.swift-version
88
xcuserdata
99
Package.resolved
10+
.serverless
File renamed without changes.

Examples/LambdaFunctions/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

Examples/LambdaFunctions/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ This sample project is a collection of Lambda functions that demonstrates
44
how to write a simple Lambda function in Swift, and how to package and deploy it
55
to the AWS Lambda platform.
66

7+
The scripts are prepared to work from the `Examples` folder.
8+
9+
```
10+
git clone https://github.com/swift-server/swift-aws-lambda-runtime.git
11+
cd swift-aws-lambda-runtime/Examples
12+
```
13+
714
Note: The example scripts assume you have [jq](https://stedolan.github.io/jq/download/) command line tool installed.
815

916
## Deployment instructions using AWS CLI

Examples/LambdaFunctions/APIGateway-template.yml renamed to Examples/scripts/SAM/APIGateway-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Resources:
99
Properties:
1010
Handler: Provided
1111
Runtime: provided
12-
CodeUri: .build/lambda/APIGateway/lambda.zip
12+
CodeUri: LambdaFunctions/.build/lambda/APIGateway/lambda.zip
1313
# Add an API Gateway event source for the Lambda
1414
Events:
1515
HttpGet:

Examples/LambdaFunctions/Benchmark-template.yml renamed to Examples/scripts/SAM/Benchmark-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ Resources:
99
Properties:
1010
Handler: Provided
1111
Runtime: provided
12-
CodeUri: .build/lambda/Benchmark/lambda.zip
12+
CodeUri: LambdaFunctions/.build/lambda/Benchmark/lambda.zip
1313
# Instructs new versions to be published to an alias named "live".
1414
AutoPublishAlias: live

Examples/LambdaFunctions/CurrencyExchange-template.yml renamed to Examples/scripts/SAM/CurrencyExchange-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Resources:
99
Properties:
1010
Handler: Provided
1111
Runtime: provided
12-
CodeUri: .build/lambda/CurrencyExchange/lambda.zip
12+
CodeUri: LambdaFunctions/.build/lambda/CurrencyExchange/lambda.zip
1313
Timeout: 300
1414
# Instructs new versions to be published to an alias named "live".
1515
AutoPublishAlias: live

Examples/LambdaFunctions/ErrorHandling-template.yml renamed to Examples/scripts/SAM/ErrorHandling-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ Resources:
99
Properties:
1010
Handler: Provided
1111
Runtime: provided
12-
CodeUri: .build/lambda/ErrorHandling/lambda.zip
12+
CodeUri: LambdaFunctions/.build/lambda/ErrorHandling/lambda.zip
1313
# Instructs new versions to be published to an alias named "live".
1414
AutoPublishAlias: live

Examples/LambdaFunctions/HelloWorld-template.yml renamed to Examples/scripts/SAM/HelloWorld-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ Resources:
99
Properties:
1010
Handler: Provided
1111
Runtime: provided
12-
CodeUri: .build/lambda/HelloWorld/lambda.zip
12+
CodeUri: LambdaFunctions/.build/lambda/HelloWorld/lambda.zip
1313
# Instructs new versions to be published to an alias named "live".
1414
AutoPublishAlias: live

Examples/LambdaFunctions/scripts/build-and-package.sh renamed to Examples/scripts/build-and-package.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
set -eu
1717

1818
executable=$1
19+
workspace="$(pwd)/.."
20+
sources=$2
1921

2022
echo "-------------------------------------------------------------------------"
2123
echo "building \"$executable\" lambda"
2224
echo "-------------------------------------------------------------------------"
23-
docker run --rm -v "$(pwd)/../..":/workspace -w /workspace/Examples/LambdaFunctions builder bash -cl "swift build --product $executable -c release -Xswiftc -g"
25+
docker run --rm -v "$workspace":/workspace -w /workspace/Examples/$sources builder bash -cl "swift build --product $executable -c release -Xswiftc -g"
2426
echo "done"
2527

2628
echo "-------------------------------------------------------------------------"
2729
echo "packaging \"$executable\" lambda"
2830
echo "-------------------------------------------------------------------------"
29-
docker run --rm -v "$(pwd)/../..":/workspace -w /workspace/Examples/LambdaFunctions builder bash -cl "./scripts/package.sh $executable"
31+
docker run --rm -v "$workspace":/workspace -w /workspace/Examples builder bash -cl "./scripts/package.sh $executable $sources"

0 commit comments

Comments
 (0)