Skip to content

Commit

Permalink
Merge pull request #2491 from ymwjbxxq/ymwjbxxq-feature-move_all_rust…
Browse files Browse the repository at this point in the history
…_example_to_aws_cargolambda

Rust: upgrade to aws cargo lambda
  • Loading branch information
bfreiberg authored Nov 20, 2024
2 parents 89e78ef + b487ae6 commit 05045de
Show file tree
Hide file tree
Showing 79 changed files with 241 additions and 770 deletions.
4 changes: 2 additions & 2 deletions alb-lambda-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ name = "handler"
path = "src/bin/handler.rs"

[dependencies]
lambda_http = "0.11"
lambda_runtime = "0.11"
lambda_http = "0.13"
lambda_runtime = "0.13"
serde = {version = "1.0", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["macros"] }
Expand Down
29 changes: 0 additions & 29 deletions alb-lambda-rust/Makefile

This file was deleted.

10 changes: 5 additions & 5 deletions alb-lambda-rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Important: this application uses various AWS services and there are costs associ
* [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
* [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed
* [Rust](https://www.rust-lang.org/) 1.56.0 or higher
* [cargo-zigbuild](https://github.com/messense/cargo-zigbuild) and [Zig](https://ziglang.org/) for cross-compilation
* [CargoLambda](https://www.cargo-lambda.info/guide/installation.html)

## Deployment Instructions

Expand All @@ -27,11 +27,11 @@ Important: this application uses various AWS services and there are costs associ
```
3. Install dependencies and build:
```
make build
sam build
```
4. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:
```
make deploy
sam deploy
```
5. During the prompts:
* Enter a stack name
Expand Down Expand Up @@ -70,7 +70,7 @@ Response:
1. Delete the stack
```bash
make delete
sam delete
```
2. Confirm the stack has been deleted
```bash
Expand All @@ -80,4 +80,4 @@ Response:
----
Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
SPDX-License-Identifier: MIT-0
6 changes: 4 additions & 2 deletions alb-lambda-rust/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ Resources:
MyLambdaFunction:
Type: 'AWS::Serverless::Function'
Properties:
CodeUri: ./build/handler
CodeUri: .
Policies:
- AWSLambdaBasicExecutionRole
Tags:
name: !Ref AWS::StackName
Metadata:
BuildMethod: rust-cargolambda

MyLambdaFunctionPermission:
Type: AWS::Lambda::Permission
Expand Down Expand Up @@ -110,4 +112,4 @@ Resources:

Outputs:
DNSName:
Value: !GetAtt MyLoadBalancer.DNSName
Value: !GetAtt MyLoadBalancer.DNSName
4 changes: 2 additions & 2 deletions apigw-http-api-lambda-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ name = "handler"
path = "src/bin/handler.rs"

[dependencies]
lambda_http = "0.11"
lambda_runtime = "0.11"
lambda_http = "0.13"
lambda_runtime = "0.13"
serde_json = "1"
tokio = { version = "1", features = ["macros"] }
tracing-subscriber = { version = "0.3", features = ["fmt", "json"] }
29 changes: 0 additions & 29 deletions apigw-http-api-lambda-rust/Makefile

This file was deleted.

8 changes: 4 additions & 4 deletions apigw-http-api-lambda-rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Important: this application uses various AWS services and there are costs associ
* [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
* [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed
* [Rust](https://www.rust-lang.org/) 1.56.0 or higher
* [cargo-zigbuild](https://github.com/messense/cargo-zigbuild) and [Zig](https://ziglang.org/) for cross-compilation
* [CargoLambda](https://www.cargo-lambda.info/guide/installation.html)

## Deployment Instructions

Expand All @@ -27,11 +27,11 @@ Important: this application uses various AWS services and there are costs associ
```
3. Install dependencies and build:
```
make build
sam build
```
4. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:
```
make deploy
sam deploy
```
5. During the prompts:
* Enter a stack name
Expand Down Expand Up @@ -98,4 +98,4 @@ This pattern was contributed by Greg Davis.
----
Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
SPDX-License-Identifier: MIT-0
7 changes: 5 additions & 2 deletions apigw-http-api-lambda-rust/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ Resources:
LambdaFunction:
Type: 'AWS::Serverless::Function'
Properties:
CodeUri: ./build/handler
CodeUri: .
Metadata:
BuildMethod: rust-cargolambda

# Function permissions grant an AWS service or another account permission to use a function
FunctionResourcePermission:
Type: 'AWS::Lambda::Permission'
Expand All @@ -59,4 +62,4 @@ Resources:
Outputs:
HttpApiEndpoint:
Description: The default endpoint for the HTTP API.
Value: !GetAtt HttpApi.ApiEndpoint
Value: !GetAtt HttpApi.ApiEndpoint
4 changes: 2 additions & 2 deletions apigw-lambda-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ name = "handler"
path = "src/bin/handler.rs"

[dependencies]
lambda_http = "0.11"
lambda_runtime = "0.11"
lambda_http = "0.13.0"
lambda_runtime = "0.13.0"
serde = {version = "1.0", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["macros"] }
Expand Down
29 changes: 0 additions & 29 deletions apigw-lambda-rust/Makefile

This file was deleted.

10 changes: 5 additions & 5 deletions apigw-lambda-rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Important: this application uses various AWS services and there are costs associ
* [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
* [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed
* [Rust](https://www.rust-lang.org/) 1.56.0 or higher
* [cargo-zigbuild](https://github.com/messense/cargo-zigbuild) and [Zig](https://ziglang.org/) for cross-compilation
* [CargoLambda](https://www.cargo-lambda.info/guide/installation.html)

## Deployment Instructions

Expand All @@ -27,11 +27,11 @@ Important: this application uses various AWS services and there are costs associ
```
3. Install dependencies and build:
```
make build
sam build
```
4. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:
```
make deploy
sam deploy
```
5. During the prompts:
* Enter a stack name
Expand Down Expand Up @@ -70,7 +70,7 @@ Response:
1. Delete the stack
```bash
make delete
sam delete
```
2. Confirm the stack has been deleted
```bash
Expand All @@ -80,4 +80,4 @@ Response:
----
Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
SPDX-License-Identifier: MIT-0
8 changes: 5 additions & 3 deletions apigw-lambda-rust/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Globals:
MemorySize: 128
Architectures: ["arm64"]
Handler: bootstrap
Runtime: provided.al2
Runtime: provided.al2023
Timeout: 29
Environment:
Variables:
Expand Down Expand Up @@ -46,7 +46,7 @@ Resources:
LambdaFunction:
Type: 'AWS::Serverless::Function'
Properties:
CodeUri: ./build/handler
CodeUri: .
Policies:
- AWSLambdaBasicExecutionRole
Events:
Expand All @@ -56,8 +56,10 @@ Resources:
Path: /do
Method: POST
RestApiId: !Ref MyApi
Metadata:
BuildMethod: rust-cargolambda

Outputs:
HttpApiEndpoint:
Description: The default endpoint for the REST API.
Value: !Sub "https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/${StageName}/"
Value: !Sub "https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/${StageName}/"
4 changes: 2 additions & 2 deletions appconfig-lambda-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ path = "src/bin/handler.rs"

[dependencies]
aws-config = {version = "1", features = ["behavior-version-latest"] }
lambda_runtime = "0.11"
lazy_static = "1.4"
lambda_runtime = "0.13"
lazy_static = "1"
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json"] }
serde = {version = "1.0", features = ["derive"] }
serde_json = "1"
Expand Down
29 changes: 0 additions & 29 deletions appconfig-lambda-rust/Makefile

This file was deleted.

6 changes: 3 additions & 3 deletions appconfig-lambda-rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Important: this application uses various AWS services and there are costs associ
* [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
* [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed
* [Rust](https://www.rust-lang.org/) 1.56.0 or higher
* [cargo-zigbuild](https://github.com/messense/cargo-zigbuild) and [Zig](https://ziglang.org/) for cross-compilation
* [CargoLambda](https://www.cargo-lambda.info/guide/installation.html)
* [AWS AppConfig integration with Lambda extensions](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-integration-lambda-extensions.html)

## Deployment Instructions
Expand All @@ -28,11 +28,11 @@ Important: this application uses various AWS services and there are costs associ
```
3. Install dependencies and build:
```
make build
sam build
```
4. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:
```
make deploy
sam deploy
```
5. During the prompts:
* Enter a stack name
Expand Down
6 changes: 4 additions & 2 deletions appconfig-lambda-rust/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Resources:
PutObjectFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./build/handler
CodeUri: .
Policies:
- AWSLambdaBasicExecutionRole
- Version: '2012-10-17'
Expand All @@ -94,4 +94,6 @@ Resources:
AWS_APPCONFIG_PROFILE: MyTestProfile
AWS_APPCONFIG_EXTENSION_HTTP_PORT: 2772
Layers:
- arn:aws:lambda:eu-central-1:066940009817:layer:AWS-AppConfig-Extension-Arm64:2
- arn:aws:lambda:eu-central-1:066940009817:layer:AWS-AppConfig-Extension-Arm64:101
Metadata:
BuildMethod: rust-cargolambda
2 changes: 1 addition & 1 deletion cloudfront-apigw-http-api-lambda-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "handler"
path = "src/bin/handler.rs"

[dependencies]
lambda_http = "0.11"
lambda_http = "0.13"
serde_json = "1"
tokio = { version = "1", features = ["macros"] }
tracing-subscriber = { version = "0.3", features = ["fmt", "json"] }
Loading

0 comments on commit 05045de

Please sign in to comment.