Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dce6fa2

Browse files
committedJan 2, 2025
add section 4
1 parent 762b2aa commit dce6fa2

25 files changed

+38
-58
lines changed
 
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
# shellcheck disable=all
2-
31
swift package archive --allow-network-connections docker
4-
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
# shellcheck disable=all
2-
31
swift package archive --allow-network-connections docker
42

53
-------------------------------------------------------------------------
6-
building "squarenumberlambda" in docker
4+
building "palindrome" in docker
75
-------------------------------------------------------------------------
86
updating "swift:amazonlinux2" docker image
97
amazonlinux2: Pulling from library/swift
10-
Digest: sha256:5b0cbe56e35210fa90365ba3a4db9cd2b284a5b74d959fc1ee56a13e9c35b378
11-
Status: Image is up to date for swift:amazonlinux2
8+
Digest: sha256:df06a50f70e2e87f237bd904d2fc48195742ebda9f40b4a821c4d39766434009
9+
Status: Image is up to date for swift:amazonlinux2
1210
docker.io/library/swift:amazonlinux2
13-
building "SquareNumberLambda"
11+
building "PalindromeLambda"
12+
[0/1] Planning build
1413
Building for production...
15-
...
14+
[0/2] Write swift-version-24593BA9C3E375BF.txt
15+
Build of product 'PalindromeLambda' complete! (1.91s)
1616
-------------------------------------------------------------------------
17-
archiving "SquareNumberLambda"
17+
archiving "PalindromeLambda"
1818
-------------------------------------------------------------------------
1919
1 archive created
20-
* SquareNumberLambda at /Users/YourUserName/SquareNumberLambda/.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/SquareNumberLambda/SquareNumberLambda.zip
21-
20+
* PalindromeLambda at /Users/sst/Palindrome/.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/PalindromeLambda/PalindromeLambda.zip
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
# shellcheck disable=all
2-
31
swift package archive --allow-network-connections docker
42

53
-------------------------------------------------------------------------
6-
building "squarenumberlambda" in docker
4+
building "palindrome" in docker
75
-------------------------------------------------------------------------
86
updating "swift:amazonlinux2" docker image
97
amazonlinux2: Pulling from library/swift
10-
Digest: sha256:5b0cbe56e35210fa90365ba3a4db9cd2b284a5b74d959fc1ee56a13e9c35b378
11-
Status: Image is up to date for swift:amazonlinux2
8+
Digest: sha256:df06a50f70e2e87f237bd904d2fc48195742ebda9f40b4a821c4d39766434009
9+
Status: Image is up to date for swift:amazonlinux2
1210
docker.io/library/swift:amazonlinux2
13-
building "SquareNumberLambda"
11+
building "PalindromeLambda"
12+
[0/1] Planning build
1413
Building for production...
15-
...
14+
[0/2] Write swift-version-24593BA9C3E375BF.txt
15+
Build of product 'PalindromeLambda' complete! (1.91s)
1616
-------------------------------------------------------------------------
17-
archiving "SquareNumberLambda"
17+
archiving "PalindromeLambda"
1818
-------------------------------------------------------------------------
1919
1 archive created
20-
* SquareNumberLambda at /Users/YourUserName/SquareNumberLambda/.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/SquareNumberLambda/SquareNumberLambda.zip
21-
20+
* PalindromeLambda at /Users/sst/Palindrome/.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/PalindromeLambda/PalindromeLambda.zip
2221

23-
cp .build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/SquareNumberLambda/SquareNumberLambda.zip ~/Desktop
22+
cp .build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/PalindromeLambda/PalindromeLambda.zip ~/Desktop
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
# shellcheck disable=all
2-
31
aws --version
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
# shellcheck disable=all
2-
3-
#
41
# --region the AWS Region to send the command
52
# --function-name the name of your function
63
# --cli-binary-format tells the cli to use raw data as input (default is base64)
74
# --payload the payload to pass to your function code
85
# result.json the name of the file to store the response from the function
9-
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# shellcheck disable=all
2-
3-
#
41
# --region the AWS Region to send the command
52
# --function-name the name of your function
63
# --cli-binary-format tells the cli to use raw data as input (default is base64)
@@ -9,8 +6,8 @@
96

107
aws lambda invoke \
118
--region us-west-2 \
12-
--function-name SquaredNumberLambda \
9+
--function-name PalindromeLambda \
1310
--cli-binary-format raw-in-base64-out \
14-
--payload '{"number":3}' \
11+
--payload '{"text": "Was it a car or a cat I saw?"}' \
1512
result.json
1613

‎Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-03-lambda-invoke.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# shellcheck disable=all
2-
3-
#
41
# --region the AWS Region to send the command
52
# --function-name the name of your function
63
# --cli-binary-format tells the cli to use raw data as input (default is base64)
@@ -9,9 +6,9 @@
96

107
aws lambda invoke \
118
--region us-west-2 \
12-
--function-name SquaredNumberLambda \
9+
--function-name PalindromeLambda \
1310
--cli-binary-format raw-in-base64-out \
14-
--payload '{"number":3}' \
11+
--payload '{"text": "Was it a car or a cat I saw?"}' \
1512
result.json
1613

