├── .github ├── PULL_REQUEST_TEMPLATE.md ├── actions │ └── rust-build │ │ └── action.yml ├── dependabot.yml └── workflows │ ├── build-events.yml │ ├── build-extension.yml │ ├── build-integration-test.yml │ ├── build-runtime.yml │ ├── check-docs.yml │ ├── check-examples.yml │ ├── closed-issue-message.yml │ ├── format.yml │ └── run-integration-test.yml ├── .gitignore ├── .rustfmt.toml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.toml ├── LICENSE ├── Makefile ├── NOTICE ├── README.md ├── examples ├── advanced-appconfig-feature-flags │ ├── .gitignore │ ├── Cargo.toml │ ├── README.md │ ├── cdk │ │ ├── .npmignore │ │ ├── README.md │ │ ├── bin │ │ │ └── cdk.ts │ │ ├── cdk.json │ │ ├── jest.config.js │ │ ├── lib │ │ │ └── cdk-stack.ts │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── test │ │ │ └── cdk.test.ts │ │ └── tsconfig.json │ └── src │ │ ├── appconfig.rs │ │ └── main.rs ├── advanced-sqs-multiple-functions-shared-data │ ├── Cargo.toml │ ├── README.md │ ├── consumer │ │ ├── Cargo.toml │ │ └── src │ │ │ └── main.rs │ ├── pizza_lib │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ └── producer │ │ ├── Cargo.toml │ │ └── src │ │ └── main.rs ├── advanced-sqs-partial-batch-failures │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── basic-cognito-post-confirmation │ ├── .gitignore │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── basic-error-error-crates-integration │ ├── .gitignore │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── basic-error-handling │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── basic-error-thiserror │ ├── .gitignore │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── basic-lambda-external-runtime │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── basic-lambda │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── basic-s3-object-lambda-thumbnail │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── main.rs │ │ └── s3.rs │ └── testdata │ │ ├── image.png │ │ └── thumbnail.png ├── basic-s3-thumbnail │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── main.rs │ │ └── s3.rs ├── basic-sdk │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── basic-shared-resource │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── basic-sqs │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── basic-streaming-response │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── check-examples.sh ├── extension-basic │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── extension-combined │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── extension-custom-events │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── extension-custom-service │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── extension-internal-flush │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── extension-logs-basic │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── extension-logs-custom-service │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── extension-logs-kinesis-firehose │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── extension-telemetry-basic │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── http-axum-apigw-authorizer │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── http-axum-diesel-ssl │ ├── .DS_Store │ ├── Cargo.toml │ ├── README.md │ ├── migrations │ │ └── 2023-04-07-231632_create_posts │ │ │ ├── down.sql │ │ │ └── up.sql │ └── src │ │ └── main.rs ├── http-axum-diesel │ ├── Cargo.toml │ ├── README.md │ ├── migrations │ │ └── 2023-04-07-231632_create_posts │ │ │ ├── down.sql │ │ │ └── up.sql │ └── src │ │ └── main.rs ├── http-axum-middleware │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── http-axum │ ├── Cargo.toml │ ├── README.md │ ├── cdk │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── README.md │ │ ├── bin │ │ │ └── cdk.ts │ │ ├── cdk.json │ │ ├── lib │ │ │ └── cdk-stack.ts │ │ ├── package-lock.json │ │ ├── package.json │ │ └── tsconfig.json │ └── src │ │ └── main.rs ├── http-basic-lambda │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── http-cors │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── http-dynamodb │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── http-query-parameters │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── http-raw-path │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── http-shared-resource │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── http-tower-trace │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── lambda-rds-iam-auth │ ├── .gitignore │ ├── Cargo.toml │ ├── cdk │ │ ├── .gitignore │ │ ├── README.md │ │ ├── app.ts │ │ ├── cdk.json │ │ ├── package.json │ │ └── tsconfig.json │ └── src │ │ ├── global-bundle.pem │ │ └── main.rs └── opentelemetry-tracing │ ├── Cargo.toml │ └── src │ └── main.rs ├── lambda-events ├── Cargo.toml ├── LICENSE ├── README.md └── src │ ├── custom_serde │ ├── codebuild_time.rs │ ├── float_unix_epoch.rs │ ├── headers.rs │ ├── http_method.rs │ └── mod.rs │ ├── encodings │ ├── http.rs │ ├── mod.rs │ └── time.rs │ ├── event │ ├── activemq │ │ └── mod.rs │ ├── alb │ │ └── mod.rs │ ├── apigw │ │ └── mod.rs │ ├── appsync │ │ └── mod.rs │ ├── autoscaling │ │ └── mod.rs │ ├── bedrock_agent_runtime │ │ └── mod.rs │ ├── chime_bot │ │ └── mod.rs │ ├── clientvpn │ │ └── mod.rs │ ├── cloudformation │ │ ├── mod.rs │ │ └── provider.rs │ ├── cloudwatch_alarms │ │ └── mod.rs │ ├── cloudwatch_events │ │ ├── cloudtrail.rs │ │ ├── codedeploy.rs │ │ ├── codepipeline.rs │ │ ├── ec2.rs │ │ ├── emr.rs │ │ ├── gamelift.rs │ │ ├── glue.rs │ │ ├── health.rs │ │ ├── kms.rs │ │ ├── macie.rs │ │ ├── mod.rs │ │ ├── opsworks.rs │ │ ├── signin.rs │ │ ├── sms.rs │ │ ├── ssm.rs │ │ ├── tag.rs │ │ └── trustedadvisor.rs │ ├── cloudwatch_logs │ │ └── mod.rs │ ├── code_commit │ │ └── mod.rs │ ├── codebuild │ │ └── mod.rs │ ├── codedeploy │ │ └── mod.rs │ ├── codepipeline_cloudwatch │ │ └── mod.rs │ ├── codepipeline_job │ │ └── mod.rs │ ├── cognito │ │ └── mod.rs │ ├── config │ │ └── mod.rs │ ├── connect │ │ └── mod.rs │ ├── documentdb │ │ ├── events │ │ │ ├── commom_types.rs │ │ │ ├── delete_event.rs │ │ │ ├── drop_database_event.rs │ │ │ ├── drop_event.rs │ │ │ ├── insert_event.rs │ │ │ ├── invalidate_event.rs │ │ │ ├── mod.rs │ │ │ ├── rename_event.rs │ │ │ ├── replace_event.rs │ │ │ └── update_event.rs │ │ └── mod.rs │ ├── dynamodb │ │ ├── attributes.rs │ │ └── mod.rs │ ├── ecr_scan │ │ └── mod.rs │ ├── eventbridge │ │ └── mod.rs │ ├── firehose │ │ └── mod.rs │ ├── iam │ │ └── mod.rs │ ├── iot │ │ └── mod.rs │ ├── iot_1_click │ │ └── mod.rs │ ├── iot_button │ │ └── mod.rs │ ├── iot_deprecated │ │ └── mod.rs │ ├── kafka │ │ └── mod.rs │ ├── kinesis │ │ ├── analytics.rs │ │ ├── event.rs │ │ └── mod.rs │ ├── lambda_function_urls │ │ └── mod.rs │ ├── lex │ │ └── mod.rs │ ├── mod.rs │ ├── rabbitmq │ │ └── mod.rs │ ├── s3 │ │ ├── batch_job.rs │ │ ├── event.rs │ │ ├── mod.rs │ │ └── object_lambda.rs │ ├── secretsmanager │ │ └── mod.rs │ ├── ses │ │ └── mod.rs │ ├── sns │ │ └── mod.rs │ ├── sqs │ │ └── mod.rs │ └── streams │ │ └── mod.rs │ ├── fixtures │ ├── example-activemq-event.json │ ├── example-alb-lambda-target-request-headers-only.json │ ├── example-alb-lambda-target-request-multivalue-headers.json │ ├── example-alb-lambda-target-response.json │ ├── example-apigw-console-request.json │ ├── example-apigw-console-test-request.json │ ├── example-apigw-custom-auth-request-type-request.json │ ├── example-apigw-custom-auth-request.json │ ├── example-apigw-custom-auth-response-with-condition.json │ ├── example-apigw-custom-auth-response-with-single-value-action.json │ ├── example-apigw-custom-auth-response-with-single-value-resource.json │ ├── example-apigw-custom-auth-response.json │ ├── example-apigw-request-multi-value-parameters.json │ ├── example-apigw-request.json │ ├── example-apigw-response.json │ ├── example-apigw-restapi-openapi-request.json │ ├── example-apigw-sam-http-request.json │ ├── example-apigw-sam-rest-request.json │ ├── example-apigw-v2-custom-authorizer-v1-request.json │ ├── example-apigw-v2-custom-authorizer-v2-request-without-cookies.json │ ├── example-apigw-v2-custom-authorizer-v2-request-without-identity-source.json │ ├── example-apigw-v2-custom-authorizer-v2-request.json │ ├── example-apigw-v2-custom-authorizer-websocket-request.json │ ├── example-apigw-v2-request-iam.json │ ├── example-apigw-v2-request-jwt-authorizer.json │ ├── example-apigw-v2-request-lambda-authorizer.json │ ├── example-apigw-v2-request-multi-value-parameters.json │ ├── example-apigw-v2-request-no-authorizer.json │ ├── example-apigw-websocket-request-disconnect-route.json │ ├── example-apigw-websocket-request-without-method.json │ ├── example-apigw-websocket-request.json │ ├── example-appsync-batchinvoke.json │ ├── example-appsync-identity-cognito.json │ ├── example-appsync-identity-iam.json │ ├── example-appsync-invoke.json │ ├── example-appsync-lambda-auth-request.json │ ├── example-appsync-lambda-auth-response.json │ ├── example-autoscaling-event-launch-successful.json │ ├── example-autoscaling-event-launch-unsuccessful.json │ ├── example-autoscaling-event-lifecycle-action.json │ ├── example-autoscaling-event-terminate-action.json │ ├── example-autoscaling-event-terminate-successful.json │ ├── example-autoscaling-event-terminate-unsuccessful.json │ ├── example-bedrock-agent-runtime-event-without-parameters.json │ ├── example-bedrock-agent-runtime-event-without-request-body.json │ ├── example-bedrock-agent-runtime-event.json │ ├── example-clientvpn-connectionhandler-request.json │ ├── example-cloudformation-custom-resource-create-request.json │ ├── example-cloudformation-custom-resource-delete-request.json │ ├── example-cloudformation-custom-resource-provider-create-request.json │ ├── example-cloudformation-custom-resource-provider-delete-request.json │ ├── example-cloudformation-custom-resource-provider-response.json │ ├── example-cloudformation-custom-resource-provider-update-request.json │ ├── example-cloudformation-custom-resource-response.json │ ├── example-cloudformation-custom-resource-update-request.json │ ├── example-cloudwatch-alarm-composite-with-suppressor-alarm.json │ ├── example-cloudwatch-alarm-composite.json │ ├── example-cloudwatch-alarm-metric.json │ ├── example-cloudwatch-alarm-sns-payload-multiple-metrics.json │ ├── example-cloudwatch-alarm-sns-payload-single-metric.json │ ├── example-cloudwatch-cloudtrail-assumed-role.json │ ├── example-cloudwatch-cloudtrail-unknown-federate.json │ ├── example-cloudwatch-cloudtrail-unknown-user-auth.json │ ├── example-cloudwatch_logs-event.json │ ├── example-code_commit-event.json │ ├── example-codebuild-phase-change.json │ ├── example-codebuild-state-change.json │ ├── example-codedeploy-deployment-event.json │ ├── example-codedeploy-instance-event.json │ ├── example-codedeploy-lifecycle-event.json │ ├── example-codepipeline-action-execution-stage-change-event.json │ ├── example-codepipeline-execution-stage-change-event.json │ ├── example-codepipeline-execution-state-change-event.json │ ├── example-codepipeline_job-event.json │ ├── example-cognito-event-userpools-create-auth-challenge-user-not-found.json │ ├── example-cognito-event-userpools-create-auth-challenge.json │ ├── example-cognito-event-userpools-custommessage.json │ ├── example-cognito-event-userpools-define-auth-challenge-optional-response-fields.json │ ├── example-cognito-event-userpools-define-auth-challenge-user-not-found.json │ ├── example-cognito-event-userpools-define-auth-challenge.json │ ├── example-cognito-event-userpools-migrateuser.json │ ├── example-cognito-event-userpools-postauthentication.json │ ├── example-cognito-event-userpools-postconfirmation.json │ ├── example-cognito-event-userpools-preauthentication.json │ ├── example-cognito-event-userpools-presignup.json │ ├── example-cognito-event-userpools-pretokengen-incoming.json │ ├── example-cognito-event-userpools-pretokengen-v2-incoming.json │ ├── example-cognito-event-userpools-pretokengen-v2.json │ ├── example-cognito-event-userpools-pretokengen.json │ ├── example-cognito-event-userpools-verify-auth-challenge-null-answer-correct.json │ ├── example-cognito-event-userpools-verify-auth-challenge-optional-answer-correct.json │ ├── example-cognito-event-userpools-verify-auth-challenge-user-not-found.json │ ├── example-cognito-event-userpools-verify-auth-challenge.json │ ├── example-cognito-event.json │ ├── example-config-event.json │ ├── example-connect-event-without-queue.json │ ├── example-connect-event.json │ ├── example-documentdb-delete-event.json │ ├── example-documentdb-drop-database-event.json │ ├── example-documentdb-drop-event.json │ ├── example-documentdb-insert-event.json │ ├── example-documentdb-invalidate-event.json │ ├── example-documentdb-rename-event.json │ ├── example-documentdb-replace-event.json │ ├── example-documentdb-update-event.json │ ├── example-dynamodb-event-record-with-optional-fields.json │ ├── example-dynamodb-event.json │ ├── example-ecr-image-scan-event-with-missing-severities.json │ ├── example-ecr-image-scan-event.json │ ├── example-eventbridge-event-obj.json │ ├── example-eventbridge-schedule.json │ ├── example-firehose-event.json │ ├── example-iot-custom-auth-request.json │ ├── example-iot-custom-auth-response.json │ ├── example-iot_1_click-event.json │ ├── example-iot_button-event.json │ ├── example-kafka-event.json │ ├── example-kinesis-event-encrypted.json │ ├── example-kinesis-event.json │ ├── example-kinesis-firehose-event.json │ ├── example-kinesis-firehose-response.json │ ├── example-lex-event.json │ ├── example-lex-response.json │ ├── example-rabbitmq-event.json │ ├── example-s3-event-with-decoded.json │ ├── example-s3-event.json │ ├── example-s3-object-lambda-event-get-object-assumed-role.json │ ├── example-s3-object-lambda-event-get-object-iam.json │ ├── example-s3-object-lambda-event-head-object-iam.json │ ├── example-s3-object-lambda-event-list-objects-iam.json │ ├── example-s3-object-lambda-event-list-objects-v2-iam.json │ ├── example-secretsmanager-secret-rotation-event.json │ ├── example-ses-event.json │ ├── example-ses-lambda-event.json │ ├── example-ses-s3-event.json │ ├── example-ses-sns-event.json │ ├── example-sns-event-obj.json │ ├── example-sns-event-pascal-case.json │ ├── example-sns-event.json │ ├── example-sqs-api-event-obj.json │ ├── example-sqs-batch-response.json │ ├── example-sqs-event-obj.json │ └── example-sqs-event.json │ ├── lib.rs │ └── time_window.rs ├── lambda-extension ├── Cargo.toml ├── README.md └── src │ ├── error.rs │ ├── events.rs │ ├── extension.rs │ ├── lib.rs │ ├── logs.rs │ ├── requests.rs │ └── telemetry.rs ├── lambda-http ├── Cargo.toml ├── README.md ├── src │ ├── deserializer.rs │ ├── ext │ │ ├── extensions.rs │ │ ├── mod.rs │ │ └── request.rs │ ├── lib.rs │ ├── request.rs │ ├── response.rs │ └── streaming.rs └── tests │ └── data │ ├── alb_health_check.json │ ├── alb_multi_value_request.json │ ├── alb_multi_value_request_encoded_query_parameters.json │ ├── alb_no_host.json │ ├── alb_request.json │ ├── alb_request_encoded_query_parameters.json │ ├── apigw_multi_value_proxy_request.json │ ├── apigw_no_host.json │ ├── apigw_proxy_request.json │ ├── apigw_request_path_with_space.json │ ├── apigw_v2_proxy_request.json │ ├── apigw_v2_proxy_request_minimal.json │ ├── apigw_v2_proxy_request_with_stage_in_path.json │ ├── apigw_v2_sam_local.json │ ├── lambda_function_url_request.json │ └── svg_logo.svg ├── lambda-integration-tests ├── Cargo.toml ├── samconfig.toml ├── src │ ├── authorizer.rs │ └── helloworld.rs ├── template.yaml └── tests │ └── integration_test.rs ├── lambda-runtime-api-client ├── Cargo.toml ├── README.md └── src │ ├── body │ ├── channel.rs │ ├── mod.rs │ ├── sender.rs │ └── watch.rs │ ├── error.rs │ ├── lib.rs │ └── tracing.rs └── lambda-runtime ├── Cargo.toml └── src ├── deserializer.rs ├── diagnostic.rs ├── layers ├── api_client.rs ├── api_response.rs ├── mod.rs ├── otel.rs ├── panic.rs └── trace.rs ├── lib.rs ├── requests.rs ├── runtime.rs ├── streaming.rs └── types.rs /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 📬 *Issue #, if available:* 2 | 3 | ✍️ *Description of changes:* 4 | 5 | 🔏 *By submitting this pull request* 6 | 7 | - [ ] I confirm that I've ran `cargo +nightly fmt`. 8 | - [ ] I confirm that I've ran `cargo clippy --fix`. 9 | - [ ] I confirm that I've made a best effort attempt to update all relevant documentation. 10 | - [ ] I confirm that my contribution is made under the terms of the Apache 2.0 license. 11 | -------------------------------------------------------------------------------- /.github/actions/rust-build/action.yml: -------------------------------------------------------------------------------- 1 | name: "Rust builds" 2 | description: "Builds, tests, and formats Rust code" 3 | inputs: 4 | package: 5 | required: true 6 | description: "the Rust package to test" 7 | toolchain: 8 | required: true 9 | description: "the Rust toolchain to use" 10 | run-tests: 11 | required: true 12 | default: true 13 | description: "whether to run tests in addition to building" 14 | 15 | runs: 16 | using: "composite" 17 | steps: 18 | - uses: dtolnay/rust-toolchain@master 19 | with: 20 | toolchain: ${{ inputs.toolchain }} 21 | components: clippy, rustfmt 22 | - uses: Swatinem/rust-cache@v2 23 | 24 | - name: Build 25 | shell: bash 26 | run: cargo build --all-features --verbose --package ${{ inputs.package }} 27 | 28 | - name: Run tests 29 | if: ${{ inputs.run-tests == 'true' }} 30 | shell: bash 31 | run: cargo test --all-features --verbose --package ${{ inputs.package }} 32 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "cargo" 4 | directory: "." 5 | schedule: 6 | interval: "weekly" 7 | - package-ecosystem: "cargo" 8 | directory: "lambda-events" 9 | schedule: 10 | interval: "weekly" 11 | - package-ecosystem: "cargo" 12 | directory: "lambda-extension" 13 | schedule: 14 | interval: "weekly" 15 | - package-ecosystem: "cargo" 16 | directory: "lambda-http" 17 | schedule: 18 | interval: "weekly" 19 | - package-ecosystem: "cargo" 20 | directory: "lambda-integration-tests" 21 | schedule: 22 | interval: "weekly" 23 | - package-ecosystem: "cargo" 24 | directory: "lambda-runtime-api-client" 25 | schedule: 26 | interval: "weekly" 27 | - package-ecosystem: "cargo" 28 | directory: "lambda-runtime" 29 | schedule: 30 | interval: "weekly" -------------------------------------------------------------------------------- /.github/workflows/build-integration-test.yml: -------------------------------------------------------------------------------- 1 | name: Build integration tests 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'lambda-runtime-api-client/**' 7 | - 'lambda-runtime/**' 8 | - 'lambda-http/**' 9 | - 'lambda-extension/**' 10 | - 'Cargo.toml' 11 | 12 | pull_request: 13 | paths: 14 | - 'lambda-runtime-api-client/**' 15 | - 'lambda-runtime/**' 16 | - 'lambda-http/**' 17 | - 'lambda-extension/**' 18 | - 'Cargo.toml' 19 | 20 | jobs: 21 | build-runtime: 22 | runs-on: ubuntu-latest 23 | strategy: 24 | matrix: 25 | toolchain: 26 | - "1.81.0" # Current MSRV 27 | - stable 28 | env: 29 | RUST_BACKTRACE: 1 30 | steps: 31 | - uses: actions/checkout@v3 32 | 33 | - name: Build Integration tests 34 | uses: ./.github/actions/rust-build 35 | with: 36 | package: lambda-integration-tests 37 | toolchain: ${{ matrix.toolchain}} 38 | # the tests will generally fail in ci since they make a network call to a real endpoint, 39 | # this step is just designed to make sure they build successfully 40 | run-tests: false 41 | -------------------------------------------------------------------------------- /.github/workflows/check-docs.yml: -------------------------------------------------------------------------------- 1 | name: Check rustdocs 2 | # this is its own workflow since we to to use unstable 3 | # to have the docs.rs display of feature flags 4 | 5 | on: 6 | push: 7 | paths: 8 | - 'lambda-runtime/**' 9 | - 'lambda-runtime-api-client/**' 10 | - 'lambda-http/**' 11 | - 'lambda-events/**' 12 | - 'lambda-extension/**' 13 | - 'Cargo.toml' 14 | 15 | pull_request: 16 | paths: 17 | - 'lambda-runtime/**' 18 | - 'lambda-runtime-api-client/**' 19 | - 'lambda-http/**' 20 | - 'lambda-events/**' 21 | - 'lambda-extension/**' 22 | - 'Cargo.toml' 23 | 24 | jobs: 25 | build-runtime: 26 | runs-on: ubuntu-latest 27 | 28 | env: 29 | RUST_BACKTRACE: 1 30 | steps: 31 | - uses: actions/checkout@v3 32 | - uses: dtolnay/rust-toolchain@nightly 33 | 34 | - name: Check documentation 35 | shell: bash 36 | env: 37 | RUSTFLAGS: --cfg docsrs 38 | RUSTDOCFLAGS: --cfg docsrs -Dwarnings 39 | run: cargo doc --no-deps --document-private-items --all-features 40 | -------------------------------------------------------------------------------- /.github/workflows/check-examples.yml: -------------------------------------------------------------------------------- 1 | name: Check examples 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | 8 | jobs: 9 | check: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | - uses: dtolnay/rust-toolchain@stable 14 | - uses: Swatinem/rust-cache@v2 15 | 16 | - name: Check examples 17 | working-directory: examples 18 | shell: bash 19 | run: ./check-examples.sh -------------------------------------------------------------------------------- /.github/workflows/closed-issue-message.yml: -------------------------------------------------------------------------------- 1 | name: Closed Issue Message 2 | on: 3 | issues: 4 | types: [closed] 5 | jobs: 6 | auto_comment: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: aws-actions/closed-issue-message@v1 10 | with: 11 | # These inputs are both required 12 | repo-token: "${{ secrets.GITHUB_TOKEN }}" 13 | message: | 14 | This issue is now closed. Comments on closed issues are hard for our team to see. 15 | If you need more assistance, please either tag a team member or open a new issue that references this one. 16 | -------------------------------------------------------------------------------- /.github/workflows/format.yml: -------------------------------------------------------------------------------- 1 | name: Formatting and Linting 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | fmt: 7 | name: Cargo fmt 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: dtolnay/rust-toolchain@nightly 12 | with: 13 | components: rustfmt 14 | - uses: Swatinem/rust-cache@v2 15 | - name: Run fmt check 16 | id: cargoFmt 17 | shell: bash 18 | run: cargo +nightly fmt --all -- --check 19 | clippy: 20 | name: Cargo clippy 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v3 24 | - uses: dtolnay/rust-toolchain@stable 25 | - uses: Swatinem/rust-cache@v2 26 | - name: Run clippy check 27 | id: cargoClippy 28 | shell: bash 29 | run: cargo clippy --workspace --all-features -- -D warnings 30 | 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | /.cargo 3 | lambda-runtime/libtest.rmeta 4 | lambda-integration-tests/target 5 | Cargo.lock 6 | 7 | # Built AWS Lambda zipfile 8 | lambda.zip 9 | 10 | # output.json from example docs 11 | output.json 12 | 13 | .aws-sam 14 | build 15 | .vscode 16 | 17 | node_modules 18 | cdk.out 19 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | edition = "2021" 2 | 3 | # https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#max_width 4 | max_width = 120 5 | 6 | #https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#reorder_imports 7 | reorder_imports = true 8 | 9 | #https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#unstable_features 10 | unstable_features = true 11 | 12 | # imports_granularity is unstable 13 | # https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#merge_imports 14 | imports_granularity = "Crate" 15 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | 3 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 4 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 5 | opensource-codeofconduct@amazon.com with any additional questions or comments. 6 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = [ 4 | "lambda-http", 5 | "lambda-integration-tests", 6 | "lambda-runtime-api-client", 7 | "lambda-runtime", 8 | "lambda-extension", 9 | "lambda-events", 10 | ] 11 | 12 | exclude = ["examples"] 13 | 14 | [workspace.dependencies] 15 | base64 = "0.22" 16 | bytes = "1" 17 | chrono = { version = "0.4.35", default-features = false, features = [ 18 | "clock", 19 | "serde", 20 | "std", 21 | ] } 22 | futures = "0.3" 23 | futures-channel = "0.3" 24 | futures-util = "0.3" 25 | http = "1.0" 26 | http-body = "1.0" 27 | http-body-util = "0.1" 28 | http-serde = "2.0" 29 | hyper = "1.0" 30 | hyper-util = "0.1.1" 31 | pin-project-lite = "0.2" 32 | tower = "0.5" 33 | tower-layer = "0.3" 34 | tower-service = "0.3" 35 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | AWS Lambda Rust Runtime 2 | Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | -------------------------------------------------------------------------------- /examples/advanced-appconfig-feature-flags/.gitignore: -------------------------------------------------------------------------------- 1 | /target -------------------------------------------------------------------------------- /examples/advanced-appconfig-feature-flags/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lambda-appconfig" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # Starting in Rust 1.62 you can use `cargo add` to add dependencies 7 | # to your project. 8 | # 9 | # If you're using an older Rust version, 10 | # download cargo-edit(https://github.com/killercup/cargo-edit#installation) 11 | # to install the `add` subcommand. 12 | # 13 | # Running `cargo add DEPENDENCY_NAME` will 14 | # add the latest version of a dependency to the list, 15 | # and it will keep the alphabetic ordering for you. 16 | 17 | [dependencies] 18 | async-trait = "0.1.68" 19 | lambda_runtime = "0.13" 20 | reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] } 21 | serde = { version = "1.0", features = ["derive"] } 22 | serde_json = "1.0" 23 | thiserror = "1.0" 24 | tokio = { version = "1", features = ["macros"] } 25 | -------------------------------------------------------------------------------- /examples/advanced-appconfig-feature-flags/cdk/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /examples/advanced-appconfig-feature-flags/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to your CDK TypeScript project 2 | 3 | This is a blank project for CDK development with TypeScript. 4 | 5 | The `cdk.json` file tells the CDK Toolkit how to execute your app. 6 | 7 | ## Useful commands 8 | 9 | * `npm run build` compile typescript to js 10 | * `npm run watch` watch for changes and compile 11 | * `npm run test` perform the jest unit tests 12 | * `npx cdk deploy` deploy this stack to your default AWS account/region 13 | * `npx cdk diff` compare deployed stack with current state 14 | * `npx cdk synth` emits the synthesized CloudFormation template 15 | -------------------------------------------------------------------------------- /examples/advanced-appconfig-feature-flags/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import 'source-map-support/register'; 3 | import * as cdk from 'aws-cdk-lib'; 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | 6 | const app = new cdk.App(); 7 | new CdkStack(app, 'CdkStack', { 8 | /* If you don't specify 'env', this stack will be environment-agnostic. 9 | * Account/Region-dependent features and context lookups will not work, 10 | * but a single synthesized template can be deployed anywhere. */ 11 | 12 | /* Uncomment the next line to specialize this stack for the AWS Account 13 | * and Region that are implied by the current CLI configuration. */ 14 | // env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION }, 15 | 16 | /* Uncomment the next line if you know exactly what Account and Region you 17 | * want to deploy the stack to. */ 18 | // env: { account: '123456789012', region: 'us-east-1' }, 19 | 20 | /* For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */ 21 | }); -------------------------------------------------------------------------------- /examples/advanced-appconfig-feature-flags/cdk/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest' 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /examples/advanced-appconfig-feature-flags/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cdk", 3 | "version": "0.1.0", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/jest": "^29.5.12", 15 | "@types/node": "20.14.2", 16 | "aws-cdk": "2.159.1", 17 | "jest": "^29.7.0", 18 | "ts-jest": "^29.1.4", 19 | "ts-node": "^10.9.2", 20 | "typescript": "~5.4.5" 21 | }, 22 | "dependencies": { 23 | "aws-cdk-lib": "2.193.0", 24 | "cargo-lambda-cdk": "^0.0.22", 25 | "constructs": "^10.0.0", 26 | "source-map-support": "^0.5.21" 27 | } 28 | } -------------------------------------------------------------------------------- /examples/advanced-appconfig-feature-flags/cdk/test/cdk.test.ts: -------------------------------------------------------------------------------- 1 | // import * as cdk from 'aws-cdk-lib'; 2 | // import { Template } from 'aws-cdk-lib/assertions'; 3 | // import * as Cdk from '../lib/cdk-stack'; 4 | 5 | // example test. To run these tests, uncomment this file along with the 6 | // example resource in lib/cdk-stack.ts 7 | test('SQS Queue Created', () => { 8 | // const app = new cdk.App(); 9 | // // WHEN 10 | // const stack = new Cdk.CdkStack(app, 'MyTestStack'); 11 | // // THEN 12 | // const template = Template.fromStack(stack); 13 | 14 | // template.hasResourceProperties('AWS::SQS::Queue', { 15 | // VisibilityTimeout: 300 16 | // }); 17 | }); 18 | -------------------------------------------------------------------------------- /examples/advanced-appconfig-feature-flags/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2020", 7 | "dom" 8 | ], 9 | "declaration": true, 10 | "strict": true, 11 | "noImplicitAny": true, 12 | "strictNullChecks": true, 13 | "noImplicitThis": true, 14 | "alwaysStrict": true, 15 | "noUnusedLocals": false, 16 | "noUnusedParameters": false, 17 | "noImplicitReturns": true, 18 | "noFallthroughCasesInSwitch": false, 19 | "inlineSourceMap": true, 20 | "inlineSources": true, 21 | "experimentalDecorators": true, 22 | "strictPropertyInitialization": false, 23 | "typeRoots": [ 24 | "./node_modules/@types" 25 | ] 26 | }, 27 | "exclude": [ 28 | "node_modules", 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /examples/advanced-sqs-multiple-functions-shared-data/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | 4 | members = [ 5 | "producer", 6 | "consumer", 7 | "pizza_lib", 8 | ] 9 | 10 | [profile.release] 11 | opt-level = 'z' 12 | lto = true 13 | codegen-units = 1 14 | panic = 'abort' -------------------------------------------------------------------------------- /examples/advanced-sqs-multiple-functions-shared-data/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 4. Make sure to edit the QUEUE_URL env variable in producer/Cargo.toml 8 | 3. Deploy boths functions to AWS Lambda with 9 | 10 | `cargo lambda deploy consumer --iam-role YOUR_ROLE` 11 | 12 | `cargo lambda deploy producer --iam-role YOUR_ROLE` 13 | 14 | ## Build for ARM 64 15 | 16 | Build the function with `cargo lambda build --release --arm64` 17 | 18 | ## Add the SQS trigger to the consumer function 19 | 20 | You can use aws-cli to create an event source mapping: 21 | 22 | ```bash 23 | aws lambda create-event-source-mapping \ 24 | --function-name consumer \ 25 | --region \ 26 | --event-source-arn \ 27 | --batch-size 1 28 | ``` -------------------------------------------------------------------------------- /examples/advanced-sqs-multiple-functions-shared-data/consumer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "consumer" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | #aws dependencies 8 | aws-sdk-config = "0.35.0" 9 | aws-sdk-sqs = "0.35.0" 10 | aws_lambda_events = { version = "0.11.1", features = ["sqs"], default-features = false } 11 | 12 | #lambda runtime 13 | lambda_runtime = { path = "../../../lambda-runtime" } 14 | tokio = { version = "1", features = ["macros"] } 15 | 16 | #shared lib 17 | pizza_lib = { path = "../pizza_lib" } 18 | -------------------------------------------------------------------------------- /examples/advanced-sqs-multiple-functions-shared-data/consumer/src/main.rs: -------------------------------------------------------------------------------- 1 | use aws_lambda_events::event::sqs::SqsEventObj; 2 | use lambda_runtime::{service_fn, tracing, Error, LambdaEvent}; 3 | use pizza_lib::Pizza; 4 | 5 | #[tokio::main] 6 | async fn main() -> Result<(), Error> { 7 | tracing::init_default_subscriber(); 8 | let func = service_fn(func); 9 | lambda_runtime::run(func).await?; 10 | Ok(()) 11 | } 12 | 13 | async fn func(event: LambdaEvent>) -> Result<(), Error> { 14 | for record in event.payload.records.iter() { 15 | let pizza = &record.body; 16 | tracing::info!(name = pizza.name, toppings = ?pizza.toppings, "pizza order received"); 17 | } 18 | Ok(()) 19 | } 20 | -------------------------------------------------------------------------------- /examples/advanced-sqs-multiple-functions-shared-data/pizza_lib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pizza_lib" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | serde = { version = "1.0.191", features = ["derive"] } 8 | -------------------------------------------------------------------------------- /examples/advanced-sqs-multiple-functions-shared-data/pizza_lib/src/lib.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | #[derive(Serialize, Deserialize)] 4 | pub struct Pizza { 5 | pub name: String, 6 | pub toppings: Vec, 7 | } 8 | -------------------------------------------------------------------------------- /examples/advanced-sqs-multiple-functions-shared-data/producer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "producer" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [package.metadata.lambda.deploy] 7 | env = { "QUEUE_URL" = "https://changeMe" } 8 | 9 | [dependencies] 10 | #aws dependencies 11 | aws-config = "0.57.1" 12 | aws-sdk-config = "0.35.0" 13 | aws-sdk-sqs = "0.35.0" 14 | 15 | #lambda runtime 16 | lambda_runtime = { path = "../../../lambda-runtime" } 17 | serde_json = "1.0.108" 18 | tokio = { version = "1", features = ["macros"] } 19 | 20 | #shared lib 21 | pizza_lib = { path = "../pizza_lib" } -------------------------------------------------------------------------------- /examples/advanced-sqs-partial-batch-failures/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "advanced-sqs-partial-batch-failures" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | serde = "^1" 8 | serde_derive = "^1" 9 | serde_with = { version = "^2", features = ["json"], optional = true } 10 | serde_json = "^1" 11 | aws_lambda_events = { path = "../../lambda-events" } 12 | lambda_runtime = { path = "../../lambda-runtime" } 13 | tokio = { version = "1", features = ["macros"] } 14 | futures = "0.3" 15 | -------------------------------------------------------------------------------- /examples/advanced-sqs-partial-batch-failures/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function that receives events from SQS 2 | 3 | This example shows how to process events from an SQS queue using the partial batch failure feature. 4 | 5 | _Important note:_ your lambda sqs trigger _needs_ to be configured with partial batch response support 6 | (the `ReportBatchItemFailures` flag set to true), otherwise failed message will be not be reprocessed. You may see more details [here](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting). 7 | 8 | ## Build & Deploy 9 | 10 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 11 | 2. Build the function with `cargo lambda build --release` 12 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 13 | 14 | ## Build for ARM 64 15 | 16 | Build the function with `cargo lambda build --release --arm64` 17 | -------------------------------------------------------------------------------- /examples/basic-cognito-post-confirmation/.gitignore: -------------------------------------------------------------------------------- 1 | /target -------------------------------------------------------------------------------- /examples/basic-cognito-post-confirmation/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic-cognito-post-confirmation" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # Starting in Rust 1.62 you can use `cargo add` to add dependencies 7 | # to your project. 8 | # 9 | # If you're using an older Rust version, 10 | # download cargo-edit(https://github.com/killercup/cargo-edit#installation) 11 | # to install the `add` subcommand. 12 | # 13 | # Running `cargo add DEPENDENCY_NAME` will 14 | # add the latest version of a dependency to the list, 15 | # and it will keep the alphabetic ordering for you. 16 | 17 | [dependencies] 18 | aws-config = "1.5.0" 19 | aws-sdk-ses = "1.28.0" 20 | aws_lambda_events = { path = "../../lambda-events", default-features = false, features = ["cognito"] } 21 | 22 | lambda_runtime = { path = "../../lambda-runtime" } 23 | tokio = { version = "1", features = ["macros"] } 24 | 25 | -------------------------------------------------------------------------------- /examples/basic-cognito-post-confirmation/README.md: -------------------------------------------------------------------------------- 1 | # Cognito Post Confirmation Request example 2 | 3 | This example shows how to write a Lambda function in Rust to process Cognito's Post Confirmation requests. 4 | 5 | This is a translation of the example in the AWS Docs to Rust: https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-post-confirmation.html#aws-lambda-triggers-post-confirmation-example 6 | 7 | ## Build & Deploy 8 | 9 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 10 | 2. Build the function with `cargo lambda build --release` 11 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy` 12 | 13 | ## Build for ARM 64 14 | 15 | Build the function with `cargo lambda build --release --arm64` 16 | -------------------------------------------------------------------------------- /examples/basic-error-error-crates-integration/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /examples/basic-error-error-crates-integration/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic-error-error-crates-integration" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | anyhow = "1" 8 | eyre = "0.6.12" 9 | lambda_runtime = { path = "../../lambda-runtime", features = ["anyhow", "eyre", "miette"] } 10 | miette = "7.2.0" 11 | serde = "1" 12 | tokio = { version = "1", features = ["macros"] } 13 | -------------------------------------------------------------------------------- /examples/basic-error-error-crates-integration/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function Error Handling with several popular error crates. 2 | 3 | This example shows how to use external error types like `anyhow::Error`, `eyre::Report`, and `miette::Report`. 4 | 5 | To use the integrations with these crates, you need to enable to respective feature flag in the runtime which provides the implemetation of `into_diagnostic` for specific error types provided by these crates. 6 | 7 | ## Build & Deploy 8 | 9 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 10 | 2. Build the function with `cargo lambda build --release` 11 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 12 | 13 | ## Build for ARM 64 14 | 15 | Build the function with `cargo lambda build --release --arm64` 16 | -------------------------------------------------------------------------------- /examples/basic-error-handling/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "error-handling" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda_runtime = { path = "../../lambda-runtime" } 8 | serde = "1.0.136" 9 | serde_json = "1.0.81" 10 | simple-error = "0.2.3" 11 | tokio = { version = "1", features = ["macros"] } 12 | -------------------------------------------------------------------------------- /examples/basic-error-handling/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function Error handling example 2 | 3 | This example shows how to return a custom error type for unexpected failures. 4 | 5 | ## Build & Deploy 6 | 7 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 8 | 2. Build the function with `cargo lambda build --release` 9 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 10 | 11 | ## Build for ARM 64 12 | 13 | Build the function with `cargo lambda build --release --arm64` 14 | -------------------------------------------------------------------------------- /examples/basic-error-thiserror/.gitignore: -------------------------------------------------------------------------------- 1 | /target -------------------------------------------------------------------------------- /examples/basic-error-thiserror/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic-error-thiserror" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # Starting in Rust 1.62 you can use `cargo add` to add dependencies 7 | # to your project. 8 | # 9 | # If you're using an older Rust version, 10 | # download cargo-edit(https://github.com/killercup/cargo-edit#installation) 11 | # to install the `add` subcommand. 12 | # 13 | # Running `cargo add DEPENDENCY_NAME` will 14 | # add the latest version of a dependency to the list, 15 | # and it will keep the alphabetic ordering for you. 16 | 17 | [dependencies] 18 | 19 | lambda_runtime = { path = "../../lambda-runtime" } 20 | serde = "1" 21 | thiserror = "1.0.61" 22 | tokio = { version = "1", features = ["macros"] } 23 | -------------------------------------------------------------------------------- /examples/basic-error-thiserror/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function Error handling example 2 | 3 | This example shows how to implement the `Diagnostic` trait to return a specific `error_type` in the Lambda error response. If you don't use the `error_type` field, you don't need to implement `Diagnostic`, the type will be generated based on the error type name. 4 | 5 | ## Build & Deploy 6 | 7 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 8 | 2. Build the function with `cargo lambda build --release` 9 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 10 | 11 | ## Build for ARM 64 12 | 13 | Build the function with `cargo lambda build --release --arm64` 14 | -------------------------------------------------------------------------------- /examples/basic-error-thiserror/src/main.rs: -------------------------------------------------------------------------------- 1 | use lambda_runtime::{service_fn, Diagnostic, Error, LambdaEvent}; 2 | use serde::Deserialize; 3 | use thiserror; 4 | 5 | #[derive(Deserialize)] 6 | struct Request {} 7 | 8 | #[derive(Debug, thiserror::Error)] 9 | pub enum ExecutionError { 10 | #[error("transient database error: {0}")] 11 | DatabaseError(String), 12 | #[error("unexpected error: {0}")] 13 | Unexpected(String), 14 | } 15 | 16 | impl From for Diagnostic { 17 | fn from(value: ExecutionError) -> Diagnostic { 18 | let (error_type, error_message) = match value { 19 | ExecutionError::DatabaseError(err) => ("Retryable", err.to_string()), 20 | ExecutionError::Unexpected(err) => ("NonRetryable", err.to_string()), 21 | }; 22 | Diagnostic { 23 | error_type: error_type.into(), 24 | error_message: error_message.into(), 25 | } 26 | } 27 | } 28 | 29 | /// This is the main body for the Lambda function 30 | async fn function_handler(_event: LambdaEvent) -> Result<(), ExecutionError> { 31 | Err(ExecutionError::Unexpected("ooops".to_string())) 32 | } 33 | 34 | #[tokio::main] 35 | async fn main() -> Result<(), Error> { 36 | lambda_runtime::run(service_fn(function_handler)).await 37 | } 38 | -------------------------------------------------------------------------------- /examples/basic-lambda-external-runtime/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic-lambda-external-runtime" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | async-channel = "1.8.0" 8 | futures-lite = "1.13.0" 9 | lambda_runtime = { path = "../../lambda-runtime" } 10 | serde = "1.0.163" 11 | tokio = "1.28.2" 12 | 13 | [dev-dependencies] 14 | tokio-test = "0.4.2" 15 | -------------------------------------------------------------------------------- /examples/basic-lambda-external-runtime/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 8 | 9 | ## Build for ARM 64 10 | 11 | Build the function with `cargo lambda build --release --arm64` 12 | -------------------------------------------------------------------------------- /examples/basic-lambda/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic-lambda" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda_runtime = { path = "../../lambda-runtime" } 8 | serde = "1.0.136" 9 | tokio = { version = "1", features = ["macros"] } 10 | 11 | [dev-dependencies] 12 | tokio-test = "0.4.2" -------------------------------------------------------------------------------- /examples/basic-lambda/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 8 | 9 | ## Build for ARM 64 10 | 11 | Build the function with `cargo lambda build --release --arm64` 12 | -------------------------------------------------------------------------------- /examples/basic-s3-object-lambda-thumbnail/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic-s3-object-lambda-thumbnail" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # Starting in Rust 1.62 you can use `cargo add` to add dependencies 7 | # to your project. 8 | # 9 | # If you're using an older Rust version, 10 | # download cargo-edit(https://github.com/killercup/cargo-edit#installation) 11 | # to install the `add` subcommand. 12 | # 13 | # Running `cargo add DEPENDENCY_NAME` will 14 | # add the latest version of a dependency to the list, 15 | # and it will keep the alphabetic ordering for you. 16 | 17 | [dependencies] 18 | aws_lambda_events = "0.8.3" 19 | lambda_runtime = { path = "../../lambda-runtime" } 20 | serde = "1" 21 | tokio = { version = "1", features = ["macros"] } 22 | aws-config = "0.55.3" 23 | aws-sdk-s3 = "0.28.0" 24 | thumbnailer = "0.5.1" 25 | mime = "0.3.16" 26 | async-trait = "0.1.66" 27 | ureq = "2.6.2" 28 | aws-smithy-http = "0.55.3" 29 | webp = "=0.2.1" 30 | 31 | [dev-dependencies] 32 | mockall = "0.11.3" 33 | tokio-test = "0.4.2" 34 | -------------------------------------------------------------------------------- /examples/basic-s3-object-lambda-thumbnail/testdata/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-lambda-rust-runtime/62a36b04ddfd67000d407d06d0da60f394ca4b36/examples/basic-s3-object-lambda-thumbnail/testdata/image.png -------------------------------------------------------------------------------- /examples/basic-s3-object-lambda-thumbnail/testdata/thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-lambda-rust-runtime/62a36b04ddfd67000d407d06d0da60f394ca4b36/examples/basic-s3-object-lambda-thumbnail/testdata/thumbnail.png -------------------------------------------------------------------------------- /examples/basic-s3-thumbnail/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic-s3-thumbnail" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # Starting in Rust 1.62 you can use `cargo add` to add dependencies 7 | # to your project. 8 | # 9 | # If you're using an older Rust version, 10 | # download cargo-edit(https://github.com/killercup/cargo-edit#installation) 11 | # to install the `add` subcommand. 12 | # 13 | # Running `cargo add DEPENDENCY_NAME` will 14 | # add the latest version of a dependency to the list, 15 | # and it will keep the alphabetic ordering for you. 16 | 17 | [dependencies] 18 | aws_lambda_events = { path = "../../lambda-events" } 19 | lambda_runtime = { path = "../../lambda-runtime" } 20 | serde = "1" 21 | tokio = { version = "1", features = ["macros"] } 22 | aws-config = "0.55" 23 | aws-smithy-http = "0.55.3" 24 | aws-sdk-s3 = "0.28" 25 | thumbnailer = "0.5.1" 26 | mime = "0.3.16" 27 | async-trait = "0.1.68" 28 | webp = "=0.2.1" 29 | 30 | [dev-dependencies] 31 | mockall = "0.11" 32 | tokio-test = "0.4" 33 | chrono = "0.4" 34 | -------------------------------------------------------------------------------- /examples/basic-s3-thumbnail/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function that uses S3 2 | 3 | This example processes S3 events. If the event is a CREATE event, 4 | it downloads the created file, generates a thumbnail from it 5 | (it assumes that the file is an image) and uploads it to S3 into a bucket named 6 | [original-bucket-name]-thumbs. 7 | 8 | ## Set up 9 | 1. Create a lambda function and upload the bootloader.zip 10 | 2. Go to aws services S3 11 | 3. Create a bucket, let's say with name bucketx 12 | 4. Create another bucket bucketx-thumbs 13 | 5. Got to the bucketx properties tab, event notifications 14 | 6. Create lambda event notification for "all object create event" and select your lambda function 15 | 7. Go to the lambda function, configuration and open the role name 16 | 8. Add "AmazonS3FullAccess" permission 17 | 18 | ## Test 19 | 20 | 1. Go to S3 and upload a png picture into bucketx. Beware to not have spaces or any special characters in the file name 21 | 2. Go to S3 bucketx-thumbs and check if an image is created there. 22 | 23 | 24 | ## Build & Deploy 25 | 26 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 27 | 2. Build the function with `cargo lambda build --release` 28 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 29 | 30 | ## Build for ARM 64 31 | 32 | Build the function with `cargo lambda build --release --arm64` -------------------------------------------------------------------------------- /examples/basic-sdk/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic-sdk" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | async-trait = "0.1" 10 | aws-config = "0.54" 11 | aws-sdk-s3 = "0.24" 12 | lambda_runtime = { path = "../../lambda-runtime" } 13 | serde = "1.0.136" 14 | tokio = { version = "1", features = ["macros"] } 15 | 16 | [dev-dependencies] 17 | mockall = "0.11.3" 18 | tokio-test = "0.4.2" -------------------------------------------------------------------------------- /examples/basic-sdk/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## basic-sdk example 3 | 4 | This is an sample function that uses the [AWS SDK](https://github.com/awslabs/aws-sdk-rust) to 5 | list the contents of an S3 bucket specified by the invoker. It uses standard credentials as defined 6 | in the function's execution role to make calls against S3. 7 | 8 | ### Running Locally 9 | You can use `cargo lambda watch` to spin up a local version of the function. This will automatically re-compile and restart 10 | itself when it observes changes to the code. If you invoke `watch` with no other context then the function will not have 11 | the environment variables necessary to supply on SDK calls. To get around this you can manually supply a credentials file 12 | profile for the SDK to resolve and use in your function: 13 | ``` 14 | AWS_PROFILE=my-profile cargo lambda watch 15 | ``` 16 | 17 | ### Invoking 18 | You can invoke by simply leveraging `cargo lambda invoke` with the payload expected by the function handler. 19 | ``` 20 | cargo lambda invoke --data-ascii '{"bucket":"my-bucket"}' 21 | ``` 22 | -------------------------------------------------------------------------------- /examples/basic-shared-resource/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "shared-resource" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda_runtime = { path = "../../lambda-runtime" } 8 | serde = "1.0.136" 9 | tokio = { version = "1", features = ["macros"] } 10 | -------------------------------------------------------------------------------- /examples/basic-shared-resource/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 8 | 9 | ## Build for ARM 64 10 | 11 | Build the function with `cargo lambda build --release --arm64` 12 | -------------------------------------------------------------------------------- /examples/basic-sqs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic-sqs" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # Starting in Rust 1.62 you can use `cargo add` to add dependencies 7 | # to your project. 8 | # 9 | # If you're using an older Rust version, 10 | # download cargo-edit(https://github.com/killercup/cargo-edit#installation) 11 | # to install the `add` subcommand. 12 | # 13 | # Running `cargo add DEPENDENCY_NAME` will 14 | # add the latest version of a dependency to the list, 15 | # and it will keep the alphabetic ordering for you. 16 | 17 | [dependencies] 18 | aws_lambda_events = { path = "../../lambda-events" } 19 | lambda_runtime = { path = "../../lambda-runtime" } 20 | serde = "1.0.136" 21 | tokio = { version = "1", features = ["macros"] } 22 | -------------------------------------------------------------------------------- /examples/basic-sqs/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function that receives events from SQS 2 | 3 | This example shows how to process events from a SQS queue. 4 | 5 | ## Build & Deploy 6 | 7 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 8 | 2. Build the function with `cargo lambda build --release` 9 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 10 | 11 | ## Build for ARM 64 12 | 13 | Build the function with `cargo lambda build --release --arm64` -------------------------------------------------------------------------------- /examples/basic-sqs/src/main.rs: -------------------------------------------------------------------------------- 1 | use aws_lambda_events::event::sqs::SqsEventObj; 2 | use lambda_runtime::{run, service_fn, tracing, Error, LambdaEvent}; 3 | use serde::{Deserialize, Serialize}; 4 | 5 | /// Object that you send to SQS and plan to process on the function. 6 | #[derive(Deserialize, Serialize)] 7 | struct Data { 8 | id: String, 9 | text: String, 10 | } 11 | 12 | /// This is the main body for the function. 13 | /// You can use the data sent into SQS here. 14 | async fn function_handler(event: LambdaEvent>) -> Result<(), Error> { 15 | let data = &event.payload.records[0].body; 16 | tracing::info!(id = ?data.id, text = ?data.text, "data received from SQS"); 17 | 18 | Ok(()) 19 | } 20 | 21 | #[tokio::main] 22 | async fn main() -> Result<(), Error> { 23 | // required to enable CloudWatch error logging by the runtime 24 | tracing::init_default_subscriber(); 25 | 26 | run(service_fn(function_handler)).await 27 | } 28 | -------------------------------------------------------------------------------- /examples/basic-streaming-response/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic-streaming-response" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | lambda_runtime = { path = "../../lambda-runtime" } 10 | tokio = { version = "1", features = ["macros"] } 11 | serde_json = "1.0" -------------------------------------------------------------------------------- /examples/basic-streaming-response/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --enable-function-url --iam-role YOUR_ROLE` 8 | 4. Enable Lambda streaming response on Lambda console: change the function url's invoke mode to `RESPONSE_STREAM` 9 | 5. Verify the function works: `curl -v -N `. The results should be streamed back with 0.5 second pause between each word. 10 | 11 | ## Build for ARM 64 12 | 13 | Build the function with `cargo lambda build --release --arm64` 14 | -------------------------------------------------------------------------------- /examples/basic-streaming-response/src/main.rs: -------------------------------------------------------------------------------- 1 | use lambda_runtime::{ 2 | service_fn, 3 | streaming::{channel, Body, Response}, 4 | tracing, Error, LambdaEvent, 5 | }; 6 | use serde_json::Value; 7 | use std::{thread, time::Duration}; 8 | 9 | async fn func(_event: LambdaEvent) -> Result, Error> { 10 | let messages = vec!["Hello", "world", "from", "Lambda!"]; 11 | 12 | let (mut tx, rx) = channel(); 13 | 14 | tokio::spawn(async move { 15 | for message in messages.iter() { 16 | tx.send_data((message.to_string() + "\n").into()).await.unwrap(); 17 | thread::sleep(Duration::from_millis(500)); 18 | } 19 | }); 20 | 21 | Ok(Response::from(rx)) 22 | } 23 | 24 | #[tokio::main] 25 | async fn main() -> Result<(), Error> { 26 | // required to enable CloudWatch error logging by the runtime 27 | tracing::init_default_subscriber(); 28 | 29 | lambda_runtime::run(service_fn(func)).await?; 30 | Ok(()) 31 | } 32 | -------------------------------------------------------------------------------- /examples/check-examples.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 5 | export CARGO_TARGET_DIR="$SCRIPT_DIR/../target" 6 | 7 | echo "==> Using shared target directory: $CARGO_TARGET_DIR" 8 | 9 | for f in *; do 10 | if [ -d "$f" ]; then 11 | echo "==> Checking example: $f" 12 | cd $f 13 | cargo test 14 | cd .. 15 | fi 16 | done 17 | -------------------------------------------------------------------------------- /examples/extension-basic/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "extension-basic" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda-extension = { path = "../../lambda-extension" } 8 | serde = "1.0.136" 9 | tokio = { version = "1", features = ["macros"] } 10 | -------------------------------------------------------------------------------- /examples/extension-basic/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Logs extension example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the extension with `cargo lambda build --release --extension` 7 | 3. Deploy the extension as a layer with `cargo lambda deploy --extension` 8 | 9 | The last command will give you an ARN for the extension layer that you can use in your functions. 10 | 11 | ## Build for ARM 64 12 | 13 | Build the extension with `cargo lambda build --release --extension --arm64` 14 | -------------------------------------------------------------------------------- /examples/extension-basic/src/main.rs: -------------------------------------------------------------------------------- 1 | use lambda_extension::{service_fn, tracing, Error, LambdaEvent, NextEvent}; 2 | 3 | async fn my_extension(event: LambdaEvent) -> Result<(), Error> { 4 | match event.next { 5 | NextEvent::Shutdown(_e) => { 6 | // do something with the shutdown event 7 | } 8 | NextEvent::Invoke(_e) => { 9 | // do something with the invoke event 10 | } 11 | } 12 | Ok(()) 13 | } 14 | 15 | #[tokio::main] 16 | async fn main() -> Result<(), Error> { 17 | // required to enable CloudWatch error logging by the runtime 18 | tracing::init_default_subscriber(); 19 | 20 | let func = service_fn(my_extension); 21 | lambda_extension::run(func).await 22 | } 23 | -------------------------------------------------------------------------------- /examples/extension-combined/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "extension-combined" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda-extension = { path = "../../lambda-extension" } 8 | serde = "1.0.136" 9 | tokio = { version = "1", features = ["macros"] } 10 | -------------------------------------------------------------------------------- /examples/extension-combined/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Logs extension example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the extension with `cargo lambda build --release --extension` 7 | 3. Deploy the extension as a layer with `cargo lambda deploy --extension` 8 | 9 | The last command will give you an ARN for the extension layer that you can use in your functions. 10 | 11 | ## Build for ARM 64 12 | 13 | Build the extension with `cargo lambda build --release --extension --arm64` 14 | -------------------------------------------------------------------------------- /examples/extension-combined/src/main.rs: -------------------------------------------------------------------------------- 1 | use lambda_extension::{ 2 | service_fn, tracing, Error, Extension, LambdaEvent, LambdaLog, LambdaLogRecord, NextEvent, SharedService, 3 | }; 4 | 5 | async fn my_extension(event: LambdaEvent) -> Result<(), Error> { 6 | match event.next { 7 | NextEvent::Shutdown(_e) => { 8 | // do something with the shutdown event 9 | } 10 | NextEvent::Invoke(_e) => { 11 | // do something with the invoke event 12 | } 13 | } 14 | Ok(()) 15 | } 16 | 17 | async fn my_log_processor(logs: Vec) -> Result<(), Error> { 18 | for log in logs { 19 | match log.record { 20 | LambdaLogRecord::Function(record) => tracing::info!("[logs] [function] {}", record), 21 | LambdaLogRecord::Extension(record) => tracing::info!("[logs] [extension] {}", record), 22 | _ => (), 23 | } 24 | } 25 | 26 | Ok(()) 27 | } 28 | 29 | #[tokio::main] 30 | async fn main() -> Result<(), Error> { 31 | // required to enable CloudWatch error logging by the runtime 32 | tracing::init_default_subscriber(); 33 | 34 | let func = service_fn(my_extension); 35 | let logs_processor = SharedService::new(service_fn(my_log_processor)); 36 | 37 | Extension::new() 38 | .with_events_processor(func) 39 | .with_logs_processor(logs_processor) 40 | .run() 41 | .await 42 | } 43 | -------------------------------------------------------------------------------- /examples/extension-custom-events/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "extension-custom-events" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda-extension = { path = "../../lambda-extension" } 8 | serde = "1.0.136" 9 | tokio = { version = "1", features = ["macros"] } 10 | -------------------------------------------------------------------------------- /examples/extension-custom-events/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Logs extension example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the extension with `cargo lambda build --release --extension` 7 | 3. Deploy the extension as a layer with `cargo lambda deploy --extension` 8 | 9 | The last command will give you an ARN for the extension layer that you can use in your functions. 10 | 11 | ## Build for ARM 64 12 | 13 | Build the extension with `cargo lambda build --release --extension --arm64` 14 | -------------------------------------------------------------------------------- /examples/extension-custom-events/src/main.rs: -------------------------------------------------------------------------------- 1 | use lambda_extension::{service_fn, tracing, Error, Extension, LambdaEvent, NextEvent}; 2 | 3 | async fn my_extension(event: LambdaEvent) -> Result<(), Error> { 4 | match event.next { 5 | NextEvent::Shutdown(_e) => { 6 | // do something with the shutdown event 7 | } 8 | _ => { 9 | // ignore any other event 10 | // because we've registered the extension 11 | // only to receive SHUTDOWN events 12 | } 13 | } 14 | Ok(()) 15 | } 16 | 17 | #[tokio::main] 18 | async fn main() -> Result<(), Error> { 19 | // required to enable CloudWatch error logging by the runtime 20 | tracing::init_default_subscriber(); 21 | 22 | Extension::new() 23 | .with_events(&["SHUTDOWN"]) 24 | .with_events_processor(service_fn(my_extension)) 25 | .run() 26 | .await 27 | } 28 | -------------------------------------------------------------------------------- /examples/extension-custom-service/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "extension-custom-service" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda-extension = { path = "../../lambda-extension" } 8 | serde = "1.0.136" 9 | tokio = { version = "1", features = ["macros"] } 10 | -------------------------------------------------------------------------------- /examples/extension-custom-service/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Logs extension example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the extension with `cargo lambda build --release --extension` 7 | 3. Deploy the extension as a layer with `cargo lambda deploy --extension` 8 | 9 | The last command will give you an ARN for the extension layer that you can use in your functions. 10 | 11 | ## Build for ARM 64 12 | 13 | Build the extension with `cargo lambda build --release --extension --arm64` 14 | -------------------------------------------------------------------------------- /examples/extension-custom-service/src/main.rs: -------------------------------------------------------------------------------- 1 | use lambda_extension::{run, tracing, Error, InvokeEvent, LambdaEvent, NextEvent, Service}; 2 | use std::{ 3 | future::{ready, Future}, 4 | pin::Pin, 5 | }; 6 | 7 | #[derive(Default)] 8 | struct MyExtension { 9 | data: Vec, 10 | } 11 | 12 | impl Service for MyExtension { 13 | type Error = Error; 14 | type Future = Pin>>>; 15 | type Response = (); 16 | 17 | fn poll_ready(&mut self, _cx: &mut core::task::Context<'_>) -> core::task::Poll> { 18 | core::task::Poll::Ready(Ok(())) 19 | } 20 | 21 | fn call(&mut self, event: LambdaEvent) -> Self::Future { 22 | match event.next { 23 | NextEvent::Shutdown(_e) => { 24 | self.data.clear(); 25 | } 26 | NextEvent::Invoke(e) => { 27 | self.data.push(e); 28 | } 29 | } 30 | Box::pin(ready(Ok(()))) 31 | } 32 | } 33 | 34 | #[tokio::main] 35 | async fn main() -> Result<(), Error> { 36 | // required to enable CloudWatch error logging by the runtime 37 | tracing::init_default_subscriber(); 38 | 39 | run(MyExtension::default()).await 40 | } 41 | -------------------------------------------------------------------------------- /examples/extension-internal-flush/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "extension-internal-flush" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | anyhow = "1" 8 | aws_lambda_events = { path = "../../lambda-events" } 9 | lambda-extension = { path = "../../lambda-extension" } 10 | lambda_runtime = { path = "../../lambda-runtime" } 11 | serde = "1.0.136" 12 | tokio = { version = "1", features = ["macros", "sync"] } 13 | -------------------------------------------------------------------------------- /examples/extension-logs-basic/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "extension-logs-basic" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda-extension = { path = "../../lambda-extension" } 8 | serde = "1.0.136" 9 | tokio = { version = "1", features = ["macros", "rt"] } 10 | -------------------------------------------------------------------------------- /examples/extension-logs-basic/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Logs extension example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the extension with `cargo lambda build --release --extension` 7 | 3. Deploy the extension as a layer with `cargo lambda deploy --extension` 8 | 9 | The last command will give you an ARN for the extension layer that you can use in your functions. 10 | 11 | ## Build for ARM 64 12 | 13 | Build the extension with `cargo lambda build --release --extension --arm64` 14 | -------------------------------------------------------------------------------- /examples/extension-logs-basic/src/main.rs: -------------------------------------------------------------------------------- 1 | use lambda_extension::{service_fn, tracing, Error, Extension, LambdaLog, LambdaLogRecord, SharedService}; 2 | use tracing::info; 3 | 4 | async fn handler(logs: Vec) -> Result<(), Error> { 5 | for log in logs { 6 | match log.record { 7 | LambdaLogRecord::Function(record) => info!("[logs] [function] {}", record), 8 | LambdaLogRecord::Extension(record) => info!("[logs] [extension] {}", record), 9 | _ => (), 10 | } 11 | } 12 | 13 | Ok(()) 14 | } 15 | 16 | #[tokio::main] 17 | async fn main() -> Result<(), Error> { 18 | // required to enable CloudWatch error logging by the runtime 19 | tracing::init_default_subscriber(); 20 | 21 | let logs_processor = SharedService::new(service_fn(handler)); 22 | 23 | Extension::new().with_logs_processor(logs_processor).run().await?; 24 | 25 | Ok(()) 26 | } 27 | -------------------------------------------------------------------------------- /examples/extension-logs-custom-service/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "extension-logs-custom-service" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda-extension = { path = "../../lambda-extension" } 8 | serde = "1.0.136" 9 | tokio = { version = "1", features = ["macros"] } 10 | -------------------------------------------------------------------------------- /examples/extension-logs-custom-service/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Logs extension example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the extension with `cargo lambda build --release --extension` 7 | 3. Deploy the extension as a layer with `cargo lambda deploy --extension` 8 | 9 | The last command will give you an ARN for the extension layer that you can use in your functions. 10 | 11 | ## Build for ARM 64 12 | 13 | Build the extension with `cargo lambda build --release --extension --arm64` 14 | -------------------------------------------------------------------------------- /examples/extension-logs-kinesis-firehose/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lambda-logs-firehose-extension" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda-extension = { path = "../../lambda-extension" } 8 | tokio = { version = "1.17.0", features = ["full"] } 9 | aws-config = "0.13.0" 10 | aws-sdk-firehose = "0.13.0" 11 | -------------------------------------------------------------------------------- /examples/extension-logs-kinesis-firehose/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Logs extension example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the extension with `cargo lambda build --release --extension` 7 | 3. Deploy the extension as a layer with `cargo lambda deploy --extension` 8 | 9 | The last command will give you an ARN for the extension layer that you can use in your functions. 10 | 11 | ## Build for ARM 64 12 | 13 | Build the extension with `cargo lambda build --release --extension --arm64` 14 | -------------------------------------------------------------------------------- /examples/extension-telemetry-basic/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "extension-telemetry-basic" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda-extension = { path = "../../lambda-extension" } 8 | serde = "1.0.136" 9 | tokio = { version = "1", features = ["macros", "rt"] } 10 | -------------------------------------------------------------------------------- /examples/extension-telemetry-basic/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Telemetry extension example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the extension with `cargo lambda build --release --extension` 7 | 3. Deploy the extension as a layer with `cargo lambda deploy --extension` 8 | 9 | The last command will give you an ARN for the extension layer that you can use in your functions. 10 | 11 | ## Build for ARM 64 12 | 13 | Build the extension with `cargo lambda build --release --extension --arm64` 14 | -------------------------------------------------------------------------------- /examples/http-axum-apigw-authorizer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http-axum-apigw-authorizer" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | axum = "0.7" 8 | lambda_http = { path = "../../lambda-http" } 9 | lambda_runtime = { path = "../../lambda-runtime" } 10 | serde = "1.0.196" 11 | serde_json = "1.0" 12 | tokio = { version = "1", features = ["macros"] } 13 | -------------------------------------------------------------------------------- /examples/http-axum-apigw-authorizer/README.md: -------------------------------------------------------------------------------- 1 | # Axum example that integrates with Api Gateway authorizers 2 | 3 | This example shows how to extract information from the Api Gateway Request Authorizer in an Axum handler. 4 | 5 | ## Build & Deploy 6 | 7 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 8 | 2. Build the function with `cargo lambda build --release` 9 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 10 | 11 | ## Build for ARM 64 12 | 13 | Build the function with `cargo lambda build --release --arm64` 14 | -------------------------------------------------------------------------------- /examples/http-axum-diesel-ssl/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/aws-lambda-rust-runtime/62a36b04ddfd67000d407d06d0da60f394ca4b36/examples/http-axum-diesel-ssl/.DS_Store -------------------------------------------------------------------------------- /examples/http-axum-diesel-ssl/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http-axum-diesel" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | axum = "0.7" 8 | bb8 = "0.8.0" 9 | diesel = "2.0.3" 10 | diesel-async = { version = "0.2.1", features = ["postgres", "bb8"] } 11 | lambda_http = { path = "../../lambda-http" } 12 | lambda_runtime = { path = "../../lambda-runtime" } 13 | serde = "1.0.159" 14 | futures-util = "0.3.21" 15 | rustls = "0.20.8" 16 | rustls-native-certs = "0.6.2" 17 | tokio = { version = "1.2.0", default-features = false, features = ["macros", "rt-multi-thread"] } 18 | tokio-postgres = "0.7.7" 19 | tokio-postgres-rustls = "0.9.0" -------------------------------------------------------------------------------- /examples/http-axum-diesel-ssl/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | This example shows how to develop a REST API with Axum and Diesel that connects to a Postgres database. 4 | 5 | ## Build & Deploy 6 | 7 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 8 | 2. Build the function with `cargo lambda build --release` 9 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 10 | 11 | ## Build for ARM 64 12 | 13 | Build the function with `cargo lambda build --release --arm64` 14 | -------------------------------------------------------------------------------- /examples/http-axum-diesel-ssl/migrations/2023-04-07-231632_create_posts/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE posts -------------------------------------------------------------------------------- /examples/http-axum-diesel-ssl/migrations/2023-04-07-231632_create_posts/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE posts ( 3 | id SERIAL PRIMARY KEY, 4 | title VARCHAR NOT NULL, 5 | content TEXT NOT NULL, 6 | published BOOLEAN NOT NULL DEFAULT FALSE 7 | ) -------------------------------------------------------------------------------- /examples/http-axum-diesel/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http-axum-diesel" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | axum = "0.7" 8 | bb8 = "0.8.0" 9 | diesel = "2.0.3" 10 | diesel-async = { version = "0.2.1", features = ["postgres", "bb8"] } 11 | lambda_http = { path = "../../lambda-http" } 12 | lambda_runtime = { path = "../../lambda-runtime" } 13 | serde = "1.0.159" 14 | tokio = { version = "1", features = ["macros"] } 15 | -------------------------------------------------------------------------------- /examples/http-axum-diesel/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | This example shows how to develop a REST API with Axum and Diesel that connects to a Postgres database. 4 | 5 | ## Build & Deploy 6 | 7 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 8 | 2. Build the function with `cargo lambda build --release` 9 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 10 | 11 | ## Build for ARM 64 12 | 13 | Build the function with `cargo lambda build --release --arm64` 14 | -------------------------------------------------------------------------------- /examples/http-axum-diesel/migrations/2023-04-07-231632_create_posts/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE posts -------------------------------------------------------------------------------- /examples/http-axum-diesel/migrations/2023-04-07-231632_create_posts/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE posts ( 3 | id SERIAL PRIMARY KEY, 4 | title VARCHAR NOT NULL, 5 | content TEXT NOT NULL, 6 | published BOOLEAN NOT NULL DEFAULT FALSE 7 | ) -------------------------------------------------------------------------------- /examples/http-axum-middleware/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http-axum-middleware" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | axum = "0.7" 8 | lambda_http = { path = "../../lambda-http", default-features = false, features = [ 9 | "apigw_rest", "tracing" 10 | ] } 11 | lambda_runtime = { path = "../../lambda-runtime" } 12 | serde_json = "1.0" 13 | tokio = { version = "1", features = ["macros"] } 14 | -------------------------------------------------------------------------------- /examples/http-axum-middleware/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 8 | 9 | ## Build for ARM 64 10 | 11 | Build the function with `cargo lambda build --release --arm64` 12 | -------------------------------------------------------------------------------- /examples/http-axum/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http-axum" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | axum = "0.7" 8 | lambda_http = { path = "../../lambda-http" } 9 | lambda_runtime = { path = "../../lambda-runtime" } 10 | serde = "1.0.196" 11 | serde_json = "1.0" 12 | tokio = { version = "1", features = ["macros"] } 13 | -------------------------------------------------------------------------------- /examples/http-axum/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 8 | 9 | ## Build for ARM 64 10 | 11 | Build the function with `cargo lambda build --release --arm64` 12 | -------------------------------------------------------------------------------- /examples/http-axum/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | 6 | # CDK asset staging directory 7 | .cdk.staging 8 | cdk.out 9 | -------------------------------------------------------------------------------- /examples/http-axum/cdk/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /examples/http-axum/cdk/bin/cdk.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import 'source-map-support/register'; 3 | import * as cdk from 'aws-cdk-lib'; 4 | import { CdkStack } from '../lib/cdk-stack'; 5 | 6 | const app = new cdk.App(); 7 | new CdkStack(app, 'CdkStack', { 8 | /* If you don't specify 'env', this stack will be environment-agnostic. 9 | * Account/Region-dependent features and context lookups will not work, 10 | * but a single synthesized template can be deployed anywhere. */ 11 | 12 | /* Uncomment the next line to specialize this stack for the AWS Account 13 | * and Region that are implied by the current CLI configuration. */ 14 | // env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION }, 15 | 16 | /* Uncomment the next line if you know exactly what Account and Region you 17 | * want to deploy the stack to. */ 18 | // env: { account: '123456789012', region: 'us-east-1' }, 19 | 20 | /* For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */ 21 | }); -------------------------------------------------------------------------------- /examples/http-axum/cdk/lib/cdk-stack.ts: -------------------------------------------------------------------------------- 1 | import { join } from 'path'; 2 | import { CfnOutput, Stack, StackProps } from 'aws-cdk-lib'; 3 | import { Construct } from 'constructs'; 4 | import { RustFunction } from 'cargo-lambda-cdk'; 5 | import { LambdaRestApi } from 'aws-cdk-lib/aws-apigateway' 6 | import { FunctionUrlAuthType } from "aws-cdk-lib/aws-lambda"; 7 | 8 | export class CdkStack extends Stack { 9 | constructor(scope: Construct, id: string, props?: StackProps) { 10 | super(scope, id, props); 11 | 12 | const handler = new RustFunction(this, 'Axum API', { 13 | // Path to the http-axum root directory. 14 | manifestPath: join(__dirname, '..', '..'), 15 | }); 16 | 17 | if (process.env.ENABLE_LAMBDA_RUST_AXUM_FUNCTION_URL) { 18 | const lambdaUrl = handler.addFunctionUrl({ 19 | authType: FunctionUrlAuthType.NONE, 20 | }); 21 | new CfnOutput(this, 'Axum FunctionUrl ', { value: lambdaUrl.url }); 22 | } 23 | 24 | new LambdaRestApi(this, 'axum', { handler }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/http-axum/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cdk", 3 | "version": "0.1.0", 4 | "bin": { 5 | "cdk": "bin/cdk.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@types/jest": "^29.5.11", 15 | "@types/node": "20.11.14", 16 | "aws-cdk": "2.126.0", 17 | "jest": "^29.7.0", 18 | "ts-jest": "^29.1.2", 19 | "ts-node": "^10.9.2", 20 | "typescript": "~5.3.3" 21 | }, 22 | "dependencies": { 23 | "aws-cdk-lib": "^2.193.0", 24 | "cargo-lambda-cdk": "^0.0.17", 25 | "constructs": "^10.0.0", 26 | "source-map-support": "^0.5.21" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /examples/http-axum/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2020", 7 | "dom" 8 | ], 9 | "declaration": true, 10 | "strict": true, 11 | "noImplicitAny": true, 12 | "strictNullChecks": true, 13 | "noImplicitThis": true, 14 | "alwaysStrict": true, 15 | "noUnusedLocals": false, 16 | "noUnusedParameters": false, 17 | "noImplicitReturns": true, 18 | "noFallthroughCasesInSwitch": false, 19 | "inlineSourceMap": true, 20 | "inlineSources": true, 21 | "experimentalDecorators": true, 22 | "strictPropertyInitialization": false, 23 | "typeRoots": [ 24 | "./node_modules/@types" 25 | ] 26 | }, 27 | "exclude": [ 28 | "node_modules", 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /examples/http-basic-lambda/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http-basic-lambda" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda_http = { path = "../../lambda-http" } 8 | lambda_runtime = { path = "../../lambda-runtime" } 9 | tokio = { version = "1", features = ["macros"] } 10 | -------------------------------------------------------------------------------- /examples/http-basic-lambda/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 8 | 9 | ## Build for ARM 64 10 | 11 | Build the function with `cargo lambda build --release --arm64` 12 | -------------------------------------------------------------------------------- /examples/http-basic-lambda/src/main.rs: -------------------------------------------------------------------------------- 1 | use lambda_http::{run, service_fn, tracing, Body, Error, Request, Response}; 2 | 3 | /// This is the main body for the function. 4 | /// Write your code inside it. 5 | /// There are some code examples in the Runtime repository: 6 | /// - 7 | async fn function_handler(_event: Request) -> Result, Error> { 8 | // Extract some useful information from the request 9 | 10 | // Return something that implements IntoResponse. 11 | // It will be serialized to the right response event automatically by the runtime 12 | let resp = Response::builder() 13 | .status(200) 14 | .header("content-type", "text/html") 15 | .body("Hello AWS Lambda HTTP request".into()) 16 | .map_err(Box::new)?; 17 | Ok(resp) 18 | } 19 | 20 | #[tokio::main] 21 | async fn main() -> Result<(), Error> { 22 | // required to enable CloudWatch error logging by the runtime 23 | tracing::init_default_subscriber(); 24 | 25 | run(service_fn(function_handler)).await 26 | } 27 | -------------------------------------------------------------------------------- /examples/http-cors/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http-cors" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda_http = { path = "../../lambda-http" } 8 | lambda_runtime = { path = "../../lambda-runtime" } 9 | tokio = { version = "1", features = ["macros"] } 10 | tower-http = { version = "0.5", features = ["cors"] } 11 | -------------------------------------------------------------------------------- /examples/http-cors/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 8 | 9 | ## Build for ARM 64 10 | 11 | Build the function with `cargo lambda build --release --arm64` 12 | -------------------------------------------------------------------------------- /examples/http-cors/src/main.rs: -------------------------------------------------------------------------------- 1 | use lambda_http::{ 2 | http::Method, service_fn, tower::ServiceBuilder, tracing, Body, Error, IntoResponse, Request, RequestExt, Response, 3 | }; 4 | use tower_http::cors::{Any, CorsLayer}; 5 | 6 | #[tokio::main] 7 | async fn main() -> Result<(), Error> { 8 | // required to enable CloudWatch error logging by the runtime 9 | tracing::init_default_subscriber(); 10 | 11 | // Define a layer to inject CORS headers 12 | let cors_layer = CorsLayer::new() 13 | .allow_methods(vec![Method::GET, Method::POST]) 14 | .allow_origin(Any); 15 | 16 | let handler = ServiceBuilder::new() 17 | // Add the CORS layer to the service 18 | .layer(cors_layer) 19 | .service(service_fn(func)); 20 | 21 | lambda_http::run(handler).await?; 22 | Ok(()) 23 | } 24 | 25 | async fn func(event: Request) -> Result, Error> { 26 | Ok( 27 | match event 28 | .query_string_parameters_ref() 29 | .and_then(|params| params.first("first_name")) 30 | { 31 | Some(first_name) => format!("Hello, {}!", first_name).into_response().await, 32 | None => Response::builder() 33 | .status(400) 34 | .body("Empty first name".into()) 35 | .expect("failed to render response"), 36 | }, 37 | ) 38 | } 39 | -------------------------------------------------------------------------------- /examples/http-dynamodb/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http-dynamodb" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | simple-error = "0.3.0" 8 | serde_json = "1.0.107" 9 | serde = { version = "1.0.189", features = ["derive"] } 10 | serde_dynamo = {version = "^4.2.7", features = ["aws-sdk-dynamodb+0_33"]} 11 | lambda_http = { path = "../../lambda-http" } 12 | aws-sdk-dynamodb = "0.33.0" 13 | aws-config = "0.56.1" 14 | tokio = { version = "1.33.0", features = ["macros"] } 15 | -------------------------------------------------------------------------------- /examples/http-dynamodb/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 8 | 9 | ## Build for ARM 64 10 | 11 | Build the function with `cargo lambda build --release --arm64` 12 | 13 | Setting up Dynamodb 14 | 15 | 1. Log into your account. 16 | 2. Create a Dynamodb table with the name 'lambda_dyno_example' with the partition key of "username". 17 | 3. Create IAM role with the permissions for Lambda, Cloudwatch and Dynamodb. 18 | -------------------------------------------------------------------------------- /examples/http-query-parameters/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http-query-parameters" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda_http = { path = "../../lambda-http" } 8 | lambda_runtime = { path = "../../lambda-runtime" } 9 | tokio = { version = "1", features = ["macros"] } 10 | -------------------------------------------------------------------------------- /examples/http-query-parameters/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 8 | 9 | ## Build for ARM 64 10 | 11 | Build the function with `cargo lambda build --release --arm64` 12 | -------------------------------------------------------------------------------- /examples/http-query-parameters/src/main.rs: -------------------------------------------------------------------------------- 1 | use lambda_http::{run, service_fn, tracing, Error, IntoResponse, Request, RequestExt, Response}; 2 | 3 | /// This is the main body for the function. 4 | /// Write your code inside it. 5 | /// You can see more examples in Runtime's repository: 6 | /// - 7 | async fn function_handler(event: Request) -> Result { 8 | // Extract some useful information from the request 9 | Ok( 10 | match event 11 | .query_string_parameters_ref() 12 | .and_then(|params| params.first("first_name")) 13 | { 14 | Some(first_name) => format!("Hello, {}!", first_name).into_response().await, 15 | None => Response::builder() 16 | .status(400) 17 | .body("Empty first name".into()) 18 | .expect("failed to render response"), 19 | }, 20 | ) 21 | } 22 | 23 | #[tokio::main] 24 | async fn main() -> Result<(), Error> { 25 | // required to enable CloudWatch error logging by the runtime 26 | tracing::init_default_subscriber(); 27 | 28 | run(service_fn(function_handler)).await 29 | } 30 | -------------------------------------------------------------------------------- /examples/http-raw-path/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http-raw-path" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda_http = { path = "../../lambda-http" } 8 | lambda_runtime = { path = "../../lambda-runtime" } 9 | tokio = { version = "1", features = ["macros"] } 10 | -------------------------------------------------------------------------------- /examples/http-raw-path/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 8 | 9 | ## Build for ARM 64 10 | 11 | Build the function with `cargo lambda build --release --arm64` 12 | -------------------------------------------------------------------------------- /examples/http-raw-path/src/main.rs: -------------------------------------------------------------------------------- 1 | use lambda_http::{service_fn, tracing, Error, IntoResponse, Request, RequestExt}; 2 | 3 | #[tokio::main] 4 | async fn main() -> Result<(), Error> { 5 | // required to enable CloudWatch error logging by the runtime 6 | tracing::init_default_subscriber(); 7 | 8 | lambda_http::run(service_fn(func)).await?; 9 | Ok(()) 10 | } 11 | 12 | async fn func(event: Request) -> Result { 13 | let res = format!("The raw path for this request is: {}", event.raw_http_path()) 14 | .into_response() 15 | .await; 16 | 17 | Ok(res) 18 | } 19 | -------------------------------------------------------------------------------- /examples/http-shared-resource/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http-shared-resource" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda_http = { path = "../../lambda-http" } 8 | lambda_runtime = { path = "../../lambda-runtime" } 9 | tokio = { version = "1", features = ["macros"] } 10 | -------------------------------------------------------------------------------- /examples/http-shared-resource/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function example 2 | 3 | ## Build & Deploy 4 | 5 | 1. Install [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda#installation) 6 | 2. Build the function with `cargo lambda build --release` 7 | 3. Deploy the function to AWS Lambda with `cargo lambda deploy --iam-role YOUR_ROLE` 8 | 9 | ## Build for ARM 64 10 | 11 | Build the function with `cargo lambda build --release --arm64` 12 | -------------------------------------------------------------------------------- /examples/http-tower-trace/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http-tower-trace" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda_http = { path = "../../lambda-http" } 8 | lambda_runtime = "0.5.1" 9 | tokio = { version = "1", features = ["macros"] } 10 | tower-http = { version = "0.5", features = ["trace"] } 11 | -------------------------------------------------------------------------------- /examples/http-tower-trace/src/main.rs: -------------------------------------------------------------------------------- 1 | use lambda_http::tracing::{self, Level}; 2 | use lambda_http::{run, tower::ServiceBuilder, Error}; 3 | use lambda_http::{Request, Response}; 4 | use tower_http::trace::{DefaultOnRequest, DefaultOnResponse, TraceLayer}; 5 | 6 | async fn handler(_req: Request) -> Result, Error> { 7 | Ok(Response::new("Success".into())) 8 | } 9 | 10 | #[tokio::main] 11 | async fn main() -> Result<(), Error> { 12 | // required to enable CloudWatch error logging by the runtime 13 | tracing::init_default_subscriber(); 14 | 15 | let layer = TraceLayer::new_for_http() 16 | .on_request(DefaultOnRequest::new().level(Level::INFO)) 17 | .on_response(DefaultOnResponse::new().level(Level::INFO)); 18 | 19 | let service = ServiceBuilder::new().layer(layer).service_fn(handler); 20 | 21 | run(service).await?; 22 | Ok(()) 23 | } 24 | -------------------------------------------------------------------------------- /examples/lambda-rds-iam-auth/.gitignore: -------------------------------------------------------------------------------- 1 | # Rust 2 | debug/ 3 | target/ 4 | 5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 7 | Cargo.lock 8 | 9 | # These are backup files generated by rustfmt 10 | **/*.rs.bk 11 | -------------------------------------------------------------------------------- /examples/lambda-rds-iam-auth/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rds-iam-rust-lambda" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda_runtime = { path = "../../lambda-runtime" } 8 | serde_json = "1.0.120" 9 | aws-config = "1.0.1" 10 | aws-credential-types = "1.0.1" 11 | aws-sigv4 = "1.0.1" 12 | url = "2.5.0" 13 | tokio = { version = "1.25.0", features = ["full"] } 14 | sqlx = { version = "0.7.4", features = ["tls-rustls", "postgres", "runtime-tokio"] } 15 | -------------------------------------------------------------------------------- /examples/lambda-rds-iam-auth/cdk/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Function that uses RDS's IAM Authnetication 2 | This example shows how to build and deploy Rust Lambda Function and an RDS instance using AWS CDK and 3 | 4 | Build & Deploy 5 | 1. `npm install` 6 | 1. `npx cdk deploy` 7 | 1. Using the dev instance or using a local Postgres client: connect into the RDS instance as root and create the required Users with permissions `CREATE USER lambda; GRANT rds_iam TO lambda;` 8 | 1. Go to the Lambda Function in the AWS console and invoke the lambda function -------------------------------------------------------------------------------- /examples/lambda-rds-iam-auth/cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node --prefer-ts-exts app.ts", 3 | "watch": { 4 | "include": [ 5 | "**.js", 6 | "**.rs", 7 | "**.ts" 8 | ], 9 | "exclude": [ 10 | "README.md", 11 | "cdk*.json", 12 | "**/*.d.ts", 13 | "**/*.js", 14 | "tsconfig.json", 15 | "package*.json", 16 | "yarn.lock", 17 | "node_modules", 18 | "test" 19 | ] 20 | } 21 | } -------------------------------------------------------------------------------- /examples/lambda-rds-iam-auth/cdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@cdklabs/aws-lambda-rust": "0.0.4", 4 | "aws-cdk-lib": "^2.147.0", 5 | "path": "^0.12.7", 6 | "prettier": "^3.3.2", 7 | "rust.aws-cdk-lambda": "^1.2.1", 8 | "ts-node": "^10.9.2" 9 | }, 10 | "devDependencies": { 11 | "@types/node": "^20.14.10" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/lambda-rds-iam-auth/cdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2020", 7 | "dom" 8 | ], 9 | "declaration": true, 10 | "strict": true, 11 | "noImplicitAny": true, 12 | "strictNullChecks": true, 13 | "noImplicitThis": true, 14 | "alwaysStrict": true, 15 | "noUnusedLocals": false, 16 | "noUnusedParameters": false, 17 | "noImplicitReturns": true, 18 | "noFallthroughCasesInSwitch": false, 19 | "inlineSourceMap": true, 20 | "inlineSources": true, 21 | "experimentalDecorators": true, 22 | "strictPropertyInitialization": false, 23 | "typeRoots": [ 24 | "./node_modules/@types" 25 | ] 26 | }, 27 | "exclude": [ 28 | "node_modules", 29 | "cdk.out" 30 | ] 31 | } -------------------------------------------------------------------------------- /examples/opentelemetry-tracing/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "opentelemetry-tracing" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | lambda_runtime = { path = "../../lambda-runtime", features = ["opentelemetry"] } 8 | opentelemetry-semantic-conventions = "0.14" 9 | opentelemetry = "0.22" 10 | opentelemetry_sdk = { version = "0.22", features = ["rt-tokio"] } 11 | opentelemetry-stdout = { version = "0.3", features = ["trace"] } 12 | pin-project = "1" 13 | serde_json = "1.0" 14 | tokio = "1" 15 | tower = "0.5" 16 | tracing = "0.1" 17 | tracing-opentelemetry = "0.23" 18 | tracing-subscriber = "0.3" 19 | -------------------------------------------------------------------------------- /lambda-events/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Sam Rijs and Christian Legnitto 4 | Copyright 2023 Amazon.com, Inc. or its affiliates 5 | 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /lambda-events/src/encodings/mod.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | use std::ops::{Deref, DerefMut}; 3 | 4 | #[cfg(feature = "chrono")] 5 | mod time; 6 | use crate::custom_serde::{deserialize_base64, serialize_base64}; 7 | 8 | #[cfg(feature = "chrono")] 9 | #[cfg_attr(docsrs, doc(cfg(feature = "chrono")))] 10 | pub use self::time::*; 11 | #[cfg(feature = "http")] 12 | mod http; 13 | #[cfg(feature = "http")] 14 | #[cfg_attr(docsrs, doc(cfg(feature = "http")))] 15 | pub use self::http::*; 16 | 17 | pub type Error = Box; 18 | 19 | /// Binary data encoded in base64. 20 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 21 | pub struct Base64Data( 22 | #[serde(deserialize_with = "deserialize_base64")] 23 | #[serde(serialize_with = "serialize_base64")] 24 | pub Vec, 25 | ); 26 | 27 | impl Deref for Base64Data { 28 | type Target = Vec; 29 | 30 | fn deref(&self) -> &Self::Target { 31 | &self.0 32 | } 33 | } 34 | 35 | impl DerefMut for Base64Data { 36 | fn deref_mut(&mut self) -> &mut Self::Target { 37 | &mut self.0 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lambda-events/src/event/cloudwatch_events/codedeploy.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 4 | #[serde(rename_all = "camelCase")] 5 | pub struct StateChangeNotification { 6 | pub instance_group_id: String, 7 | pub region: String, 8 | pub application: String, 9 | pub deployment_id: String, 10 | pub state: String, 11 | pub deployment_group: String, 12 | } 13 | 14 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 15 | #[serde(rename_all = "camelCase")] 16 | pub struct DeploymentStateChangeNotification { 17 | pub instance_id: String, 18 | pub region: String, 19 | pub state: String, 20 | pub application: String, 21 | pub deployment_id: String, 22 | pub instance_group_id: String, 23 | pub deployment_group: String, 24 | } 25 | 26 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 27 | #[serde(rename_all = "camelCase")] 28 | pub struct InstanceStateChangeNotification { 29 | pub pipeline: String, 30 | pub version: String, 31 | pub state: String, 32 | #[serde(rename = "execution-id")] 33 | pub execution_id: String, 34 | } 35 | -------------------------------------------------------------------------------- /lambda-events/src/event/cloudwatch_events/ec2.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 4 | #[serde(rename_all = "camelCase")] 5 | pub struct InstanceStateChange { 6 | #[serde(rename = "instance-id")] 7 | pub instance_id: String, 8 | pub state: String, 9 | } 10 | -------------------------------------------------------------------------------- /lambda-events/src/event/cloudwatch_events/health.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | use std::collections::HashMap; 3 | 4 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 5 | #[serde(rename_all = "camelCase")] 6 | pub struct Event { 7 | pub event_arn: String, 8 | pub service: String, 9 | pub event_type_code: String, 10 | pub event_type_category: String, 11 | pub start_time: String, 12 | pub end_time: String, 13 | pub event_description: Vec, 14 | pub affected_entities: Option>, 15 | } 16 | 17 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 18 | #[serde(rename_all = "camelCase")] 19 | pub struct EventDescription { 20 | pub language: String, 21 | pub latest_description: String, 22 | } 23 | 24 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 25 | #[serde(rename_all = "camelCase")] 26 | pub struct Entity { 27 | pub entity_value: String, 28 | pub tags: HashMap, 29 | } 30 | -------------------------------------------------------------------------------- /lambda-events/src/event/cloudwatch_events/kms.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 4 | #[serde(rename_all = "camelCase")] 5 | pub struct CMKEvent { 6 | #[serde(rename = "key-id")] 7 | pub key_id: String, 8 | } 9 | -------------------------------------------------------------------------------- /lambda-events/src/event/cloudwatch_events/sms.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 4 | #[serde(rename_all = "camelCase")] 5 | pub struct JobStateChange { 6 | pub state: String, 7 | #[serde(rename = "replication-run-id")] 8 | pub replication_run_id: String, 9 | #[serde(rename = "replication-job-id")] 10 | pub replication_job_id: String, 11 | #[serde(rename = "ami-id")] 12 | pub ami_id: Option, 13 | pub version: String, 14 | } 15 | -------------------------------------------------------------------------------- /lambda-events/src/event/cloudwatch_events/tag.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use serde::{Deserialize, Serialize}; 4 | 5 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 6 | #[serde(rename_all = "camelCase")] 7 | pub struct TagChangeOnResource { 8 | #[serde(rename = "changed-tag-keys")] 9 | pub changed_tag_keys: Vec, 10 | pub service: String, 11 | #[serde(rename = "resource-type")] 12 | pub resource_type: String, 13 | pub version: i64, 14 | pub tags: HashMap, 15 | } 16 | -------------------------------------------------------------------------------- /lambda-events/src/event/cloudwatch_events/trustedadvisor.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | use std::collections::HashMap; 3 | 4 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 5 | #[serde(rename_all = "camelCase")] 6 | pub struct CheckItemRefreshNotification { 7 | #[serde(rename = "check-name")] 8 | pub check_name: String, 9 | #[serde(rename = "check-item-detail")] 10 | pub check_item_detail: HashMap, 11 | pub status: String, 12 | #[serde(rename = "resource_id")] 13 | pub resource_id: String, 14 | pub uuid: String, 15 | } 16 | -------------------------------------------------------------------------------- /lambda-events/src/event/documentdb/events/commom_types.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use serde::{Deserialize, Serialize}; 4 | use serde_json::Value; 5 | 6 | pub type AnyDocument = HashMap; 7 | 8 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 9 | #[serde(rename_all = "camelCase")] 10 | pub struct DatabaseCollection { 11 | db: String, 12 | #[serde(default)] 13 | coll: Option, 14 | } 15 | 16 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 17 | pub struct DocumentId { 18 | #[serde(rename = "_data")] 19 | pub data: String, 20 | } 21 | 22 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 23 | pub struct DocumentKeyIdOid { 24 | #[serde(rename = "$oid")] 25 | pub oid: String, 26 | } 27 | 28 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 29 | pub struct DocumentKeyId { 30 | #[serde(rename = "_id")] 31 | pub id: DocumentKeyIdOid, 32 | } 33 | 34 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 35 | pub struct InnerTimestamp { 36 | t: usize, 37 | i: usize, 38 | } 39 | 40 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 41 | pub struct Timestamp { 42 | #[serde(rename = "$timestamp")] 43 | pub timestamp: InnerTimestamp, 44 | } 45 | -------------------------------------------------------------------------------- /lambda-events/src/event/documentdb/events/delete_event.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | use super::commom_types::{AnyDocument, DatabaseCollection, DocumentId, DocumentKeyId, Timestamp}; 4 | 5 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 6 | #[serde(rename_all = "camelCase")] 7 | pub struct ChangeDeleteEvent { 8 | #[serde(rename = "_id")] 9 | id: DocumentId, 10 | #[serde(default)] 11 | cluster_time: Option, 12 | document_key: DocumentKeyId, 13 | #[serde(default)] 14 | #[serde(rename = "lsid")] 15 | ls_id: Option, 16 | ns: DatabaseCollection, 17 | // operation_type: String, 18 | #[serde(default)] 19 | txn_number: Option, 20 | } 21 | -------------------------------------------------------------------------------- /lambda-events/src/event/documentdb/events/drop_database_event.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | use super::commom_types::{AnyDocument, DatabaseCollection, DocumentId, Timestamp}; 4 | 5 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 6 | #[serde(rename_all = "camelCase")] 7 | pub struct ChangeDropDatabaseEvent { 8 | #[serde(rename = "_id")] 9 | id: DocumentId, 10 | #[serde(default)] 11 | cluster_time: Option, 12 | #[serde(default)] 13 | #[serde(rename = "lsid")] 14 | ls_id: Option, 15 | ns: DatabaseCollection, 16 | // operation_type: String, 17 | #[serde(default)] 18 | txn_number: Option, 19 | } 20 | -------------------------------------------------------------------------------- /lambda-events/src/event/documentdb/events/drop_event.rs: -------------------------------------------------------------------------------- 1 | use super::commom_types::{AnyDocument, DatabaseCollection, DocumentId, Timestamp}; 2 | use serde::{Deserialize, Serialize}; 3 | 4 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 5 | #[serde(rename_all = "camelCase")] 6 | pub struct ChangeDropEvent { 7 | #[serde(rename = "_id")] 8 | id: DocumentId, 9 | #[serde(default)] 10 | cluster_time: Option, 11 | #[serde(default)] 12 | #[serde(rename = "lsid")] 13 | ls_id: Option, 14 | ns: DatabaseCollection, 15 | // operation_type: String, 16 | #[serde(default)] 17 | txn_number: Option, 18 | } 19 | -------------------------------------------------------------------------------- /lambda-events/src/event/documentdb/events/insert_event.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | use super::commom_types::{AnyDocument, DatabaseCollection, DocumentId, DocumentKeyId, Timestamp}; 4 | 5 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 6 | #[serde(rename_all = "camelCase")] 7 | pub struct ChangeInsertEvent { 8 | #[serde(rename = "_id")] 9 | id: DocumentId, 10 | #[serde(default)] 11 | cluster_time: Option, 12 | document_key: DocumentKeyId, 13 | #[serde(default)] 14 | #[serde(rename = "lsid")] 15 | ls_id: Option, 16 | ns: DatabaseCollection, 17 | //operation_type: String, 18 | #[serde(default)] 19 | txn_number: Option, 20 | } 21 | -------------------------------------------------------------------------------- /lambda-events/src/event/documentdb/events/invalidate_event.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | use super::commom_types::{DocumentId, Timestamp}; 4 | 5 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 6 | #[serde(rename_all = "camelCase")] 7 | pub struct ChangeInvalidateEvent { 8 | #[serde(rename = "_id")] 9 | id: DocumentId, 10 | #[serde(default)] 11 | cluster_time: Option, 12 | // operation_type: String, 13 | } 14 | -------------------------------------------------------------------------------- /lambda-events/src/event/documentdb/events/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod commom_types; 2 | pub mod delete_event; 3 | pub mod drop_database_event; 4 | pub mod drop_event; 5 | pub mod insert_event; 6 | pub mod invalidate_event; 7 | pub mod rename_event; 8 | pub mod replace_event; 9 | pub mod update_event; 10 | -------------------------------------------------------------------------------- /lambda-events/src/event/documentdb/events/rename_event.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | use super::commom_types::{AnyDocument, DatabaseCollection, DocumentId, Timestamp}; 4 | 5 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 6 | #[serde(rename_all = "camelCase")] 7 | pub struct ChangeRenameEvent { 8 | #[serde(rename = "_id")] 9 | id: DocumentId, 10 | #[serde(default)] 11 | cluster_time: Option, 12 | 13 | #[serde(default)] 14 | #[serde(rename = "lsid")] 15 | ls_id: Option, 16 | ns: DatabaseCollection, 17 | //operation_type: String, 18 | #[serde(default)] 19 | txn_number: Option, 20 | to: DatabaseCollection, 21 | } 22 | -------------------------------------------------------------------------------- /lambda-events/src/event/documentdb/events/replace_event.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | use super::commom_types::{AnyDocument, DatabaseCollection, DocumentId, DocumentKeyId, Timestamp}; 4 | 5 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 6 | #[serde(rename_all = "camelCase")] 7 | pub struct ChangeReplaceEvent { 8 | #[serde(rename = "_id")] 9 | id: DocumentId, 10 | #[serde(default)] 11 | cluster_time: Option, 12 | document_key: DocumentKeyId, 13 | #[serde(default)] 14 | #[serde(rename = "lsid")] 15 | ls_id: Option, 16 | ns: DatabaseCollection, 17 | // operation_type: String, 18 | #[serde(default)] 19 | txn_number: Option, 20 | } 21 | -------------------------------------------------------------------------------- /lambda-events/src/event/documentdb/events/update_event.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | use super::commom_types::{AnyDocument, DatabaseCollection, DocumentId, DocumentKeyId, Timestamp}; 4 | 5 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 6 | #[serde(rename_all = "camelCase")] 7 | pub struct UpdateTruncate { 8 | field: String, 9 | new_size: usize, 10 | } 11 | 12 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 13 | #[serde(rename_all = "camelCase")] 14 | pub struct UpdateDescription { 15 | removed_fields: Vec, 16 | truncated_arrays: Vec, 17 | updated_fields: AnyDocument, 18 | } 19 | 20 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 21 | #[serde(rename_all = "camelCase")] 22 | pub struct ChangeUpdateEvent { 23 | #[serde(rename = "_id")] 24 | id: DocumentId, 25 | #[serde(default)] 26 | cluster_time: Option, 27 | document_key: DocumentKeyId, 28 | #[serde(default)] 29 | #[serde(rename = "lsid")] 30 | ls_id: Option, 31 | ns: DatabaseCollection, 32 | // operation_type: String, 33 | update_description: UpdateDescription, 34 | #[serde(default)] 35 | txn_number: Option, 36 | } 37 | -------------------------------------------------------------------------------- /lambda-events/src/event/iot_button/mod.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | #[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)] 4 | #[serde(rename_all = "camelCase")] 5 | pub struct IoTButtonEvent { 6 | #[serde(default)] 7 | pub serial_number: Option, 8 | #[serde(default)] 9 | pub click_type: Option, 10 | #[serde(default)] 11 | pub battery_voltage: Option, 12 | } 13 | 14 | #[cfg(test)] 15 | mod test { 16 | use super::*; 17 | 18 | #[test] 19 | #[cfg(feature = "iot_button")] 20 | fn example_iot_button_event() { 21 | let data = include_bytes!("../../fixtures/example-iot_button-event.json"); 22 | let parsed: IoTButtonEvent = serde_json::from_slice(data).unwrap(); 23 | let output: String = serde_json::to_string(&parsed).unwrap(); 24 | let reparsed: IoTButtonEvent = serde_json::from_slice(output.as_bytes()).unwrap(); 25 | assert_eq!(parsed, reparsed); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lambda-events/src/event/kinesis/analytics.rs: -------------------------------------------------------------------------------- 1 | use crate::encodings::Base64Data; 2 | use serde::{Deserialize, Serialize}; 3 | 4 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 5 | #[serde(rename_all = "camelCase")] 6 | pub struct KinesisAnalyticsOutputDeliveryEvent { 7 | #[serde(default)] 8 | pub invocation_id: Option, 9 | #[serde(default)] 10 | pub application_arn: Option, 11 | pub records: Vec, 12 | } 13 | 14 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 15 | #[serde(rename_all = "camelCase")] 16 | pub struct KinesisAnalyticsOutputDeliveryEventRecord { 17 | #[serde(default)] 18 | pub record_id: Option, 19 | pub data: Base64Data, 20 | } 21 | 22 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 23 | #[serde(rename_all = "camelCase")] 24 | pub struct KinesisAnalyticsOutputDeliveryResponse { 25 | pub records: Vec, 26 | } 27 | 28 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] 29 | #[serde(rename_all = "camelCase")] 30 | pub struct KinesisAnalyticsOutputDeliveryResponseRecord { 31 | #[serde(default)] 32 | pub record_id: Option, 33 | /// possible values include Ok and DeliveryFailed 34 | #[serde(default)] 35 | pub result: Option, 36 | } 37 | -------------------------------------------------------------------------------- /lambda-events/src/event/kinesis/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod analytics; 2 | mod event; 3 | pub use self::event::*; 4 | -------------------------------------------------------------------------------- /lambda-events/src/event/s3/mod.rs: -------------------------------------------------------------------------------- 1 | mod event; 2 | pub use self::event::*; 3 | 4 | pub mod batch_job; 5 | pub mod object_lambda; 6 | -------------------------------------------------------------------------------- /lambda-events/src/event/secretsmanager/mod.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | #[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)] 4 | #[serde(rename_all = "PascalCase")] 5 | pub struct SecretsManagerSecretRotationEvent { 6 | pub step: String, 7 | pub secret_id: String, 8 | pub client_request_token: String, 9 | } 10 | 11 | #[cfg(test)] 12 | mod test { 13 | use super::*; 14 | 15 | #[test] 16 | #[cfg(feature = "secretsmanager")] 17 | fn example_secretsmanager_secret_rotation_event() { 18 | let data = include_bytes!("../../fixtures/example-secretsmanager-secret-rotation-event.json"); 19 | let parsed: SecretsManagerSecretRotationEvent = serde_json::from_slice(data).unwrap(); 20 | let output: String = serde_json::to_string(&parsed).unwrap(); 21 | let reparsed: SecretsManagerSecretRotationEvent = serde_json::from_slice(output.as_bytes()).unwrap(); 22 | assert_eq!(parsed, reparsed); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-activemq-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSource": "aws:mq", 3 | "eventSourceArn": "arn:aws:mq:us-west-2:533019413397:broker:shask-test:b-0f5b7522-2b41-4f85-a615-735a4e6d96b5", 4 | "messages": [ 5 | { 6 | "messageID": "ID:b-0f5b7522-2b41-4f85-a615-735a4e6d96b5-2.mq.us-west-2.amazonaws.com-34859-1598944546501-4:12:1:1:3", 7 | "messageType": "jms/text-message", 8 | "timestamp": 1599863938941, 9 | "deliveryMode": 1, 10 | "correlationID": "", 11 | "replyTo": "null", 12 | "destination": { 13 | "physicalName": "testQueue" 14 | }, 15 | "redelivered": false, 16 | "type": "", 17 | "expiration": 0, 18 | "priority": 0, 19 | "data": "RW50ZXIgc29tZSB0ZXh0IGhlcmUgZm9yIHRoZSBtZXNzYWdlIGJvZHkuLi4=", 20 | "brokerInTime": 1599863938943, 21 | "brokerOutTime": 1599863938944, 22 | "properties": {"testKey": "testValue"} 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-alb-lambda-target-request-headers-only.json: -------------------------------------------------------------------------------- 1 | { 2 | "requestContext": { 3 | "elb": { 4 | "targetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/lambda-target/abcdefg" 5 | } 6 | }, 7 | "httpMethod": "GET", 8 | "path": "/", 9 | "queryStringParameters": { 10 | "key": "hello" 11 | }, 12 | "headers": { 13 | "accept": "*/*", 14 | "connection": "keep-alive", 15 | "host": "lambda-test-alb-1334523864.us-east-1.elb.amazonaws.com", 16 | "user-agent": "curl/7.54.0", 17 | "x-amzn-trace-id": "Root=1-5c34e93e-4dea0086f9763ac0667b115a", 18 | "x-forwarded-for": "25.12.198.67", 19 | "x-forwarded-port": "80", 20 | "x-forwarded-proto": "http", 21 | "x-imforwards": "20", 22 | "x-myheader": "123" 23 | }, 24 | "isBase64Encoded": false 25 | } 26 | 27 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-alb-lambda-target-request-multivalue-headers.json: -------------------------------------------------------------------------------- 1 | { 2 | "requestContext": { 3 | "elb": { 4 | "targetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/lambda-target/abcdefgh" 5 | } 6 | }, 7 | "httpMethod": "GET", 8 | "path": "/", 9 | "multiValueQueryStringParameters": { 10 | "key": [ 11 | "hello" 12 | ] 13 | }, 14 | "multiValueHeaders": { 15 | "accept": [ 16 | "*/*" 17 | ], 18 | "connection": [ 19 | "keep-alive" 20 | ], 21 | "host": [ 22 | "lambda-test-alb-1234567.us-east-1.elb.amazonaws.com" 23 | ], 24 | "user-agent": [ 25 | "curl/7.54.0" 26 | ], 27 | "x-amzn-trace-id": [ 28 | "Root=1-5c34e7d4-00ca239424b68028d4c56d68" 29 | ], 30 | "x-forwarded-for": [ 31 | "72.21.198.67" 32 | ], 33 | "x-forwarded-port": [ 34 | "80" 35 | ], 36 | "x-forwarded-proto": [ 37 | "http" 38 | ], 39 | "x-imforwards": [ 40 | "20" 41 | ], 42 | "x-myheader": [ 43 | "123" 44 | ] 45 | }, 46 | "body": "Some text", 47 | "isBase64Encoded": false 48 | } 49 | 50 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-alb-lambda-target-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "isBase64Encoded": false, 3 | "statusCode": 200, 4 | "statusDescription": "200 OK", 5 | "headers": { 6 | "Set-cookie": "cookies", 7 | "Content-Type": "application/json" 8 | }, 9 | "multiValueHeaders": { 10 | "Set-cookie": ["cookie-name=cookie-value;Domain=myweb.com;Secure;HttpOnly","cookie-name=cookie-value;Expires=May 8, 2019"], 11 | "Content-Type": ["application/json"] 12 | }, 13 | "body": "Hello from Lambda" 14 | } 15 | 16 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-apigw-custom-auth-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "type":"TOKEN", 3 | "authorizationToken":"allow", 4 | "methodArn":"arn:aws:execute-api:us-west-2:123456789012:ymy8tbxw7b/*/GET/" 5 | } 6 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-apigw-custom-auth-response-with-condition.json: -------------------------------------------------------------------------------- 1 | { 2 | "principalId": "yyyyyyyy", 3 | "policyDocument": { 4 | "Version": "2012-10-17", 5 | "Statement": [ 6 | { 7 | "Action": [ 8 | "execute-api:Invoke" 9 | ], 10 | "Effect": "Deny", 11 | "Resource": [ 12 | "arn:aws:execute-api:{regionId}:{accountId}:{appId}/{stage}/{httpVerb}/[{resource}/[child-resources]]" 13 | ], 14 | "Condition": { 15 | "StringEquals": { 16 | "aws:SourceIp": [ 17 | "xxx" 18 | ] 19 | } 20 | } 21 | } 22 | ] 23 | }, 24 | "context": { 25 | "stringKey": "value", 26 | "numberKey": "1", 27 | "booleanKey": "true" 28 | }, 29 | "usageIdentifierKey": "{api-key}" 30 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-apigw-custom-auth-response-with-single-value-action.json: -------------------------------------------------------------------------------- 1 | { 2 | "principalId": "yyyyyyyy", 3 | "policyDocument": { 4 | "Version": "2012-10-17", 5 | "Statement": [ 6 | { 7 | "Action": "execute-api:Invoke", 8 | "Effect": "Allow", 9 | "Resource": ["arn:aws:execute-api:{regionId}:{accountId}:{appId}/{stage}/{httpVerb}/[{resource}/[child-resources]]"] 10 | } 11 | ] 12 | }, 13 | "context": { 14 | "stringKey": "value", 15 | "numberKey": "1", 16 | "booleanKey": "true" 17 | }, 18 | "usageIdentifierKey": "{api-key}" 19 | } 20 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-apigw-custom-auth-response-with-single-value-resource.json: -------------------------------------------------------------------------------- 1 | { 2 | "principalId": "yyyyyyyy", 3 | "policyDocument": { 4 | "Version": "2012-10-17", 5 | "Statement": [ 6 | { 7 | "Action": ["execute-api:Invoke"], 8 | "Effect": "Allow", 9 | "Resource": "arn:aws:execute-api:{regionId}:{accountId}:{appId}/{stage}/{httpVerb}/[{resource}/[child-resources]]" 10 | } 11 | ] 12 | }, 13 | "context": { 14 | "stringKey": "value", 15 | "numberKey": "1", 16 | "booleanKey": "true" 17 | }, 18 | "usageIdentifierKey": "{api-key}" 19 | } 20 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-apigw-custom-auth-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "principalId": "yyyyyyyy", 3 | "policyDocument": { 4 | "Version": "2012-10-17", 5 | "Statement": [ 6 | { 7 | "Action": [ 8 | "execute-api:Invoke" 9 | ], 10 | "Effect": "Deny", 11 | "Resource": [ 12 | "arn:aws:execute-api:{regionId}:{accountId}:{appId}/{stage}/{httpVerb}/[{resource}/[child-resources]]" 13 | ] 14 | } 15 | ] 16 | }, 17 | "context": { 18 | "stringKey": "value", 19 | "numberKey": "1", 20 | "booleanKey": "true" 21 | }, 22 | "usageIdentifierKey": "{api-key}" 23 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-apigw-websocket-request-disconnect-route.json: -------------------------------------------------------------------------------- 1 | { 2 | "headers": { 3 | "Host": "abcd1234.execute-api.us-east-1.amazonaws.com", 4 | "x-api-key": "", 5 | "X-Forwarded-For": "", 6 | "x-restapi": "" 7 | }, 8 | "multiValueHeaders": { 9 | "Host": [ "abcd1234.execute-api.us-east-1.amazonaws.com" ], 10 | "x-api-key": [ "" ], 11 | "X-Forwarded-For": [ "" ], 12 | "x-restapi": [ "" ] 13 | }, 14 | "requestContext": { 15 | "routeKey": "$disconnect", 16 | "disconnectStatusCode": 1005, 17 | "eventType": "DISCONNECT", 18 | "extendedRequestId": "ABCD1234=", 19 | "requestTime": "09/Feb/2024:18:23:28 +0000", 20 | "messageDirection": "IN", 21 | "disconnectReason": "Client-side close frame status not set", 22 | "stage": "prod", 23 | "connectedAt": 1707503007396, 24 | "requestTimeEpoch": 1707503008941, 25 | "identity": { "sourceIp": "192.0.2.1" }, 26 | "requestId": "ABCD1234=", 27 | "domainName": "abcd1234.execute-api.us-east-1.amazonaws.com", 28 | "connectionId": "AAAA1234=", 29 | "apiId": "abcd1234" 30 | }, 31 | "isBase64Encoded": false 32 | } 33 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-appsync-batchinvoke.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2017-02-28", 3 | "operation": "BatchInvoke", 4 | "payload": [{ 5 | "arguments": { 6 | "id": "postId1", 7 | "count": 1, 8 | "float": 1.2, 9 | "flag": true 10 | } 11 | }, 12 | { 13 | "arguments": { 14 | "id": "postId2", 15 | "count": 2, 16 | "float": 1.2 17 | } 18 | }, 19 | { 20 | "arguments": { 21 | "id": "postId3", 22 | "count": 3, 23 | "flag": false 24 | } 25 | } 26 | ] 27 | } 28 | 29 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-appsync-identity-cognito.json: -------------------------------------------------------------------------------- 1 | { 2 | "sub": "123-456", 3 | "issuer": "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_abc", 4 | "username": "user1", 5 | "claims": { 6 | "sub": "123-456", 7 | "aud": "abcdefg", 8 | "event_id": "123-123-123", 9 | "token_use": "id", 10 | "auth_time": 1551226125, 11 | "iss": "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_abc", 12 | "cognito:username": "user1", 13 | "exp": 1551228178628, 14 | "iat": 1551228178629 15 | }, 16 | "sourceIp": ["192.168.196.186", "193.168.196.186"], 17 | "defaultAuthStrategy": "ALLOW" 18 | } 19 | 20 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-appsync-identity-iam.json: -------------------------------------------------------------------------------- 1 | { 2 | "accountId": "accountid123", 3 | "cognitoIdentityPoolId": "identitypoolid123", 4 | "cognitoIdentityId": "identityid123", 5 | "cognitoIdentityAuthType": "authenticated", 6 | "cognitoIdentityAuthProvider": "providerABC", 7 | "sourceIp": ["192.168.196.186", "193.168.196.186"], 8 | "username": "user1", 9 | "userArn": "arn:aws:iam::123456789012:user/appsync" 10 | } 11 | 12 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-appsync-invoke.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2017-02-28", 3 | "operation": "Invoke", 4 | "payload": { 5 | "field": "getPost", 6 | "arguments": { 7 | "id": "postId1", 8 | "count": 1, 9 | "float": 1.2, 10 | "flag": true 11 | } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-appsync-lambda-auth-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "authorizationToken": "ExampleAUTHtoken123123123", 3 | "requestContext": { 4 | "apiId": "aaaaaa123123123example123", 5 | "accountId": "111122223333", 6 | "requestId": "f4081827-1111-4444-5555-5cf4695f339f", 7 | "queryString": "mutation CreateEvent {...}\n\nquery MyQuery {...}\n", 8 | "operationName": "MyQuery", 9 | "variables": {} 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-appsync-lambda-auth-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "isAuthorized": true, 3 | "resolverContext": { 4 | "banana": "very yellow", 5 | "apple": "very green" 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-autoscaling-event-launch-successful.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "12345678-1234-1234-1234-123456789012", 4 | "detail-type": "EC2 Instance Launch Successful", 5 | "source": "aws.autoscaling", 6 | "account": "123456789012", 7 | "time": "1970-01-01T00:00:00Z", 8 | "region": "us-west-2", 9 | "resources": [ 10 | "auto-scaling-group-arn", 11 | "instance-arn" 12 | ], 13 | "detail": { 14 | "StatusCode": "InProgress", 15 | "Description": "Launching a new EC2 instance: i-12345678", 16 | "AutoScalingGroupName": "my-auto-scaling-group", 17 | "ActivityId": "87654321-4321-4321-4321-210987654321", 18 | "Details": { 19 | "Availability Zone": "us-west-2b", 20 | "Subnet ID": "subnet-12345678" 21 | }, 22 | "RequestId": "12345678-1234-1234-1234-123456789012", 23 | "StatusMessage": "", 24 | "EndTime": "1970-01-01T00:00:00Z", 25 | "EC2InstanceId": "i-1234567890abcdef0", 26 | "StartTime": "1970-01-01T00:00:00Z", 27 | "Cause": "description-text" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-autoscaling-event-launch-unsuccessful.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "12345678-1234-1234-1234-123456789012", 4 | "detail-type": "EC2 Instance Launch Unsuccessful", 5 | "source": "aws.autoscaling", 6 | "account": "123456789012", 7 | "time": "1970-01-01T00:00:00Z", 8 | "region": "us-west-2", 9 | "resources": [ 10 | "auto-scaling-group-arn", 11 | "instance-arn" 12 | ], 13 | "detail": { 14 | "StatusCode": "Failed", 15 | "AutoScalingGroupName": "my-auto-scaling-group", 16 | "ActivityId": "87654321-4321-4321-4321-210987654321", 17 | "Details": { 18 | "Availability Zone": "us-west-2b", 19 | "Subnet ID": "subnet-12345678" 20 | }, 21 | "RequestId": "12345678-1234-1234-1234-123456789012", 22 | "StatusMessage": "message-text", 23 | "EndTime": "1970-01-01T00:00:00Z", 24 | "EC2InstanceId": "i-1234567890abcdef0", 25 | "StartTime": "1970-01-01T00:00:00Z", 26 | "Cause": "description-text" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-autoscaling-event-lifecycle-action.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "12345678-1234-1234-1234-123456789012", 4 | "detail-type": "EC2 Instance-launch Lifecycle Action", 5 | "source": "aws.autoscaling", 6 | "account": "123456789012", 7 | "time": "1970-01-01T00:00:00Z", 8 | "region": "us-west-2", 9 | "resources": [ 10 | "auto-scaling-group-arn" 11 | ], 12 | "detail": { 13 | "LifecycleActionToken": "87654321-4321-4321-4321-210987654321", 14 | "AutoScalingGroupName": "my-asg", 15 | "LifecycleHookName": "my-lifecycle-hook", 16 | "EC2InstanceId": "i-1234567890abcdef0", 17 | "LifecycleTransition": "autoscaling:EC2_INSTANCE_LAUNCHING", 18 | "NotificationMetadata": "additional-info" 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-autoscaling-event-terminate-action.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "12345678-1234-1234-1234-123456789012", 4 | "detail-type": "EC2 Instance-terminate Lifecycle Action", 5 | "source": "aws.autoscaling", 6 | "account": "123456789012", 7 | "time": "1970-01-01T00:00:00Z", 8 | "region": "us-west-2", 9 | "resources": [ 10 | "auto-scaling-group-arn" 11 | ], 12 | "detail": { 13 | "LifecycleActionToken":"87654321-4321-4321-4321-210987654321", 14 | "AutoScalingGroupName":"my-asg", 15 | "LifecycleHookName":"my-lifecycle-hook", 16 | "EC2InstanceId":"i-1234567890abcdef0", 17 | "LifecycleTransition":"autoscaling:EC2_INSTANCE_TERMINATING" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-autoscaling-event-terminate-successful.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "12345678-1234-1234-1234-123456789012", 4 | "detail-type": "EC2 Instance Terminate Successful", 5 | "source": "aws.autoscaling", 6 | "account": "123456789012", 7 | "time": "1970-01-01T00:00:00Z", 8 | "region": "us-west-2", 9 | "resources": [ 10 | "auto-scaling-group-arn", 11 | "instance-arn" 12 | ], 13 | "detail": { 14 | "StatusCode": "InProgress", 15 | "Description": "Terminating EC2 instance: i-12345678", 16 | "AutoScalingGroupName": "my-auto-scaling-group", 17 | "ActivityId": "87654321-4321-4321-4321-210987654321", 18 | "Details": { 19 | "Availability Zone": "us-west-2b", 20 | "Subnet ID": "subnet-12345678" 21 | }, 22 | "RequestId": "12345678-1234-1234-1234-123456789012", 23 | "StatusMessage": "", 24 | "EndTime": "1970-01-01T00:00:00Z", 25 | "EC2InstanceId": "i-1234567890abcdef0", 26 | "StartTime": "1970-01-01T00:00:00Z", 27 | "Cause": "description-text" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-autoscaling-event-terminate-unsuccessful.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "12345678-1234-1234-1234-123456789012", 4 | "detail-type": "EC2 Instance Terminate Unsuccessful", 5 | "source": "aws.autoscaling", 6 | "account": "123456789012", 7 | "time": "1970-01-01T00:00:00Z", 8 | "region": "us-west-2", 9 | "resources": [ 10 | "auto-scaling-group-arn", 11 | "instance-arn" 12 | ], 13 | "detail": { 14 | "StatusCode": "Failed", 15 | "AutoScalingGroupName": "my-auto-scaling-group", 16 | "ActivityId": "87654321-4321-4321-4321-210987654321", 17 | "Details": { 18 | "Availability Zone": "us-west-2b", 19 | "Subnet ID": "subnet-12345678" 20 | }, 21 | "RequestId": "12345678-1234-1234-1234-123456789012", 22 | "StatusMessage": "message-text", 23 | "EndTime": "1970-01-01T00:00:00Z", 24 | "EC2InstanceId": "i-1234567890abcdef0", 25 | "StartTime": "1970-01-01T00:00:00Z", 26 | "Cause": "description-text" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-bedrock-agent-runtime-event-without-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "messageVersion": "1.0", 3 | "agent": { 4 | "name": "AgentName", 5 | "id": "AgentID", 6 | "alias": "AgentAlias", 7 | "version": "AgentVersion" 8 | }, 9 | "inputText": "InputText", 10 | "sessionId": "SessionID", 11 | "actionGroup": "ActionGroup", 12 | "apiPath": "/api/path", 13 | "httpMethod": "POST", 14 | "requestBody": { 15 | "content": { 16 | "application/json": { 17 | "properties": [ 18 | { 19 | "name": "prop1", 20 | "type": "string", 21 | "value": "value1" 22 | } 23 | ] 24 | } 25 | } 26 | }, 27 | "sessionAttributes": { 28 | "attr1": "value1" 29 | }, 30 | "promptSessionAttributes": { 31 | "promptAttr1": "value1" 32 | } 33 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-bedrock-agent-runtime-event-without-request-body.json: -------------------------------------------------------------------------------- 1 | { 2 | "messageVersion": "1.0", 3 | "agent": { 4 | "name": "AgentName", 5 | "id": "AgentID", 6 | "alias": "AgentAlias", 7 | "version": "AgentVersion" 8 | }, 9 | "inputText": "InputText", 10 | "sessionId": "SessionID", 11 | "actionGroup": "ActionGroup", 12 | "apiPath": "/api/path", 13 | "httpMethod": "POST", 14 | "parameters": [ 15 | { 16 | "name": "param1", 17 | "type": "string", 18 | "value": "value1" 19 | } 20 | ], 21 | "sessionAttributes": { 22 | "attr1": "value1" 23 | }, 24 | "promptSessionAttributes": { 25 | "promptAttr1": "value1" 26 | } 27 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-bedrock-agent-runtime-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "messageVersion": "1.0", 3 | "agent": { 4 | "name": "AgentName", 5 | "id": "AgentID", 6 | "alias": "AgentAlias", 7 | "version": "AgentVersion" 8 | }, 9 | "inputText": "InputText", 10 | "sessionId": "SessionID", 11 | "actionGroup": "ActionGroup", 12 | "apiPath": "/api/path", 13 | "httpMethod": "POST", 14 | "parameters": [ 15 | { 16 | "name": "param1", 17 | "type": "string", 18 | "value": "value1" 19 | } 20 | ], 21 | "requestBody": { 22 | "content": { 23 | "application/json": { 24 | "properties": [ 25 | { 26 | "name": "prop1", 27 | "type": "string", 28 | "value": "value1" 29 | } 30 | ] 31 | } 32 | } 33 | }, 34 | "sessionAttributes": { 35 | "attr1": "value1" 36 | }, 37 | "promptSessionAttributes": { 38 | "promptAttr1": "value1" 39 | } 40 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-clientvpn-connectionhandler-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "connection-id": "cvpn-connection-04e7e1b2f0daf9460", 3 | "endpoint-id": "cvpn-endpoint-0f13eab7f860433cc", 4 | "common-name": "", 5 | "username": "username", 6 | "platform": "", 7 | "platform-version": "", 8 | "public-ip": "10.11.12.13", 9 | "client-openvpn-version": "", 10 | "schema-version": "v1" 11 | } 12 | 13 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cloudformation-custom-resource-create-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "ServiceToken": "arn:aws:lambda:eu-west-2:123456789012:function:custom-resource-handler", 3 | "RequestType" : "Create", 4 | "RequestId" : "82304eb2-bdda-469f-a33b-a3f1406d0a52", 5 | "ResponseURL": "https://cr-response-bucket.s3.us-east-1.amazonaws.com/cr-response-key?sig-params=sig-values", 6 | "StackId" : "arn:aws:cloudformation:us-east-1:123456789012:stack/stack-name/16580499-7622-4a9c-b32f-4eba35da93da", 7 | "ResourceType" : "Custom::MyCustomResourceType", 8 | "LogicalResourceId" : "CustomResource", 9 | "ResourceProperties" : { 10 | "Key1" : "string", 11 | "Key2" : [ "list" ], 12 | "Key3" : { "Key4" : "map" } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cloudformation-custom-resource-delete-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "ServiceToken": "arn:aws:lambda:eu-west-2:123456789012:function:custom-resource-handler", 3 | "RequestType" : "Delete", 4 | "RequestId" : "ef70561d-d4ba-42a4-801b-33ad88dafc37", 5 | "ResponseURL": "https://cr-response-bucket.s3.us-east-1.amazonaws.com/cr-response-key?sig-params=sig-values", 6 | "StackId" : "arn:aws:cloudformation:us-east-1:123456789012:stack/stack-name/16580499-7622-4a9c-b32f-4eba35da93da", 7 | "ResourceType" : "Custom::MyCustomResourceType", 8 | "LogicalResourceId" : "CustomResource", 9 | "PhysicalResourceId" : "custom-resource-f4bd5382-3de3-4caf-b7ad-1be06b899647", 10 | "ResourceProperties" : { 11 | "Key1" : "string", 12 | "Key2" : [ "list" ], 13 | "Key3" : { "Key4" : "map" } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cloudformation-custom-resource-provider-create-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "RequestType" : "Create", 3 | "RequestId" : "82304eb2-bdda-469f-a33b-a3f1406d0a52", 4 | "StackId" : "arn:aws:cloudformation:us-east-1:123456789012:stack/stack-name/16580499-7622-4a9c-b32f-4eba35da93da", 5 | "ResourceType" : "Custom::MyCustomResourceType", 6 | "LogicalResourceId" : "CustomResource", 7 | "ResourceProperties" : { 8 | "Key1" : "string", 9 | "Key2" : [ "list" ], 10 | "Key3" : { "Key4" : "map" } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cloudformation-custom-resource-provider-delete-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "RequestType" : "Delete", 3 | "RequestId" : "ef70561d-d4ba-42a4-801b-33ad88dafc37", 4 | "StackId" : "arn:aws:cloudformation:us-east-1:123456789012:stack/stack-name/16580499-7622-4a9c-b32f-4eba35da93da", 5 | "ResourceType" : "Custom::MyCustomResourceType", 6 | "LogicalResourceId" : "CustomResource", 7 | "PhysicalResourceId" : "custom-resource-f4bd5382-3de3-4caf-b7ad-1be06b899647", 8 | "ResourceProperties" : { 9 | "Key1" : "string", 10 | "Key2" : [ "list" ], 11 | "Key3" : { "Key4" : "map" } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cloudformation-custom-resource-provider-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "PhysicalResourceId": "custom-resource-f4bd5382-3de3-4caf-b7ad-1be06b899647", 3 | "NoEcho": false, 4 | "Data": { 5 | "Key1": "a", 6 | "Key2": "b", 7 | "Key3": "c" 8 | } 9 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cloudformation-custom-resource-provider-update-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "RequestType" : "Update", 3 | "RequestId" : "49347ca5-c603-44e5-a34b-10cf1854a887", 4 | "StackId" : "arn:aws:cloudformation:us-east-1:123456789012:stack/stack-name/16580499-7622-4a9c-b32f-4eba35da93da", 5 | "ResourceType" : "Custom::MyCustomResourceType", 6 | "LogicalResourceId" : "CustomResource", 7 | "PhysicalResourceId" : "custom-resource-f4bd5382-3de3-4caf-b7ad-1be06b899647", 8 | "ResourceProperties" : { 9 | "Key1" : "new-string", 10 | "Key2" : [ "new-list" ], 11 | "Key3" : { "Key4" : "new-map" } 12 | }, 13 | "OldResourceProperties" : { 14 | "Key1" : "string", 15 | "Key2" : [ "list" ], 16 | "Key3" : { "Key4" : "map" } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cloudformation-custom-resource-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "Status": "FAILED", 3 | "Reason": "This is a test failure.", 4 | "PhysicalResourceId": "custom-resource-f4bd5382-3de3-4caf-b7ad-1be06b899647", 5 | "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/stack-name/16580499-7622-4a9c-b32f-4eba35da93da", 6 | "RequestId": "49347ca5-c603-44e5-a34b-10cf1854a887", 7 | "LogicalResourceId": "CustomResource", 8 | "NoEcho": false, 9 | "Data": { 10 | "Key1": "a", 11 | "Key2": "b", 12 | "Key3": "c" 13 | } 14 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cloudformation-custom-resource-update-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "ServiceToken": "arn:aws:lambda:eu-west-2:123456789012:function:custom-resource-handler", 3 | "RequestType" : "Update", 4 | "RequestId" : "49347ca5-c603-44e5-a34b-10cf1854a887", 5 | "ResponseURL": "https://cr-response-bucket.s3.us-east-1.amazonaws.com/cr-response-key?sig-params=sig-values", 6 | "StackId" : "arn:aws:cloudformation:us-east-1:123456789012:stack/stack-name/16580499-7622-4a9c-b32f-4eba35da93da", 7 | "ResourceType" : "Custom::MyCustomResourceType", 8 | "LogicalResourceId" : "CustomResource", 9 | "PhysicalResourceId" : "custom-resource-f4bd5382-3de3-4caf-b7ad-1be06b899647", 10 | "ResourceProperties" : { 11 | "Key1" : "new-string", 12 | "Key2" : [ "new-list" ], 13 | "Key3" : { "Key4" : "new-map" } 14 | }, 15 | "OldResourceProperties" : { 16 | "Key1" : "string", 17 | "Key2" : [ "list" ], 18 | "Key3" : { "Key4" : "map" } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cloudwatch-cloudtrail-unknown-federate.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventVersion": "1.08", 3 | "userIdentity": { 4 | "type": "Unknown", 5 | "principalId": "00000000-0000-0000-0000-000000000000", 6 | "accountId": "123456789000", 7 | "userName": "me@dev.com" 8 | }, 9 | "eventTime": "2024-07-10T18:41:56Z", 10 | "eventSource": "sso.amazonaws.com", 11 | "eventName": "Federate", 12 | "awsRegion": "eu-west-1", 13 | "sourceIPAddress": "1.1.1.1", 14 | "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36", 15 | "requestParameters": null, 16 | "responseElements": null, 17 | "requestID": "00000000-0000-0000-0000-000000000000", 18 | "eventID": "00000000-0000-0000-0000-000000000000", 19 | "readOnly": false, 20 | "eventType": "AwsServiceEvent", 21 | "managementEvent": true, 22 | "recipientAccountId": "123456789000", 23 | "serviceEventDetails": { 24 | "relayId": "00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000" 25 | }, 26 | "eventCategory": "Management" 27 | } 28 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cloudwatch-cloudtrail-unknown-user-auth.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventVersion": "1.08", 3 | "userIdentity": { 4 | "type": "Unknown", 5 | "principalId": "123456789000", 6 | "arn": "", 7 | "accountId": "123456789000", 8 | "accessKeyId": "" 9 | }, 10 | "eventTime": "2024-07-10T16:05:11Z", 11 | "eventSource": "signin.amazonaws.com", 12 | "eventName": "UserAuthentication", 13 | "awsRegion": "eu-west-1", 14 | "sourceIPAddress": "1.1.1.1", 15 | "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36", 16 | "requestParameters": null, 17 | "responseElements": null, 18 | "additionalEventData": { 19 | "AuthWorkflowID": "00000000-0000-0000-0000-000000000000", 20 | "LoginTo": "https://tenant.awsapps.com/start/", 21 | "CredentialType": "EXTERNAL_IDP" 22 | }, 23 | "requestID": "00000000-0000-0000-0000-000000000000", 24 | "eventID": "00000000-0000-0000-0000-000000000000", 25 | "readOnly": false, 26 | "eventType": "AwsServiceEvent", 27 | "managementEvent": true, 28 | "recipientAccountId": "123456789000", 29 | "serviceEventDetails": { 30 | "UserAuthentication": "Success" 31 | }, 32 | "eventCategory": "Management" 33 | } 34 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cloudwatch_logs-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "awslogs": { 3 | "data": "H4sIAAAAAAAAAHWPwQqCQBCGX0Xm7EFtK+smZBEUgXoLCdMhFtKV3akI8d0bLYmibvPPN3wz00CJxmQnTO41whwWQRIctmEcB6sQbFC3CjW3XW8kxpOpP+OC22d1Wml1qZkQGtoMsScxaczKN3plG8zlaHIta5KqWsozoTYw3/djzwhpLwivWFGHGpAFe7DL68JlBUk+l7KSN7tCOEJ4M3/qOI49vMHj+zCKdlFqLaU2ZHV2a4Ct/an0/ivdX8oYc1UVX860fQDQiMdxRQEAAA==" 4 | } 5 | } 6 | 7 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-code_commit-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "eventId": "5a824061-17ca-46a9-bbf9-114edeadbeef", 5 | "eventVersion": "1.0", 6 | "eventTime": "2018-01-26T15:58:33.475+0000", 7 | "eventTriggerName": "my-trigger", 8 | "eventPartNumber": 1, 9 | "codecommit": { 10 | "references": [ 11 | { 12 | "commit": "5c4ef1049f1d27deadbeeff313e0730018be182b", 13 | "ref": "refs/heads/master" 14 | } 15 | ] 16 | }, 17 | "eventName": "TriggerEventTest", 18 | "eventTriggerConfigId": "5a824061-17ca-46a9-bbf9-114edeadbeef", 19 | "eventSourceARN": "arn:aws:codecommit:us-east-1:123456789012:my-repo", 20 | "userIdentityARN": "arn:aws:iam::123456789012:root", 21 | "eventSource": "aws:codecommit", 22 | "awsRegion": "us-east-1", 23 | "eventTotalParts": 1 24 | } 25 | ] 26 | } 27 | 28 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-codedeploy-deployment-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "account": "123456789012", 3 | "region": "us-east-1", 4 | "detail-type": "CodeDeploy Deployment State-change Notification", 5 | "source": "aws.codedeploy", 6 | "version": "0", 7 | "time": "2016-06-30T22:06:31Z", 8 | "id": "c071bfbf-83c4-49ca-a6ff-3df053957145", 9 | "resources": [ 10 | "arn:aws:codedeploy:us-east-1:123456789012:application:myApplication", 11 | "arn:aws:codedeploy:us-east-1:123456789012:deploymentgroup:myApplication/myDeploymentGroup" 12 | ], 13 | "detail": { 14 | "instanceGroupId": "9fd2fbef-2157-40d8-91e7-6845af69e2d2", 15 | "region": "us-east-1", 16 | "application": "myApplication", 17 | "deploymentId": "d-123456789", 18 | "state": "SUCCESS", 19 | "deploymentGroup": "myDeploymentGroup" 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-codedeploy-instance-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "account": "123456789012", 3 | "region": "us-east-1", 4 | "detail-type": "CodeDeploy Instance State-change Notification", 5 | "source": "aws.codedeploy", 6 | "version": "0", 7 | "time": "2016-06-30T23:18:50Z", 8 | "id": "fb1d3015-c091-4bf9-95e2-d98521ab2ecb", 9 | "resources": [ 10 | "arn:aws:ec2:us-east-1:123456789012:instance/i-0000000aaaaaaaaaa", 11 | "arn:aws:codedeploy:us-east-1:123456789012:deploymentgroup:myApplication/myDeploymentGroup", 12 | "arn:aws:codedeploy:us-east-1:123456789012:application:myApplication" 13 | ], 14 | "detail": { 15 | "instanceId": "i-0000000aaaaaaaaaa", 16 | "region": "us-east-1", 17 | "state": "SUCCESS", 18 | "application": "myApplication", 19 | "deploymentId": "d-123456789", 20 | "instanceGroupId": "8cd3bfa8-9e72-4cbe-a1e5-da4efc7efd49", 21 | "deploymentGroup": "myDeploymentGroup" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-codedeploy-lifecycle-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "DeploymentId": "d-deploymentId", 3 | "LifecycleEventHookExecutionId": "eyJlbmNyeXB0ZWREYXRhIjoiY3VHU2NjdkJXUTJQUENVd2dkYUNGRVg0dWlpME9UWVdHTVhZcDRXVW5LYUVKc21EaUFPMkNLNXMwMWFrNDlYVStlbXdRb29xS3NJTUNVQ3RYRGFZSXc1VTFwUllvMDhmMzdlbDZFeDVVdjZrNFc0eU5waGh6YTRvdkNWcmVveVR6OWdERlM2SmlIYW1TZz09IiwiaXZQYXJhbWV0ZXJTcGVjIjoiTm1ZNFR6RzZxQVhHamhhLyIsIm1hdGVyaWFsU2V0U2VyaWFsIjoxfQ==" 4 | } 5 | 6 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-codepipeline-action-execution-stage-change-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "CWE-event-id", 4 | "detail-type": "CodePipeline Action Execution State Change", 5 | "source": "aws.codepipeline", 6 | "account": "123456789012", 7 | "time": "2017-04-22T03:31:47Z", 8 | "region": "us-east-1", 9 | "resources": [ 10 | "arn:aws:codepipeline:us-east-1:123456789012:pipeline:myPipeline" 11 | ], 12 | "detail": { 13 | "pipeline": "myPipeline", 14 | "version": 1, 15 | "execution-id": "01234567-0123-0123-0123-012345678901", 16 | "stage": "Prod", 17 | "action": "myAction", 18 | "state": "STARTED", 19 | "region":"us-west-2", 20 | "type": { 21 | "owner": "AWS", 22 | "category": "Deploy", 23 | "provider": "CodeDeploy", 24 | "version": 1 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-codepipeline-execution-stage-change-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "CWE-event-id", 4 | "detail-type": "CodePipeline Stage Execution State Change", 5 | "source": "aws.codepipeline", 6 | "account": "123456789012", 7 | "time": "2017-04-22T03:31:47Z", 8 | "region": "us-east-1", 9 | "resources": [ 10 | "arn:aws:codepipeline:us-east-1:123456789012:pipeline:myPipeline" 11 | ], 12 | "detail": { 13 | "pipeline": "myPipeline", 14 | "version": 1, 15 | "state": "STARTED", 16 | "execution-id": "01234567-0123-0123-0123-012345678901" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-codepipeline-execution-state-change-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "CWE-event-id", 4 | "detail-type": "CodePipeline Pipeline Execution State Change", 5 | "source": "aws.codepipeline", 6 | "account": "123456789012", 7 | "time": "2017-04-22T03:31:47Z", 8 | "region": "us-east-1", 9 | "resources": [ 10 | "arn:aws:codepipeline:us-east-1:123456789012:pipeline:myPipeline" 11 | ], 12 | "detail": { 13 | "pipeline": "myPipeline", 14 | "version": 1, 15 | "state": "STARTED", 16 | "execution-id": "01234567-0123-0123-0123-012345678901" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-create-auth-challenge-user-not-found.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "region": "us-west-2", 4 | "userPoolId": "", 5 | "userName": "", 6 | "callerContext": { 7 | "awsSdkVersion": "aws-sdk-unknown-unknown", 8 | "clientId": "" 9 | }, 10 | "triggerSource": "CreateAuthChallenge_Authentication", 11 | "request": { 12 | "userAttributes": { 13 | "sub": "", 14 | "cognito:user_status": "CONFIRMED", 15 | "phone_number_verified": "true", 16 | "cognito:phone_number_alias": "+12223334455", 17 | "phone_number": "+12223334455" 18 | }, 19 | "challengeName": "CUSTOM_CHALLENGE", 20 | "session": [ 21 | { 22 | "challengeName": "PASSWORD_VERIFIER", 23 | "challengeResult": true, 24 | "challengeMetadata": "metadata" 25 | } 26 | ], 27 | "clientMetadata": { 28 | "exampleMetadataKey": "example metadata value" 29 | }, 30 | "userNotFound": true 31 | }, 32 | "response": { 33 | "publicChallengeParameters": { 34 | "a": "b" 35 | }, 36 | "privateChallengeParameters": { 37 | "c": "d" 38 | }, 39 | "challengeMetadata": "challengeMetadata" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-create-auth-challenge.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "region": "us-west-2", 4 | "userPoolId": "", 5 | "userName": "", 6 | "callerContext": { 7 | "awsSdkVersion": "aws-sdk-unknown-unknown", 8 | "clientId": "" 9 | }, 10 | "triggerSource": "CreateAuthChallenge_Authentication", 11 | "request": { 12 | "userAttributes": { 13 | "sub": "", 14 | "cognito:user_status": "CONFIRMED", 15 | "phone_number_verified": "true", 16 | "cognito:phone_number_alias": "+12223334455", 17 | "phone_number": "+12223334455" 18 | }, 19 | "challengeName": "CUSTOM_CHALLENGE", 20 | "session": [ 21 | { 22 | "challengeName": "PASSWORD_VERIFIER", 23 | "challengeResult": true, 24 | "challengeMetadata": "metadata" 25 | } 26 | ], 27 | "clientMetadata": { 28 | "exampleMetadataKey": "example metadata value" 29 | }, 30 | "userNotFound": false 31 | }, 32 | "response": { 33 | "publicChallengeParameters": { 34 | "a": "b" 35 | }, 36 | "privateChallengeParameters": { 37 | "c": "d" 38 | }, 39 | "challengeMetadata": "challengeMetadata" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-custommessage.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "triggerSource": "CustomMessage_VerifyUserAttribute", 4 | "region": "", 5 | "userPoolId": "", 6 | "userName": "", 7 | "callerContext": { 8 | "awsSdkVersion": "", 9 | "clientId": "" 10 | }, 11 | "request": { 12 | "userAttributes": { 13 | "phone_number_verified": true, 14 | "email_verified": false 15 | }, 16 | "codeParameter": "####", 17 | "usernameParameter": "{username}", 18 | "clientMetadata": { 19 | "exampleMetadataKey": "example metadata value" 20 | } 21 | }, 22 | "response": { 23 | "smsMessage": "", 24 | "emailMessage": "", 25 | "emailSubject": "" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-define-auth-challenge-optional-response-fields.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "region": "us-west-2", 4 | "userPoolId": "", 5 | "userName": "", 6 | "callerContext": { 7 | "awsSdkVersion": "aws-sdk-unknown-unknown", 8 | "clientId": "" 9 | }, 10 | "triggerSource": "DefineAuthChallenge_Authentication", 11 | "request": { 12 | "userAttributes": { 13 | "sub": "", 14 | "cognito:user_status": "CONFIRMED", 15 | "phone_number_verified": "true", 16 | "cognito:phone_number_alias": "+12223334455", 17 | "phone_number": "+12223334455" 18 | }, 19 | "session": [ 20 | { 21 | "challengeName": "PASSWORD_VERIFIER", 22 | "challengeResult": true, 23 | "challengeMetadata": "metadata" 24 | } 25 | ], 26 | "clientMetadata": { 27 | "exampleMetadataKey": "example metadata value" 28 | }, 29 | "userNotFound": false 30 | }, 31 | "response": { 32 | "challengeName": "challengeName" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-define-auth-challenge-user-not-found.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "region": "us-west-2", 4 | "userPoolId": "", 5 | "userName": "", 6 | "callerContext": { 7 | "awsSdkVersion": "aws-sdk-unknown-unknown", 8 | "clientId": "" 9 | }, 10 | "triggerSource": "DefineAuthChallenge_Authentication", 11 | "request": { 12 | "userAttributes": { 13 | "sub": "", 14 | "cognito:user_status": "CONFIRMED", 15 | "phone_number_verified": "true", 16 | "cognito:phone_number_alias": "+12223334455", 17 | "phone_number": "+12223334455" 18 | }, 19 | "session": [ 20 | { 21 | "challengeName": "PASSWORD_VERIFIER", 22 | "challengeResult": true, 23 | "challengeMetadata": "metadata" 24 | } 25 | ], 26 | "clientMetadata": { 27 | "exampleMetadataKey": "example metadata value" 28 | }, 29 | "userNotFound": true 30 | }, 31 | "response": { 32 | "challengeName": "challengeName", 33 | "issueTokens": true, 34 | "failAuthentication": true 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-define-auth-challenge.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "region": "us-west-2", 4 | "userPoolId": "", 5 | "userName": "", 6 | "callerContext": { 7 | "awsSdkVersion": "aws-sdk-unknown-unknown", 8 | "clientId": "" 9 | }, 10 | "triggerSource": "DefineAuthChallenge_Authentication", 11 | "request": { 12 | "userAttributes": { 13 | "sub": "", 14 | "cognito:user_status": "CONFIRMED", 15 | "phone_number_verified": "true", 16 | "cognito:phone_number_alias": "+12223334455", 17 | "phone_number": "+12223334455" 18 | }, 19 | "session": [ 20 | { 21 | "challengeName": "PASSWORD_VERIFIER", 22 | "challengeResult": true, 23 | "challengeMetadata": "metadata" 24 | } 25 | ], 26 | "clientMetadata": { 27 | "exampleMetadataKey": "example metadata value" 28 | }, 29 | "userNotFound": false 30 | }, 31 | "response": { 32 | "challengeName": "challengeName", 33 | "issueTokens": true, 34 | "failAuthentication": true 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-migrateuser.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "triggerSource": "UserMigration_Authentication", 4 | "region": "", 5 | "userPoolId": "", 6 | "userName": "", 7 | "callerContext": { 8 | "awsSdkVersion": "", 9 | "clientId": "" 10 | }, 11 | "request": { 12 | "password": "", 13 | "validationData": { 14 | "exampleMetadataKey": "example metadata value" 15 | }, 16 | "clientMetadata": { 17 | "exampleMetadataKey": "example metadata value" 18 | } 19 | }, 20 | "response": { 21 | "userAttributes": { 22 | "email": "", 23 | "phone_number": "" 24 | }, 25 | "finalUserStatus": "", 26 | "messageAction": "", 27 | "desiredDeliveryMediums": [ 28 | "", 29 | "" 30 | ], 31 | "forceAliasCreation": true 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-postauthentication.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "triggerSource": "PostAuthentication_Authentication", 4 | "region": "", 5 | "userPoolId": "", 6 | "userName": "", 7 | "callerContext": { 8 | "awsSdkVersion": "", 9 | "clientId": "" 10 | }, 11 | "request": { 12 | "newDeviceUsed": true, 13 | "userAttributes" : { 14 | "email": "", 15 | "phone_number": "" 16 | }, 17 | "clientMetadata": { 18 | "exampleMetadataKey": "example metadata value" 19 | } 20 | }, 21 | "response": {} 22 | } 23 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-postconfirmation.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "triggerSource": "PostConfirmation_ConfirmSignUp", 4 | "region": "", 5 | "userPoolId": "", 6 | "userName": "", 7 | "callerContext": { 8 | "awsSdkVersion": "", 9 | "clientId": "" 10 | }, 11 | "request": { 12 | "userAttributes" : { 13 | "email": "", 14 | "phone_number": "" 15 | }, 16 | "clientMetadata": { 17 | "exampleMetadataKey": "example metadata value" 18 | } 19 | }, 20 | "response": {} 21 | } 22 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-preauthentication.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "triggerSource": "PreAuthentication_Authentication", 4 | "region": "", 5 | "userPoolId": "", 6 | "userName": "", 7 | "callerContext": { 8 | "awsSdkVersion": "", 9 | "clientId": "" 10 | }, 11 | "request": { 12 | "userAttributes": { 13 | "email": "" 14 | }, 15 | "validationData": { 16 | "k1": "v1", 17 | "k2": "v2" 18 | } 19 | }, 20 | "response": {} 21 | } 22 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-presignup.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "triggerSource": "PreSignUp_SignUp", 4 | "region": "", 5 | "userPoolId": "", 6 | "userName": "", 7 | "callerContext": { 8 | "awsSdkVersion": "", 9 | "clientId": "" 10 | }, 11 | "request": { 12 | "userAttributes": { 13 | "email": "", 14 | "phone_number": "" 15 | }, 16 | "validationData": { 17 | "k1": "v1", 18 | "k2": "v2" 19 | }, 20 | "clientMetadata": { 21 | "exampleMetadataKey": "example metadata value" 22 | } 23 | }, 24 | "response": { 25 | "autoConfirmUser": false, 26 | "autoVerifyEmail": true, 27 | "autoVerifyPhone": true 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-pretokengen-incoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "triggerSource": "TokenGeneration_Authentication", 4 | "region": "region", 5 | "userPoolId": "userPoolId", 6 | "userName": "userName", 7 | "callerContext": { 8 | "awsSdkVersion": "calling aws sdk with version", 9 | "clientId": "apps client id" 10 | }, 11 | "request": { 12 | "userAttributes": { 13 | "email": "email", 14 | "phone_number": "phone_number" 15 | }, 16 | "groupConfiguration": { 17 | "groupsToOverride": ["group-A", "group-B", "group-C"], 18 | "iamRolesToOverride": [ 19 | "arn:aws:iam::XXXXXXXXXXXX:role/sns_callerA", 20 | "arn:aws:iam::XXXXXXXXX:role/sns_callerB", 21 | "arn:aws:iam::XXXXXXXXXX:role/sns_callerC" 22 | ], 23 | "preferredRole": "arn:aws:iam::XXXXXXXXXXX:role/sns_caller" 24 | }, 25 | "clientMetadata": { 26 | "exampleMetadataKey": "example metadata value" 27 | } 28 | }, 29 | "response": { 30 | "claimsOverrideDetails": null 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-pretokengen-v2-incoming.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "triggerSource": "TokenGeneration_HostedAuth", 4 | "region": "region", 5 | "userPoolId": "userPoolId", 6 | "userName": "userName", 7 | "callerContext": { 8 | "awsSdkVersion": "calling aws sdk with version", 9 | "clientId": "apps client id" 10 | }, 11 | "request": { 12 | "userAttributes": { 13 | "email": "email", 14 | "phone_number": "phone_number" 15 | }, 16 | "scopes": ["scope-1", "scope-2"], 17 | "groupConfiguration": { 18 | "groupsToOverride": ["group-A", "group-B", "group-C"], 19 | "iamRolesToOverride": [ 20 | "arn:aws:iam::XXXXXXXXXXXX:role/sns_callerA", 21 | "arn:aws:iam::XXXXXXXXX:role/sns_callerB", 22 | "arn:aws:iam::XXXXXXXXXX:role/sns_callerC" 23 | ], 24 | "preferredRole": "arn:aws:iam::XXXXXXXXXXX:role/sns_caller" 25 | }, 26 | "clientMetadata": { 27 | "exampleMetadataKey": "example metadata value" 28 | } 29 | }, 30 | "response": { 31 | "claimsOverrideDetails": null 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-verify-auth-challenge-null-answer-correct.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "region": "us-west-2", 4 | "userPoolId": "", 5 | "userName": "", 6 | "callerContext": { 7 | "awsSdkVersion": "aws-sdk-unknown-unknown", 8 | "clientId": "" 9 | }, 10 | "triggerSource": "VerifyAuthChallengeResponse_Authentication", 11 | "request": { 12 | "userAttributes": { 13 | "sub": "", 14 | "cognito:user_status": "CONFIRMED", 15 | "phone_number_verified": "true", 16 | "cognito:phone_number_alias": "+12223334455", 17 | "phone_number": "+12223334455" 18 | }, 19 | "privateChallengeParameters": { 20 | "secret": "11122233" 21 | }, 22 | "challengeAnswer": "123xxxx", 23 | "clientMetadata": { 24 | "exampleMetadataKey": "example metadata value" 25 | }, 26 | "userNotFound": false 27 | }, 28 | "response": { 29 | "answerCorrect": null 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-verify-auth-challenge-optional-answer-correct.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "region": "us-west-2", 4 | "userPoolId": "", 5 | "userName": "", 6 | "callerContext": { 7 | "awsSdkVersion": "aws-sdk-unknown-unknown", 8 | "clientId": "" 9 | }, 10 | "triggerSource": "VerifyAuthChallengeResponse_Authentication", 11 | "request": { 12 | "userAttributes": { 13 | "sub": "", 14 | "cognito:user_status": "CONFIRMED", 15 | "phone_number_verified": "true", 16 | "cognito:phone_number_alias": "+12223334455", 17 | "phone_number": "+12223334455" 18 | }, 19 | "privateChallengeParameters": { 20 | "secret": "11122233" 21 | }, 22 | "challengeAnswer": "123xxxx", 23 | "clientMetadata": { 24 | "exampleMetadataKey": "example metadata value" 25 | }, 26 | "userNotFound": false 27 | }, 28 | "response": { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-verify-auth-challenge-user-not-found.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "region": "us-west-2", 4 | "userPoolId": "", 5 | "userName": "", 6 | "callerContext": { 7 | "awsSdkVersion": "aws-sdk-unknown-unknown", 8 | "clientId": "" 9 | }, 10 | "triggerSource": "VerifyAuthChallengeResponse_Authentication", 11 | "request": { 12 | "userAttributes": { 13 | "sub": "", 14 | "cognito:user_status": "CONFIRMED", 15 | "phone_number_verified": "true", 16 | "cognito:phone_number_alias": "+12223334455", 17 | "phone_number": "+12223334455" 18 | }, 19 | "privateChallengeParameters": { 20 | "secret": "11122233" 21 | }, 22 | "challengeAnswer": "123xxxx", 23 | "clientMetadata": { 24 | "exampleMetadataKey": "example metadata value" 25 | }, 26 | "userNotFound": true 27 | }, 28 | "response": { 29 | "answerCorrect": true 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event-userpools-verify-auth-challenge.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "region": "us-west-2", 4 | "userPoolId": "", 5 | "userName": "", 6 | "callerContext": { 7 | "awsSdkVersion": "aws-sdk-unknown-unknown", 8 | "clientId": "" 9 | }, 10 | "triggerSource": "VerifyAuthChallengeResponse_Authentication", 11 | "request": { 12 | "userAttributes": { 13 | "sub": "", 14 | "cognito:user_status": "CONFIRMED", 15 | "phone_number_verified": "true", 16 | "cognito:phone_number_alias": "+12223334455", 17 | "phone_number": "+12223334455" 18 | }, 19 | "privateChallengeParameters": { 20 | "secret": "11122233" 21 | }, 22 | "challengeAnswer": "123xxxx", 23 | "clientMetadata": { 24 | "exampleMetadataKey": "example metadata value" 25 | }, 26 | "userNotFound": false 27 | }, 28 | "response": { 29 | "answerCorrect": true 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-cognito-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "datasetName": "datasetName", 3 | "eventType": "SyncTrigger", 4 | "region": "us-east-1", 5 | "identityId": "identityId", 6 | "datasetRecords": 7 | { 8 | "SampleKey1": 9 | { 10 | "newValue": "newValue1", 11 | "oldValue": "oldValue1", 12 | "op": "replace" 13 | } 14 | }, 15 | "identityPoolId": "identityPoolId", 16 | "version": 2 17 | } 18 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-config-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "configRuleId": "config-rule-0123456", 3 | "version": "1.0", 4 | "configRuleName": "periodic-config-rule", 5 | "configRuleArn": "arn:aws:config:us-east-1:012345678912:config-rule/config-rule-0123456", 6 | "invokingEvent": "{\"configSnapshotId\":\"00000000-0000-0000-0000-000000000000\",\"s3ObjectKey\":\"AWSLogs/000000000000/Config/us-east-1/2016/2/24/ConfigSnapshot/000000000000_Config_us-east-1_ConfigSnapshot_20160224T182319Z_00000000-0000-0000-0000-000000000000.json.gz\",\"s3Bucket\":\"config-bucket\",\"notificationCreationTime\":\"2016-02-24T18:23:20.328Z\",\"messageType\":\"ConfigurationSnapshotDeliveryCompleted\",\"recordVersion\":\"1.1\"}", 7 | "resultToken": "myResultToken", 8 | "eventLeftScope": false, 9 | "ruleParameters": "{\"myParameterKey\":\"myParameterValue\"}", 10 | "executionRoleArn": "arn:aws:iam::012345678912:role/config-role", 11 | "accountId": "012345678912" 12 | } 13 | 14 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-connect-event-without-queue.json: -------------------------------------------------------------------------------- 1 | { 2 | "Name": "ContactFlowExecution", 3 | "Details": { 4 | "Parameters": { 5 | "key1": "value1", 6 | "key2": "value2" 7 | }, 8 | "ContactData": { 9 | "ContactId": "ASDAcxcasDFSSDFs", 10 | "InitialContactId": "Acxsada-asdasdaxA", 11 | "PreviousContactId": "Acxsada-asdasdaxA", 12 | "Channel": "Voice", 13 | "InstanceARN": "", 14 | "InitiationMethod": "INBOUND/OUTBOUND/TRANSFER/CALLBACK", 15 | "SystemEndpoint": { 16 | "Type": "TELEPHONE_NUMBER", 17 | "Address": "01234567" 18 | }, 19 | "CustomerEndpoint": { 20 | "Type": "TELEPHONE_NUMBER", 21 | "Address": "+14802021091" 22 | }, 23 | "Attributes": { 24 | "key1": "value", 25 | "key2": "value" 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-connect-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Name": "ContactFlowExecution", 3 | "Details": { 4 | "Parameters": { 5 | "key1": "value1", 6 | "key2": "value2" 7 | }, 8 | "ContactData": { 9 | "ContactId": "ASDAcxcasDFSSDFs", 10 | "InitialContactId": "Acxsada-asdasdaxA", 11 | "PreviousContactId": "Acxsada-asdasdaxA", 12 | "Channel": "Voice", 13 | "InstanceARN": "", 14 | "InitiationMethod": "INBOUND/OUTBOUND/TRANSFER/CALLBACK", 15 | "SystemEndpoint": { 16 | "Type": "TELEPHONE_NUMBER", 17 | "Address": "01234567" 18 | }, 19 | "CustomerEndpoint": { 20 | "Type": "TELEPHONE_NUMBER", 21 | "Address": "+14802021091" 22 | }, 23 | "Queue": { 24 | "Name": "PrimaryPhoneQueue", 25 | "ARN": "" 26 | }, 27 | "Attributes": { 28 | "key1": "value", 29 | "key2": "value" 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-documentdb-delete-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:canaryclusterb2a659a2-qo5tcmqkcl03", 3 | "events": [ 4 | { 5 | "event": { 6 | "_id": { 7 | "_data": "0163eeb6e7000000090100000009000041e1" 8 | }, 9 | "clusterTime": { 10 | "$timestamp": { 11 | "t": 1676588775, 12 | "i": 9 13 | } 14 | }, 15 | "documentKey": { 16 | "_id": { 17 | "$oid": "63eeb6e7d418cd98afb1c1d7" 18 | } 19 | }, 20 | "ns": { 21 | "db": "test_database", 22 | "coll": "test_collection" 23 | }, 24 | "operationType": "delete" 25 | } 26 | } 27 | ], 28 | "eventSource": "aws:docdb" 29 | } 30 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-documentdb-drop-database-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:canaryclusterb2a659a2-qo5tcmqkcl03", 3 | "events": [ 4 | { 5 | "event": { 6 | "_id": { 7 | "_data": "0163eeb6e7000000090100000009000041e1" 8 | }, 9 | "clusterTime": { 10 | "$timestamp": { 11 | "t": 1676588775, 12 | "i": 9 13 | } 14 | }, 15 | "ns": { 16 | "db": "test_database" 17 | }, 18 | "operationType": "dropDatabase" 19 | } 20 | } 21 | ], 22 | "eventSource": "aws:docdb" 23 | } 24 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-documentdb-drop-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:canaryclusterb2a659a2-qo5tcmqkcl03", 3 | "events": [ 4 | { 5 | "event": { 6 | "_id": { 7 | "_data": "0163eeb6e7000000090100000009000041e1" 8 | }, 9 | "clusterTime": { 10 | "$timestamp": { 11 | "t": 1676588775, 12 | "i": 9 13 | } 14 | }, 15 | "documentKey": { 16 | "_id": { 17 | "$oid": "63eeb6e7d418cd98afb1c1d7" 18 | } 19 | }, 20 | "ns": { 21 | "db": "test_database", 22 | "coll": "test_collection" 23 | }, 24 | "operationType": "drop" 25 | } 26 | } 27 | ], 28 | "eventSource": "aws:docdb" 29 | } 30 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-documentdb-insert-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:canaryclusterb2a659a2-qo5tcmqkcl03", 3 | "events": [ 4 | { 5 | "event": { 6 | "_id": { 7 | "_data": "0163eeb6e7000000090100000009000041e1" 8 | }, 9 | "clusterTime": { 10 | "$timestamp": { 11 | "t": 1676588775, 12 | "i": 9 13 | } 14 | }, 15 | "documentKey": { 16 | "_id": { 17 | "$oid": "63eeb6e7d418cd98afb1c1d7" 18 | } 19 | }, 20 | "ns": { 21 | "db": "test_database", 22 | "coll": "test_collection" 23 | }, 24 | "operationType": "insert" 25 | } 26 | } 27 | ], 28 | "eventSource": "aws:docdb" 29 | } 30 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-documentdb-invalidate-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:canaryclusterb2a659a2-qo5tcmqkcl03", 3 | "events": [ 4 | { 5 | "event": { 6 | "_id": { 7 | "_data": "0163eeb6e7000000090100000009000041e1" 8 | }, 9 | "clusterTime": { 10 | "$timestamp": { 11 | "t": 1676588775, 12 | "i": 9 13 | } 14 | }, 15 | "operationType": "invalidate" 16 | } 17 | } 18 | ], 19 | "eventSource": "aws:docdb" 20 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-documentdb-rename-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:canaryclusterb2a659a2-qo5tcmqkcl03", 3 | "events": [ 4 | { 5 | "event": { 6 | "_id": { 7 | "_data": "0163eeb6e7000000090100000009000041e1" 8 | }, 9 | "clusterTime": { 10 | "$timestamp": { 11 | "t": 1676588775, 12 | "i": 9 13 | } 14 | }, 15 | "documentKey": { 16 | "_id": { 17 | "$oid": "63eeb6e7d418cd98afb1c1d7" 18 | } 19 | }, 20 | "ns": { 21 | "db": "test_database", 22 | "coll": "test_collection" 23 | }, 24 | "to": { 25 | "db": "test_database_new", 26 | "coll": "test_collection_new" 27 | }, 28 | "operationType": "rename" 29 | } 30 | } 31 | ], 32 | "eventSource": "aws:docdb" 33 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-documentdb-replace-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:canaryclusterb2a659a2-qo5tcmqkcl03", 3 | "events": [ 4 | { 5 | "event": { 6 | "_id": { 7 | "_data": "0163eeb6e7000000090100000009000041e1" 8 | }, 9 | "operationType": "replace", 10 | "clusterTime": { 11 | "$timestamp": { 12 | "t": 1676588775, 13 | "i": 9 14 | } 15 | }, 16 | "ns": { 17 | "db": "engineering", 18 | "coll": "users" 19 | }, 20 | "documentKey": { 21 | "_id": { 22 | "$oid": "63eeb6e7d418cd98afb1c1d7" 23 | } 24 | } 25 | } 26 | } 27 | ], 28 | "eventSource": "aws:docdb" 29 | } 30 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-documentdb-update-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:canaryclusterb2a659a2-qo5tcmqkcl03", 3 | "events": [ 4 | { 5 | "event": { 6 | "_id": { 7 | "_data": "0163eeb6e7000000090100000009000041e1" 8 | }, 9 | "operationType": "update", 10 | "clusterTime": { 11 | "$timestamp": { 12 | "t": 1676588775, 13 | "i": 9 14 | } 15 | }, 16 | "ns": { 17 | "db": "test_database", 18 | "coll": "test_collection" 19 | }, 20 | "documentKey": { 21 | "_id": { 22 | "$oid": "63eeb6e7d418cd98afb1c1d7" 23 | } 24 | }, 25 | "updateDescription": { 26 | "updatedFields": { 27 | "email": "alice@10gen.com" 28 | }, 29 | "removedFields": [ 30 | "phoneNumber" 31 | ], 32 | "truncatedArrays": [ 33 | { 34 | "field": "vacation_time", 35 | "newSize": 36 36 | } 37 | ] 38 | } 39 | } 40 | } 41 | ], 42 | "eventSource": "aws:docdb" 43 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-dynamodb-event-record-with-optional-fields.json: -------------------------------------------------------------------------------- 1 | { 2 | "awsRegion":"eu-west-1", 3 | "eventID":"00000000-0000-0000-0000-000000000000", 4 | "eventName":"INSERT", 5 | "userIdentity":null, 6 | "recordFormat":"application/json", 7 | "tableName":"examples", 8 | "dynamodb":{ 9 | "Keys":{ 10 | "id":{ 11 | "S":"00000000-0000-0000-0000-000000000000" 12 | } 13 | }, 14 | "NewImage":{ 15 | "id":{ 16 | "S":"00000000-0000-0000-0000-000000000000" 17 | }, 18 | "created":{ 19 | "S":"2022-02-16T15:12:00.14Z" 20 | } 21 | }, 22 | "SizeBytes":292 23 | }, 24 | "eventSource":"aws:dynamodb" 25 | } 26 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-ecr-image-scan-event-with-missing-severities.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "85fc3613-e913-7fc4-a80c-a3753e4aa9ae", 4 | "detail-type": "ECR Image Scan", 5 | "source": "aws.ecr", 6 | "account": "123456789012", 7 | "time": "2019-10-29T02:36:48Z", 8 | "region": "us-east-1", 9 | "resources": [ 10 | "arn:aws:ecr:us-east-1:123456789012:repository/my-repository-name" 11 | ], 12 | "detail": { 13 | "scan-status": "COMPLETE", 14 | "repository-name": "my-repository-name", 15 | "finding-severity-counts": { 16 | "CRITICAL": 10, 17 | "MEDIUM": 9 18 | }, 19 | "image-digest": "sha256:7f5b2640fe6fb4f46592dfd3410c4a79dac4f89e4782432e0378abcd1234", 20 | "image-tags": [] 21 | } 22 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-ecr-image-scan-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "01234567-0123-0123-0123-012345678901", 4 | "detail-type": "ECR Image Scan", 5 | "source": "aws.ecr", 6 | "account": "123456789012", 7 | "time": "2019-10-30T21:32:27Z", 8 | "region": "eu-north-1", 9 | "resources": ["arn:aws:ecr:eu-north-1:123456789012:repository/tribble-image-scan-test"], 10 | "detail": { 11 | "scan-status": "COMPLETE", 12 | "repository-name": "tribble-image-scan-test", 13 | "finding-severity-counts": { 14 | "CRITICAL": 10, 15 | "HIGH": 2, 16 | "MEDIUM": 9, 17 | "LOW": 3, 18 | "INFORMATIONAL": 0, 19 | "UNDEFINED": 0 20 | }, 21 | "image-digest": "sha256:d4a96ee9443e641fc100e763a0c10928720b50c6e3ea3342d05d7c3435fc5355", 22 | "image-tags": ["1572471135"] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-eventbridge-event-obj.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "7bf73129-1428-4cd3-a780-95db273d1602", 3 | "detail-type": "EC2 Instance State-change Notification", 4 | "source": "aws.ec2", 5 | "account": "123456789012", 6 | "time": "2021-11-11T21:29:54Z", 7 | "region": "us-east-1", 8 | "resources": [ 9 | "arn:aws:ec2:us-east-1:123456789012:instance/i-abcd1111" 10 | ], 11 | "detail": { 12 | "instance-id": "i-abcd1111", 13 | "state": "pending" 14 | } 15 | } -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-eventbridge-schedule.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "53dc4d37-cffa-4f76-80c9-8b7d4a4d2eaa", 4 | "detail-type": "Scheduled Event", 5 | "source": "aws.events", 6 | "account": "123456789012", 7 | "time": "2015-10-08T16:53:06Z", 8 | "region": "us-east-1", 9 | "resources": [ 10 | "arn:aws:events:us-east-1:123456789012:rule/my-scheduled-rule" 11 | ], 12 | "detail": {} 13 | } 14 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-firehose-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "invocationId": "invoked123", 3 | "deliveryStreamArn": "aws:lambda:events", 4 | "sourceKinesisStreamArn": "arn:aws:kinesis:us-east-1:123456789012:stream/test", 5 | "region": "us-west-2", 6 | "records": [ 7 | { 8 | "data": "SGVsbG8gV29ybGQ=", 9 | "recordId": "record1", 10 | "approximateArrivalTimestamp": 1507217624302, 11 | "kinesisRecordMetadata": { 12 | "shardId": "shardId-000000000000", 13 | "partitionKey": "4d1ad2b9-24f8-4b9d-a088-76e9947c317a", 14 | "approximateArrivalTimestamp": 1507217624302, 15 | "sequenceNumber": "49546986683135544286507457936321625675700192471156785154", 16 | "subsequenceNumber": 123456 17 | } 18 | }, 19 | { 20 | "data": "SGVsbG8gV29ybGQ=", 21 | "recordId": "record2", 22 | "approximateArrivalTimestamp": 1507217624302, 23 | "kinesisRecordMetadata": { 24 | "shardId": "shardId-000000000001", 25 | "partitionKey": "4d1ad2b9-24f8-4b9d-a088-76e9947c318a", 26 | "approximateArrivalTimestamp": 1507217624302, 27 | "sequenceNumber": "49546986683135544286507457936321625675700192471156785155", 28 | "subsequenceNumber": 123457 29 | } 30 | } 31 | ] 32 | } 33 | 34 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-iot-custom-auth-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "token" :"aToken", 3 | "signatureVerified": true, 4 | "protocols": ["tls", "http", "mqtt"], 5 | "protocolData": { 6 | "tls" : { 7 | "serverName": "serverName" 8 | }, 9 | "http": { 10 | "headers": { 11 | "X-Request-ID": "abc123" 12 | }, 13 | "queryString": "?foo=bar" 14 | }, 15 | "mqtt": { 16 | "username": "myUserName", 17 | "password": "bXlQYXNzd29yZA==", 18 | "clientId": "myClientId" 19 | } 20 | }, 21 | "connectionMetadata": { 22 | "id": "e56f08c3-c559-490f-aa9f-7e8427d0f57b" 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-iot-custom-auth-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "isAuthenticated":true, 3 | "principalId": "xxxxxxxx", 4 | "disconnectAfterInSeconds": 86400, 5 | "refreshAfterInSeconds": 300, 6 | "policyDocuments": [ 7 | { 8 | "Version": "2012-10-17", 9 | "Statement": [ 10 | { 11 | "Action": ["iot:Publish"], 12 | "Effect": "Allow", 13 | "Resource": ["arn:aws:iot:us-east-1::topic/customauthtesting"] 14 | } 15 | ] 16 | } 17 | ] 18 | } 19 | 20 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-iot_1_click-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "deviceEvent": { 3 | "buttonClicked": { 4 | "clickType": "SINGLE", 5 | "reportedTime": "2018-05-04T23:26:33.747Z" 6 | } 7 | }, 8 | "deviceInfo": { 9 | "attributes": { 10 | "key3": "value3", 11 | "key1": "value1", 12 | "key4": "value4" 13 | }, 14 | "type": "button", 15 | "deviceId": "G030PMXXXXXXXXXX", 16 | "remainingLife": 5.00 17 | }, 18 | "placementInfo": { 19 | "projectName": "test", 20 | "placementName": "myPlacement", 21 | "attributes": { 22 | "location": "Seattle", 23 | "equipment": "printer" 24 | }, 25 | "devices": { 26 | "myButton": "G030PMXXXXXXXXXX" 27 | } 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-iot_button-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "serialNumber": "ABCDEFG12345", 3 | "clickType": "SINGLE", 4 | "batteryVoltage": "2000 mV" 5 | } 6 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-kafka-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSource": "aws:kafka", 3 | "eventSourceArn": "arn:aws:kafka:us-west-2:012345678901:cluster/ExampleMSKCluster/e9f754c6-d29a-4430-a7db-958a19fd2c54-4", 4 | "bootstrapServers": "b-2.demo-cluster-1.a1bcde.c1.kafka.us-east-1.amazonaws.com:9092,b-1.demo-cluster-1.a1bcde.c1.kafka.us-east-1.amazonaws.com:9092", 5 | "records": { 6 | "AWSKafkaTopic-0": [ 7 | { 8 | "topic": "AWSKafkaTopic", 9 | "partition": 0, 10 | "offset": 0, 11 | "timestamp": 1595035749700, 12 | "timestampType": "CREATE_TIME", 13 | "key": "OGQ1NTk2YjQtMTgxMy00MjM4LWIyNGItNmRhZDhlM2QxYzBj", 14 | "value": "OGQ1NTk2YjQtMTgxMy00MjM4LWIyNGItNmRhZDhlM2QxYzBj", 15 | "headers": [ 16 | { 17 | "headerKey": [104, 101, 97, 100, 101, 114, 86, 97, 108, 117, 101] 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-kinesis-firehose-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "invocationId": "invoked123", 3 | "deliveryStreamArn": "aws:lambda:events", 4 | "sourceKinesisStreamArn": "arn:aws:kinesis:us-east-1:123456789012:stream/test", 5 | "region": "us-west-2", 6 | "records": [ 7 | { 8 | "data": "SGVsbG8gV29ybGQ=", 9 | "recordId": "record1", 10 | "approximateArrivalTimestamp": 1507217624302, 11 | "kinesisRecordMetadata": { 12 | "shardId": "shardId-000000000000", 13 | "partitionKey": "4d1ad2b9-24f8-4b9d-a088-76e9947c317a", 14 | "approximateArrivalTimestamp": 1507217624302, 15 | "sequenceNumber": "49546986683135544286507457936321625675700192471156785154", 16 | "subsequenceNumber": 123456 17 | } 18 | }, 19 | { 20 | "data": "SGVsbG8gV29ybGQ=", 21 | "recordId": "record2", 22 | "approximateArrivalTimestamp": 1507217624302, 23 | "kinesisRecordMetadata": { 24 | "shardId": "shardId-000000000001", 25 | "partitionKey": "4d1ad2b9-24f8-4b9d-a088-76e9947c318a", 26 | "approximateArrivalTimestamp": 1507217624302, 27 | "sequenceNumber": "49546986683135544286507457936321625675700192471156785155", 28 | "subsequenceNumber": 123457 29 | } 30 | } 31 | ] 32 | } 33 | 34 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-kinesis-firehose-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "records": [ 3 | { 4 | "data": "SGVsbG8gV29ybGQ=", 5 | "recordId": "record1", 6 | "result": "TRANSFORMED_STATE_OK", 7 | "metadata": { 8 | "partitionKeys": {} 9 | } 10 | }, 11 | { 12 | "data": "SGVsbG8gV29ybGQ=", 13 | "recordId": "record2", 14 | "result": "TRANSFORMED_STATE_DROPPED", 15 | "metadata": { 16 | "partitionKeys": {} 17 | } 18 | }, 19 | { 20 | "data": "SGVsbG8gV29ybGQ=", 21 | "recordId": "record3", 22 | "result": "TransformedStateOk", 23 | "metadata": { 24 | "partitionKeys": { 25 | "iamKey1": "iamValue1", 26 | "iamKey2": "iamValue2" 27 | } 28 | } 29 | } 30 | ] 31 | } 32 | 33 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-lex-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentIntent": { 3 | "name": "intent-name", 4 | "slots": { 5 | "slot name1": "value1", 6 | "slot name2": "value2" 7 | }, 8 | "slotDetails": { 9 | "slot name1": { 10 | "resolutions": [ 11 | { "value1": "resolved value1" }, 12 | { "value2": "resolved value2" } 13 | ], 14 | "originalValue": "original text" 15 | }, 16 | "slot name2": { 17 | "resolutions": [ 18 | { "value1": "resolved value1" }, 19 | { "value2": "resolved value2" } 20 | ], 21 | "originalValue": "original text" 22 | } 23 | }, 24 | "confirmationStatus": "None, Confirmed, or Denied (intent confirmation, if configured)" 25 | }, 26 | "bot": { 27 | "name": "bot name", 28 | "alias": "bot alias", 29 | "version": "bot version" 30 | }, 31 | "userId": "User ID specified in the POST request to Amazon Lex.", 32 | "inputTranscript": "Text used to process the request", 33 | "invocationSource": "FulfillmentCodeHook or DialogCodeHook", 34 | "outputDialogMode": "Text or Voice, based on ContentType request header in runtime API request", 35 | "messageVersion": "1.0", 36 | "sessionAttributes": { 37 | "key1": "value1", 38 | "key2": "value2" 39 | }, 40 | "requestAttributes": { 41 | "key1": "value1", 42 | "key2": "value2" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-lex-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "sessionAttributes": { 3 | "key1": "value1", 4 | "key2": "value2" 5 | }, 6 | "dialogAction": { 7 | "type": "ElicitIntent, ElicitSlot, ConfirmIntent, Delegate, or Close", 8 | "fulfillmentState": "Fulfilled or Failed", 9 | "message": { 10 | "contentType": "PlainText or SSML", 11 | "content": "message to convey to the user" 12 | }, 13 | "intentName": "intent-name", 14 | "slots": { 15 | "slot-name1": "value1", 16 | "slot-name2": "value2", 17 | "slot-name3": "value3" 18 | }, 19 | "slotToElicit": "slot-name", 20 | "responseCard": { 21 | "version": 3, 22 | "contentType": "application/vnd.amazonaws.card.generic", 23 | "genericAttachments": [ 24 | { 25 | "title": "card-title", 26 | "subTitle": "card-sub-title", 27 | "imageUrl": "URL of the image to be shown", 28 | "attachmentLinkUrl": "URL of the attachment to be associated with the card", 29 | "buttons": [ 30 | { 31 | "text": "button-text", 32 | "value": "value sent to server on button click" 33 | } 34 | ] 35 | } 36 | ] 37 | } 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-s3-event-with-decoded.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "eventVersion": "2.0", 5 | "eventSource": "aws:s3", 6 | "awsRegion": "us-east-1", 7 | "eventTime": "1970-01-01T00:00:00.123Z", 8 | "eventName": "ObjectCreated:Put", 9 | "userIdentity": { 10 | "principalId": "EXAMPLE" 11 | }, 12 | "requestParameters": { 13 | "sourceIPAddress": "127.0.0.1" 14 | }, 15 | "responseElements": { 16 | "x-amz-request-id": "C3D13FE58DE4C810", 17 | "x-amz-id-2": "FMyUVURIY8/IgAtTv8xRjskZQpcIZ9KG4V5Wp6S7S/JRWeUWerMUE5JgHvANOjpD" 18 | }, 19 | "s3": { 20 | "s3SchemaVersion": "1.0", 21 | "configurationId": "testConfigRule", 22 | "bucket": { 23 | "name": "sourcebucket", 24 | "ownerIdentity": { 25 | "principalId": "EXAMPLE" 26 | }, 27 | "arn": "arn:aws:s3:::mybucket" 28 | }, 29 | "object": { 30 | "key": "Happy%20Face.jpg", 31 | "urlDecodedKey": "Happy Face.jpg", 32 | "size": 1024, 33 | "versionId": "version", 34 | "eTag": "d41d8cd98f00b204e9800998ecf8427e", 35 | "sequencer": "Happy Sequencer" 36 | } 37 | } 38 | } 39 | ] 40 | } 41 | 42 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-s3-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "eventVersion": "2.0", 5 | "eventSource": "aws:s3", 6 | "awsRegion": "us-east-1", 7 | "eventTime": "1970-01-01T00:00:00.123Z", 8 | "eventName": "ObjectCreated:Put", 9 | "userIdentity": { 10 | "principalId": "EXAMPLE" 11 | }, 12 | "requestParameters": { 13 | "sourceIPAddress": "127.0.0.1" 14 | }, 15 | "responseElements": { 16 | "x-amz-request-id": "C3D13FE58DE4C810", 17 | "x-amz-id-2": "FMyUVURIY8/IgAtTv8xRjskZQpcIZ9KG4V5Wp6S7S/JRWeUWerMUE5JgHvANOjpD" 18 | }, 19 | "s3": { 20 | "s3SchemaVersion": "1.0", 21 | "configurationId": "testConfigRule", 22 | "bucket": { 23 | "name": "sourcebucket", 24 | "ownerIdentity": { 25 | "principalId": "EXAMPLE" 26 | }, 27 | "arn": "arn:aws:s3:::mybucket" 28 | }, 29 | "object": { 30 | "key": "Happy%20Face.jpg", 31 | "size": 1024, 32 | "versionId": "version", 33 | "eTag": "d41d8cd98f00b204e9800998ecf8427e", 34 | "sequencer": "Happy Sequencer" 35 | } 36 | } 37 | } 38 | ] 39 | } 40 | 41 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-s3-object-lambda-event-get-object-iam.json: -------------------------------------------------------------------------------- 1 | { 2 | "xAmzRequestId": "requestId", 3 | "getObjectContext": { 4 | "inputS3Url": "https://my-s3-ap-111122223333.s3-accesspoint.us-east-1.amazonaws.com/example?X-Amz-Security-Token=", 5 | "outputRoute": "io-use1-001", 6 | "outputToken": "OutputToken" 7 | }, 8 | "configuration": { 9 | "accessPointArn": "arn:aws:s3-object-lambda:us-east-1:111122223333:accesspoint/example-object-lambda-ap", 10 | "supportingAccessPointArn": "arn:aws:s3:us-east-1:111122223333:accesspoint/example-ap", 11 | "payload": "{}" 12 | }, 13 | "userRequest": { 14 | "url": "https://object-lambda-111122223333.s3-object-lambda.us-east-1.amazonaws.com/example", 15 | "headers": { 16 | "Host": "object-lambda-111122223333.s3-object-lambda.us-east-1.amazonaws.com", 17 | "Accept-Encoding": "identity", 18 | "X-Amz-Content-SHA256": "e3b0c44298fc1example" 19 | } 20 | }, 21 | "userIdentity": { 22 | "type": "IAMUser", 23 | "principalId": "principalId", 24 | "arn": "arn:aws:iam::111122223333:user/username", 25 | "accountId": "111122223333", 26 | "accessKeyId": "accessKeyId" 27 | }, 28 | "protocolVersion": "1.00" 29 | } 30 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-s3-object-lambda-event-head-object-iam.json: -------------------------------------------------------------------------------- 1 | { 2 | "xAmzRequestId": "requestId", 3 | "headObjectContext": { 4 | "inputS3Url": "https://my-s3-ap-111122223333.s3-accesspoint.us-east-1.amazonaws.com/example?X-Amz-Security-Token=" 5 | }, 6 | "configuration": { 7 | "accessPointArn": "arn:aws:s3-object-lambda:us-east-1:111122223333:accesspoint/example-object-lambda-ap", 8 | "supportingAccessPointArn": "arn:aws:s3:us-east-1:111122223333:accesspoint/example-ap", 9 | "payload": "{}" 10 | }, 11 | "userRequest": { 12 | "url": "https://object-lambda-111122223333.s3-object-lambda.us-east-1.amazonaws.com/example", 13 | "headers": { 14 | "Host": "object-lambda-111122223333.s3-object-lambda.us-east-1.amazonaws.com", 15 | "Accept-Encoding": "identity", 16 | "X-Amz-Content-SHA256": "e3b0c44298fc1example" 17 | } 18 | }, 19 | "userIdentity": { 20 | "type": "IAMUser", 21 | "principalId": "principalId", 22 | "arn": "arn:aws:iam::111122223333:user/username", 23 | "accountId": "111122223333", 24 | "accessKeyId": "accessKeyId" 25 | }, 26 | "protocolVersion": "1.01" 27 | } 28 | 29 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-s3-object-lambda-event-list-objects-iam.json: -------------------------------------------------------------------------------- 1 | { 2 | "xAmzRequestId": "requestId", 3 | "listObjectsContext": { 4 | "inputS3Url": "https://my-s3-ap-111122223333.s3-accesspoint.us-east-1.amazonaws.com/example?X-Amz-Security-Token=" 5 | }, 6 | "configuration": { 7 | "accessPointArn": "arn:aws:s3-object-lambda:us-east-1:111122223333:accesspoint/example-object-lambda-ap", 8 | "supportingAccessPointArn": "arn:aws:s3:us-east-1:111122223333:accesspoint/example-ap", 9 | "payload": "{}" 10 | }, 11 | "userRequest": { 12 | "url": "https://object-lambda-111122223333.s3-object-lambda.us-east-1.amazonaws.com/example", 13 | "headers": { 14 | "Host": "object-lambda-111122223333.s3-object-lambda.us-east-1.amazonaws.com", 15 | "Accept-Encoding": "identity", 16 | "X-Amz-Content-SHA256": "e3b0c44298fc1example" 17 | } 18 | }, 19 | "userIdentity": { 20 | "type": "IAMUser", 21 | "principalId": "principalId", 22 | "arn": "arn:aws:iam::111122223333:user/username", 23 | "accountId": "111122223333", 24 | "accessKeyId": "accessKeyId" 25 | }, 26 | "protocolVersion": "1.01" 27 | } 28 | 29 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-s3-object-lambda-event-list-objects-v2-iam.json: -------------------------------------------------------------------------------- 1 | { 2 | "xAmzRequestId": "requestId", 3 | "listObjectsV2Context": { 4 | "inputS3Url": "https://my-s3-ap-111122223333.s3-accesspoint.us-east-1.amazonaws.com/example?X-Amz-Security-Token=" 5 | }, 6 | "configuration": { 7 | "accessPointArn": "arn:aws:s3-object-lambda:us-east-1:111122223333:accesspoint/example-object-lambda-ap", 8 | "supportingAccessPointArn": "arn:aws:s3:us-east-1:111122223333:accesspoint/example-ap", 9 | "payload": "{}" 10 | }, 11 | "userRequest": { 12 | "url": "https://object-lambda-111122223333.s3-object-lambda.us-east-1.amazonaws.com/example", 13 | "headers": { 14 | "Host": "object-lambda-111122223333.s3-object-lambda.us-east-1.amazonaws.com", 15 | "Accept-Encoding": "identity", 16 | "X-Amz-Content-SHA256": "e3b0c44298fc1example" 17 | } 18 | }, 19 | "userIdentity": { 20 | "type": "IAMUser", 21 | "principalId": "principalId", 22 | "arn": "arn:aws:iam::111122223333:user/username", 23 | "accountId": "111122223333", 24 | "accessKeyId": "accessKeyId" 25 | }, 26 | "protocolVersion": "1.01" 27 | } 28 | 29 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-secretsmanager-secret-rotation-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Step": "createSecret", 3 | "SecretId": "arn:aws:secretsmanager:us-east-1:111122223333:secret:id-ABCD1E", 4 | "ClientRequestToken": "1ab23456-cde7-8912-34fg-h56i78j9k12l" 5 | } 6 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-sns-event-obj.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "EventVersion": "1.0", 5 | "EventSubscriptionArn": "arn:aws:sns:EXAMPLE", 6 | "EventSource": "aws:sns", 7 | "Sns": { 8 | "Type" : "Notification", 9 | "MessageId" : "82833b5c-8d5d-56d0-b0e1-7511f8253eb8", 10 | "TopicArn" : "arn:aws:sns:us-east-1:246796806071:snsNetTest", 11 | "Subject" : "Greetings", 12 | "Message" : "{\"foo\":\"Hello world!\",\"bar\":123}", 13 | "Timestamp" : "2015-08-18T18:02:32.111Z", 14 | "SignatureVersion" : "1", 15 | "Signature" : "e+khMfZriwAOTkF0OVm3tmdVq9eY6s5Bj6rXZty4B2TYssx7SSSBpvsDCiDuzgeHe++MNsGLDDT+5OpGEFBqCcd/K7iXhofz+KabMEtvM2Ku3aXcFixjOCAY1BF8hH6zU6nKzOy+m7K4UIoVqIOOhqsLWoXNFWgwQseBol1pFQ/MRi9UH84/WGdU8//dH+1/zjLxCud8Lg1vY9Yi/jxMU1HVpZ2JuvzJBdNBFJWc/VYAiw8K1r/J+dxAiLr87P96MgUqyg1wWxYe00HaEXGtjIctCNcd92s3pngOOeGvPYGaTIZEbYhSf2leMYd+CXujUHRqozru5K0Zp+l99fUNTg==", 16 | "SigningCertURL" : "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-d6d679a1d18e95c2f9ffcf11f4f9e198.pem", 17 | "UnsubscribeURL" : "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:246796806071:snsNetTest:228cc6c9-dcd8-4c92-9f3a-77f55176b9e3" 18 | } 19 | } 20 | ] 21 | } 22 | 23 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-sns-event-pascal-case.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "EventVersion": "1.0", 5 | "EventSubscriptionArn": "arn:aws:sns:EXAMPLE", 6 | "EventSource": "aws:sns", 7 | "Sns": { 8 | "Type" : "Notification", 9 | "MessageId" : "82833b5c-8d5d-56d0-b0e1-7511f8253eb8", 10 | "TopicArn" : "arn:aws:sns:us-east-1:246796806071:snsNetTest", 11 | "Subject" : "Greetings", 12 | "Message" : "Hello\r\nworld!", 13 | "Timestamp" : "2015-08-18T18:02:32.111Z", 14 | "SignatureVersion" : "1", 15 | "Signature" : "e+khMfZriwAOTkF0OVm3tmdVq9eY6s5Bj6rXZty4B2TYssx7SSSBpvsDCiDuzgeHe++MNsGLDDT+5OpGEFBqCcd/K7iXhofz+KabMEtvM2Ku3aXcFixjOCAY1BF8hH6zU6nKzOy+m7K4UIoVqIOOhqsLWoXNFWgwQseBol1pFQ/MRi9UH84/WGdU8//dH+1/zjLxCud8Lg1vY9Yi/jxMU1HVpZ2JuvzJBdNBFJWc/VYAiw8K1r/J+dxAiLr87P96MgUqyg1wWxYe00HaEXGtjIctCNcd92s3pngOOeGvPYGaTIZEbYhSf2leMYd+CXujUHRqozru5K0Zp+l99fUNTg==", 16 | "SigningCertUrl" : "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-d6d679a1d18e95c2f9ffcf11f4f9e198.pem", 17 | "UnsubscribeUrl" : "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:246796806071:snsNetTest:228cc6c9-dcd8-4c92-9f3a-77f55176b9e3" 18 | } 19 | } 20 | ] 21 | } 22 | 23 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-sns-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "EventVersion": "1.0", 5 | "EventSubscriptionArn": "arn:aws:sns:EXAMPLE", 6 | "EventSource": "aws:sns", 7 | "Sns": { 8 | "Type" : "Notification", 9 | "MessageId" : "82833b5c-8d5d-56d0-b0e1-7511f8253eb8", 10 | "TopicArn" : "arn:aws:sns:us-east-1:246796806071:snsNetTest", 11 | "Subject" : "Greetings", 12 | "Message" : "Hello\r\nworld!", 13 | "Timestamp" : "2015-08-18T18:02:32.111Z", 14 | "SignatureVersion" : "1", 15 | "Signature" : "e+khMfZriwAOTkF0OVm3tmdVq9eY6s5Bj6rXZty4B2TYssx7SSSBpvsDCiDuzgeHe++MNsGLDDT+5OpGEFBqCcd/K7iXhofz+KabMEtvM2Ku3aXcFixjOCAY1BF8hH6zU6nKzOy+m7K4UIoVqIOOhqsLWoXNFWgwQseBol1pFQ/MRi9UH84/WGdU8//dH+1/zjLxCud8Lg1vY9Yi/jxMU1HVpZ2JuvzJBdNBFJWc/VYAiw8K1r/J+dxAiLr87P96MgUqyg1wWxYe00HaEXGtjIctCNcd92s3pngOOeGvPYGaTIZEbYhSf2leMYd+CXujUHRqozru5K0Zp+l99fUNTg==", 16 | "SigningCertURL" : "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-d6d679a1d18e95c2f9ffcf11f4f9e198.pem", 17 | "UnsubscribeURL" : "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:246796806071:snsNetTest:228cc6c9-dcd8-4c92-9f3a-77f55176b9e3" 18 | } 19 | } 20 | ] 21 | } 22 | 23 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-sqs-api-event-obj.json: -------------------------------------------------------------------------------- 1 | { 2 | "Messages": [ 3 | { 4 | "Body": "{\"country\": \"usa\", \"city\": \"provincetown\"}", 5 | "Md5OfBody": "2b3e4f40b57e80d67ac5b9660c56d787", 6 | "MessageId": "f663a189-97e2-41f5-9c0e-cfb595d8322c", 7 | "ReceiptHandle": "AQEBdObBZIl7FWJiK9c3KmqKNvusy6+eqG51SLIp5Gs6lQ6+e4SI0lJ6Glw+qcOi+2RRrnfOjlsF8uDlo13TgubmtgP+CH7s+YKDdpbg2jA931vLi6qnU0ZFXcf/H8BDZ4kcz29npMu9/N2DT9F+kI9Q9pTfLsISg/7XFMvRTqAtjSfa2wI5TVcOPZBdkGqTLUoKqAYni0L7NTLzFUTjCN/HiOcvG+16zahhsTniM1MwOTSpbOO2uTZmY25V/PCfNdF1PBXtdNA9mWW2Ym6THV28ug3cuK6dXbFQBuxIGVhOq+mRVU6gKN/eZpZediiBt75oHD6ASu8jIUpJGeUWEZm6qSWU+YTivr6QoqGLwAVvI3CXOIZQ/+Wp/RJAxMQxtRIe/MOsOITcmGlFqhWnjlGQdg==" 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /lambda-events/src/fixtures/example-sqs-batch-response.json: -------------------------------------------------------------------------------- 1 | { 2 | "batchItemFailures": [ 3 | { 4 | "itemIdentifier": "id2" 5 | }, 6 | { 7 | "itemIdentifier": "id4" 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /lambda-extension/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lambda-extension" 3 | version = "0.12.1" 4 | edition = "2021" 5 | rust-version = "1.81.0" 6 | authors = [ 7 | "David Calavera ", 8 | "Harold Sun ", 9 | ] 10 | description = "AWS Lambda Extension API" 11 | license = "Apache-2.0" 12 | repository = "https://github.com/awslabs/aws-lambda-rust-runtime" 13 | categories = ["web-programming::http-server"] 14 | keywords = ["AWS", "Lambda", "API"] 15 | readme = "README.md" 16 | 17 | [features] 18 | default = ["tracing"] 19 | tracing = ["lambda_runtime_api_client/tracing"] 20 | 21 | [dependencies] 22 | async-stream = "0.3" 23 | bytes = { workspace = true } 24 | chrono = { workspace = true, features = ["serde"] } 25 | http = { workspace = true } 26 | http-body-util = { workspace = true } 27 | hyper = { workspace = true, features = ["http1", "client", "server"] } 28 | hyper-util = { workspace = true } 29 | lambda_runtime_api_client = { version = "0.12", path = "../lambda-runtime-api-client" } 30 | serde = { version = "1", features = ["derive"] } 31 | serde_json = "^1" 32 | tokio = { version = "1.0", features = [ 33 | "macros", 34 | "io-util", 35 | "sync", 36 | "rt-multi-thread", 37 | ] } 38 | tokio-stream = "0.1.2" 39 | tower = { workspace = true, features = ["make", "util"] } 40 | tracing = { version = "0.1", features = ["log"] } 41 | 42 | [package.metadata.docs.rs] 43 | all-features = true 44 | -------------------------------------------------------------------------------- /lambda-extension/src/error.rs: -------------------------------------------------------------------------------- 1 | /// Error type that extensions may result in 2 | pub type Error = lambda_runtime_api_client::BoxError; 3 | 4 | /// Simple error that encapsulates human readable descriptions 5 | #[derive(Clone, Debug, PartialEq, Eq)] 6 | pub struct ExtensionError { 7 | err: String, 8 | } 9 | 10 | impl ExtensionError { 11 | pub(crate) fn boxed>(str: T) -> Box { 12 | Box::new(ExtensionError { err: str.into() }) 13 | } 14 | } 15 | 16 | impl std::fmt::Display for ExtensionError { 17 | #[inline] 18 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 19 | self.err.fmt(f) 20 | } 21 | } 22 | 23 | impl std::error::Error for ExtensionError {} 24 | -------------------------------------------------------------------------------- /lambda-http/src/ext/mod.rs: -------------------------------------------------------------------------------- 1 | //! Extension methods for `Request` types 2 | 3 | pub mod extensions; 4 | pub mod request; 5 | 6 | pub use extensions::RequestExt; 7 | pub use request::{PayloadError, RequestPayloadExt}; 8 | -------------------------------------------------------------------------------- /lambda-http/tests/data/alb_health_check.json: -------------------------------------------------------------------------------- 1 | { 2 | "requestContext": { 3 | "elb": { 4 | "targetGroupArn": "arn:aws:elasticloadbalancing:region:123456789012:targetgroup/my-target-group/6d0ecf831eec9f09" 5 | } 6 | }, 7 | "httpMethod": "GET", 8 | "path": "/", 9 | "queryStringParameters": {}, 10 | "headers": { 11 | "user-agent": "ELB-HealthChecker/2.0" 12 | }, 13 | "body": "", 14 | "isBase64Encoded": false 15 | } -------------------------------------------------------------------------------- /lambda-http/tests/data/alb_no_host.json: -------------------------------------------------------------------------------- 1 | { 2 | "body": "", 3 | "headers": { 4 | "user-agent": "ELB-HealthChecker/2.0" 5 | }, 6 | "httpMethod": "GET", 7 | 8 | "isBase64Encoded": false, 9 | 10 | "path": "/v1/health/", 11 | "queryStringParameters": {}, 12 | "requestContext": { 13 | "elb": { 14 | "targetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:111111111:targetgroup/cdn-ingestor-tg-usea1-dev/3fe2aca58c0da101" 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /lambda-http/tests/data/alb_request.json: -------------------------------------------------------------------------------- 1 | { 2 | "requestContext": { 3 | "elb": { 4 | "targetGroupArn": "arn:aws:elasticloadbalancing:region:123456789012:targetgroup/my-target-group/6d0ecf831eec9f09" 5 | } 6 | }, 7 | "httpMethod": "GET", 8 | "path": "/", 9 | "queryStringParameters": { "myKey": "val2"}, 10 | "headers": { 11 | "accept": "text/html,application/xhtml+xml", 12 | "accept-language": "en-US,en;q=0.8", 13 | "content-type": "text/plain", 14 | "cookie": "cookies", 15 | "host": "lambda-846800462-us-east-2.elb.amazonaws.com", 16 | "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6)", 17 | "x-amzn-trace-id": "Root=1-5bdb40ca-556d8b0c50dc66f0511bf520", 18 | "x-forwarded-for": "72.21.198.66", 19 | "x-forwarded-port": "443", 20 | "x-forwarded-proto": "https" 21 | }, 22 | "isBase64Encoded": false, 23 | "body": "request_body" 24 | } -------------------------------------------------------------------------------- /lambda-http/tests/data/alb_request_encoded_query_parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "requestContext": { 3 | "elb": { 4 | "targetGroupArn": "arn:aws:elasticloadbalancing:region:123456789012:targetgroup/my-target-group/6d0ecf831eec9f09" 5 | } 6 | }, 7 | "httpMethod": "GET", 8 | "path": "/", 9 | "queryStringParameters": { "myKey": "%3FshowAll%3Dtrue"}, 10 | "headers": { 11 | "accept": "text/html,application/xhtml+xml", 12 | "accept-language": "en-US,en;q=0.8", 13 | "content-type": "text/plain", 14 | "cookie": "cookies", 15 | "host": "lambda-846800462-us-east-2.elb.amazonaws.com", 16 | "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6)", 17 | "x-amzn-trace-id": "Root=1-5bdb40ca-556d8b0c50dc66f0511bf520", 18 | "x-forwarded-for": "72.21.198.66", 19 | "x-forwarded-port": "443", 20 | "x-forwarded-proto": "https" 21 | }, 22 | "isBase64Encoded": false, 23 | "body": "request_body" 24 | } -------------------------------------------------------------------------------- /lambda-http/tests/data/apigw_v2_proxy_request.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "routeKey": "$default", 4 | "rawPath": "/my/path", 5 | "rawQueryString": "parameter1=value1¶meter1=value2¶meter2=value", 6 | "cookies": [ "cookie1=value1", "cookie2=value2" ], 7 | "headers": { 8 | "Header1": "value1", 9 | "Header2": "value2" 10 | }, 11 | "queryStringParameters": { "parameter1": "value1,value2", "parameter2": "value" }, 12 | "requestContext": { 13 | "accountId": "123456789012", 14 | "apiId": "api-id", 15 | "authorizer": { "jwt": { 16 | "claims": {"claim1": "value1", "claim2": "value2"}, 17 | "scopes": ["scope1", "scope2"] 18 | } 19 | }, 20 | "domainName": "id.execute-api.us-east-1.amazonaws.com", 21 | "domainPrefix": "id", 22 | "http": { 23 | "method": "POST", 24 | "path": "/my/path", 25 | "protocol": "HTTP/1.1", 26 | "sourceIp": "IP", 27 | "userAgent": "agent" 28 | }, 29 | "requestId": "id", 30 | "routeKey": "$default", 31 | "stage": "$default", 32 | "time": "12/Mar/2020:19:03:58 +0000", 33 | "timeEpoch": 1583348638390 34 | }, 35 | "body": "Hello from Lambda", 36 | "pathParameters": {"parameter1": "value1"}, 37 | "isBase64Encoded": false, 38 | "stageVariables": {"stageVariable1": "value1", "stageVariable2": "value2"} 39 | } -------------------------------------------------------------------------------- /lambda-http/tests/data/apigw_v2_proxy_request_minimal.json: -------------------------------------------------------------------------------- 1 | { 2 | "headers": { 3 | "accept": "*/*", 4 | "content-length": "0", 5 | "host": "xxx.execute-api.us-east-1.amazonaws.com", 6 | "user-agent": "curl/7.64.1", 7 | "x-amzn-trace-id": "Root=1-5eb33c07-de25b420912dee103a5db434", 8 | "x-forwarded-for": "65.78.31.245", 9 | "x-forwarded-port": "443", 10 | "x-forwarded-proto": "https" 11 | }, 12 | "isBase64Encoded": false, 13 | "rawPath": "/", 14 | "rawQueryString": "", 15 | "requestContext": { 16 | "accountId": "123456789012", 17 | "apiId": "xxx", 18 | "domainName": "xxx.execute-api.us-east-1.amazonaws.com", 19 | "domainPrefix": "xxx", 20 | "http": { 21 | "method": "GET", 22 | "path": "/", 23 | "protocol": "HTTP/1.1", 24 | "sourceIp": "65.78.31.245", 25 | "userAgent": "curl/7.64.1" 26 | }, 27 | "requestId": "MIZRNhJtIAMEMDw=", 28 | "routeKey": "$default", 29 | "stage": "$default", 30 | "time": "06/May/2020:22:36:55 +0000", 31 | "timeEpoch": 1588804615616 32 | }, 33 | "routeKey": "$default", 34 | "version": "2.0" 35 | } -------------------------------------------------------------------------------- /lambda-http/tests/data/lambda_function_url_request.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "routeKey": "$default", 4 | "rawPath": "/my/path", 5 | "rawQueryString": "parameter1=value1¶meter1=value2¶meter2=value", 6 | "cookies": [ 7 | "test=hi" 8 | ], 9 | "headers": { 10 | "x-amzn-tls-cipher-suite": "ECDHE-RSA-AES128-GCM-SHA256", 11 | "x-amzn-tls-version": "TLSv1.2", 12 | "x-amzn-trace-id": "Root=1-5eb33c07-de25b420912dee103a5db434", 13 | "cookie": "test=hi", 14 | "x-forwarded-proto": "https", 15 | "host": "id.lambda-url.eu-west-2.on.aws", 16 | "x-forwarded-port": "443", 17 | "x-forwarded-for": "65.78.31.245", 18 | "accept": "*/*", 19 | "user-agent": "curl/7.68.0" 20 | }, 21 | "requestContext": { 22 | "accountId": "123456789012", 23 | "apiId": "xxx", 24 | "domainName": "id.lambda-url.eu-west-2.on.aws", 25 | "domainPrefix": "id", 26 | "http": { 27 | "method": "GET", 28 | "path": "/my/path", 29 | "protocol": "HTTP/1.1", 30 | "sourceIp": "65.78.31.245", 31 | "userAgent": "curl/7.68.0" 32 | }, 33 | "requestId": "MIZRNhJtIAMEMDw=", 34 | "routeKey": "$default", 35 | "stage": "$default", 36 | "time": "11/Jan/2023:11:45:34 +0000", 37 | "timeEpoch": 1673437534837 38 | }, 39 | "isBase64Encoded": false 40 | } -------------------------------------------------------------------------------- /lambda-integration-tests/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lambda-integration-tests" 3 | version = "0.1.0" 4 | authors = ["Maxime David"] 5 | edition = "2021" 6 | rust-version = "1.81.0" 7 | description = "AWS Lambda Runtime integration tests" 8 | license = "Apache-2.0" 9 | repository = "https://github.com/awslabs/aws-lambda-rust-runtime" 10 | categories = ["web-programming::http-server"] 11 | keywords = ["AWS", "Lambda", "API"] 12 | readme = "../README.md" 13 | 14 | [dependencies] 15 | lambda_runtime = { path = "../lambda-runtime", features = ["tracing", "graceful-shutdown"] } 16 | aws_lambda_events = { path = "../lambda-events" } 17 | serde_json = "1.0.121" 18 | tokio = { version = "1", features = ["full"] } 19 | serde = { version = "1.0.204", features = ["derive"] } 20 | 21 | [dev-dependencies] 22 | reqwest = { version = "0.12.5", features = ["blocking"] } 23 | openssl = { version = "0.10", features = ["vendored"] } 24 | 25 | [[bin]] 26 | name = "helloworld" 27 | path = "src/helloworld.rs" 28 | 29 | [[bin]] 30 | name = "authorizer" 31 | path = "src/authorizer.rs" 32 | -------------------------------------------------------------------------------- /lambda-integration-tests/samconfig.toml: -------------------------------------------------------------------------------- 1 | version = 0.1 2 | 3 | [default] 4 | [default.build.parameters] 5 | cached = true 6 | parallel = true 7 | 8 | [default.validate.parameters] 9 | lint = true 10 | 11 | [default.deploy.parameters] 12 | capabilities = "CAPABILITY_IAM" 13 | confirm_changeset = true 14 | s3_bucket = "aws-lambda-rust-runtime-integration-testing" 15 | 16 | [default.sync.parameters] 17 | watch = true 18 | 19 | [default.local_start_api.parameters] 20 | warm_containers = "EAGER" 21 | 22 | [default.local_start_lambda.parameters] 23 | warm_containers = "EAGER" -------------------------------------------------------------------------------- /lambda-integration-tests/src/helloworld.rs: -------------------------------------------------------------------------------- 1 | use aws_lambda_events::{ 2 | apigw::{ApiGatewayProxyRequest, ApiGatewayProxyResponse}, 3 | http::HeaderMap, 4 | }; 5 | use lambda_runtime::{service_fn, tracing, Error, LambdaEvent}; 6 | 7 | #[tokio::main] 8 | async fn main() -> Result<(), Error> { 9 | tracing::init_default_subscriber(); 10 | let func = service_fn(func); 11 | lambda_runtime::spawn_graceful_shutdown_handler(|| async move {}).await; 12 | lambda_runtime::run(func).await?; 13 | Ok(()) 14 | } 15 | 16 | async fn func(_event: LambdaEvent) -> Result { 17 | let mut headers = HeaderMap::new(); 18 | headers.insert("content-type", "text/html".parse().unwrap()); 19 | let resp = ApiGatewayProxyResponse { 20 | status_code: 200, 21 | multi_value_headers: headers.clone(), 22 | is_base64_encoded: false, 23 | body: Some("Hello world!".into()), 24 | headers, 25 | }; 26 | Ok(resp) 27 | } 28 | -------------------------------------------------------------------------------- /lambda-integration-tests/tests/integration_test.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn test_calling_lambda_should_return_200() { 3 | let test_endpoint = std::env::var("TEST_ENDPOINT").expect("could not read TEST_ENDPOINT"); 4 | let secret_token = std::env::var("SECRET_TOKEN").expect("could not read SECRET_TOKEN"); 5 | let client = reqwest::blocking::Client::new(); 6 | let res = client 7 | .get(test_endpoint) 8 | .header("Authorization", secret_token) 9 | .send() 10 | .expect("could not the request"); 11 | assert_eq!(res.status(), 200); 12 | } 13 | -------------------------------------------------------------------------------- /lambda-runtime-api-client/README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Runtime API Client 2 | 3 | [![Docs](https://docs.rs/lambda_runtime_api_client/badge.svg)](https://docs.rs/lambda_runtime_api_client) 4 | 5 | **`lambda-runtime-api-client`** is a library to interact with the AWS Lambda Runtime API. 6 | 7 | This crate provides simple building blocks to send REST request to this API. You probably don't need to use this crate directly, look at [lambda_runtime](https://docs.rs/lambda_runtime) and [lambda_extension](https://docs.rs/lambda_extension) instead. 8 | 9 | ## Example 10 | 11 | ```rust,no_run 12 | use http::{Method, Request}; 13 | use hyper::Body; 14 | use lambda_runtime_api_client::{build_request, Client, Error}; 15 | 16 | fn register_request(extension_name: &str, events: &[&str]) -> Result, Error> { 17 | let events = serde_json::json!({ "events": events }); 18 | 19 | let req = build_request() 20 | .method(Method::POST) 21 | .uri("/2020-01-01/extension/register") 22 | .header("Lambda-Extension-Name", extension_name) 23 | .body(Body::from(serde_json::to_string(&events)?))?; 24 | 25 | Ok(req) 26 | } 27 | 28 | #[tokio::main] 29 | async fn main() -> Result<(), Error> { 30 | let client = Client::builder().build()?; 31 | let request = register_request("my_extension", &["INVOKE"])?; 32 | 33 | client.call(request).await 34 | } 35 | ``` 36 | -------------------------------------------------------------------------------- /lambda-runtime-api-client/src/error.rs: -------------------------------------------------------------------------------- 1 | //! Extracted from Axum under MIT license. 2 | //! 3 | use std::{error::Error as StdError, fmt}; 4 | pub use tower::BoxError; 5 | /// Errors that can happen when using axum. 6 | #[derive(Debug)] 7 | pub struct Error { 8 | inner: BoxError, 9 | } 10 | 11 | impl Error { 12 | /// Create a new `Error` from a boxable error. 13 | pub fn new(error: impl Into) -> Self { 14 | Self { inner: error.into() } 15 | } 16 | 17 | /// Convert an `Error` back into the underlying boxed trait object. 18 | pub fn into_inner(self) -> BoxError { 19 | self.inner 20 | } 21 | } 22 | 23 | impl fmt::Display for Error { 24 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 25 | self.inner.fmt(f) 26 | } 27 | } 28 | 29 | impl StdError for Error { 30 | fn source(&self) -> Option<&(dyn StdError + 'static)> { 31 | Some(&*self.inner) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lambda-runtime/src/layers/mod.rs: -------------------------------------------------------------------------------- 1 | // Internally used services. 2 | mod api_client; 3 | mod api_response; 4 | mod panic; 5 | 6 | // Publicly available services. 7 | mod trace; 8 | 9 | pub(crate) use api_client::RuntimeApiClientService; 10 | pub(crate) use api_response::RuntimeApiResponseService; 11 | pub(crate) use panic::CatchPanicService; 12 | pub use trace::TracingLayer; 13 | 14 | #[cfg(feature = "opentelemetry")] 15 | mod otel; 16 | #[cfg(feature = "opentelemetry")] 17 | #[cfg_attr(docsrs, doc(cfg(feature = "opentelemetry")))] 18 | pub use otel::{OpenTelemetryFaasTrigger, OpenTelemetryLayer}; 19 | -------------------------------------------------------------------------------- /lambda-runtime/src/streaming.rs: -------------------------------------------------------------------------------- 1 | pub use lambda_runtime_api_client::body::{sender::Sender, Body}; 2 | 3 | pub use crate::types::StreamResponse as Response; 4 | 5 | /// Create a new `Body` stream with associated Sender half. 6 | /// 7 | /// Examples 8 | /// 9 | /// ``` 10 | /// use lambda_runtime::{ 11 | /// streaming::{channel, Body, Response}, 12 | /// Error, LambdaEvent, 13 | /// }; 14 | /// use std::{thread, time::Duration}; 15 | /// 16 | /// async fn func(_event: LambdaEvent) -> Result, Error> { 17 | /// let messages = vec!["Hello", "world", "from", "Lambda!"]; 18 | /// 19 | /// let (mut tx, rx) = channel(); 20 | /// 21 | /// tokio::spawn(async move { 22 | /// for message in messages.iter() { 23 | /// tx.send_data((message.to_string() + "\n").into()).await.unwrap(); 24 | /// thread::sleep(Duration::from_millis(500)); 25 | /// } 26 | /// }); 27 | /// 28 | /// Ok(Response::from(rx)) 29 | /// } 30 | /// ``` 31 | #[allow(unused)] 32 | #[inline] 33 | pub fn channel() -> (Sender, Body) { 34 | Body::channel() 35 | } 36 | --------------------------------------------------------------------------------