1714
{

‎Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-04-lambda-invoke.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# shellcheck disable=all
2-
3-
#
41
# --region the AWS Region to send the command
52
# --function-name the name of your function
63
# --cli-binary-format tells the cli to use raw data as input (default is base64)
@@ -9,9 +6,9 @@
96

107
aws lambda invoke \
118
--region us-west-2 \
12-
--function-name SquaredNumberLambda \
9+
--function-name PalindromeLambda \
1310
--cli-binary-format raw-in-base64-out \
14-
--payload '{"number":3}' \
11+
--payload '{"text": "Was it a car or a cat I saw?"}' \
1512
result.json
1613

1714
{
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# shellcheck disable=all
2-
3-
#
41
# --region the AWS Region to send the command
52
# --function-name the name of your function
63
# --cli-binary-format tells the cli to use raw data as input (default is base64)
@@ -9,9 +6,9 @@
96

107
aws lambda invoke \
118
--region us-west-2 \
12-
--function-name SquaredNumberLambda \
9+
--function-name PalindromeLambda \
1310
--cli-binary-format raw-in-base64-out \
14-
--payload '{"number":3}' \
11+
--payload '{"text": "Was it a car or a cat I saw?"}' \
1512
result.json
1613

1714
{
@@ -20,5 +17,5 @@ aws lambda invoke \
2017
}
2118

2219
cat result.json
23-
{"result":9}
20+
{"text":"Was it a car or a cat I saw?","isPalindrome":true,"message":"Your text is a palindrome"}
2421

‎Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/04-deploy-function.tutorial

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@
6565
}
6666

6767
@Step {
68-
On the top right side of the console, select the AWS Region where you want to deploy your Lambda function. You typically choose a Region close to your customers to minimize the network latency. For this demo, I selected **Oregon (us-west-2)**
68+
On the top right side of the console, select the AWS Region where you want to deploy your Lambda function.
69+
70+
You typically choose a Region close to your customers to minimize the network latency. For this demo, I selected **Oregon (us-west-2)**
6971

7072
> AWS has multiple Regions across all continents. You can learn more about [AWS Global Infrastructure](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/) here.
7173

@@ -79,17 +81,16 @@
7981
}
8082

8183
@Step {
82-
On the top right side of the console, select **Create function**.
84+
On the top right side of the Lambda page, select **Create function**.
8385

8486
@Image(source: 04-02-05-create-function.png, alt: "Create function")
8587
}
8688

8789
@Step {
88-
Enter a **Function name**. I choose `SquaredNumberLambda`. Select `Provide your own bootstrap on Amazon Linux 2` as **Runtime**. And select `arm64` as **Architecture** when you build on a Mac with Apple Silicon. Leave all other parameter as default, and select **Create function** on the bottom right part.
90+
Enter a **Function name**. I choose `PalindromeLambda`. Select `Provide your own bootstrap on Amazon Linux 2` as **Runtime**. And select `arm64` as **Architecture** when you build on a Mac with Apple Silicon. Leave all other parameter as default, and select **Create function** on the bottom right part.
8991

9092
> The runtime architecture for Lambda (`arm64` or `x86_64`) must match the one of the machine where you compiled the code. When you compiled on an Intel-based Mac, use `x86_64`. When compiling on an Apple Silicon-based Mac select `arm64`.
9193

92-
9394
@Image(source: 04-02-06-create-function.png, alt: "Create function details")
9495
}
9596

@@ -106,13 +107,13 @@
106107
}
107108

108109
@Step {
109-
To verify everything works well, create a test event and invoke the function from the **Test** tab in the console. Enter `MyTestEvent` as **Event name**. Enter `{"number":3}` as **Event JSON**. Then, select **Test**.
110+
To verify everything works well, create a test event and invoke the function from the **Test** tab in the console. Enter `MyTestEvent` as **Event name**. Enter `{"text": "Was it a car or a cat I saw?"}` as **Event JSON**. Then, select **Test**.
110111

111112
@Image(source: 04-02-09-test-lambda.png, alt: "Create function")
112113
}
113114

114115
@Step {
115-
When the invocation succeeds, you can see the execution details and the result: `{ "result" : 9 }`.
116+
When the invocation succeeds, you can see the execution details and the result: `{ "message": "Your text is a palindrome","isPalindrome": true, "text": "Was it a car or a cat I saw?"}`.
116117

117118
> The execution result also shares the execution duration, the actual memory consumed and the logs generated by the function. These are important data to help you to fine-tune your function. Providing the function with more memory will also give it more compute power, resulting in lower execution time.
118119

@@ -164,7 +165,9 @@
164165

165166
}
166167
@Step {
167-
When everything goes well, you will see `{ "result" : 9}`. Congratulation 🎉 !
168+
When everything goes well, you will see `{"text":"Was it a car or a cat I saw?","isPalindrome":true,"message":"Your text is a palindrome"}`.
169+
170+
Congratulation 🎉 !
168171

169172
@Code(name: "Command to type in the Terminal", file: 04-03-05-lambda-invoke.sh)
170173

0 commit comments

Comments
 (0)
Please sign in to comment.