├── .github ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── aws-lambda-java-core.yml │ ├── aws-lambda-java-events-sdk-transformer.yml │ ├── aws-lambda-java-events.yml │ ├── aws-lambda-java-log4j2.yml │ ├── aws-lambda-java-profiler.yml │ ├── aws-lambda-java-serialization.yml │ ├── aws-lambda-java-tests.yml │ ├── repo-sync.yml │ ├── runtime-interface-client_merge_to_main.yml │ ├── runtime-interface-client_pr.yml │ └── samples.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── aws-lambda-java-core ├── RELEASE.CHANGELOG.md ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── amazonaws │ └── services │ └── lambda │ └── runtime │ ├── Client.java │ ├── ClientContext.java │ ├── CognitoIdentity.java │ ├── Context.java │ ├── CustomPojoSerializer.java │ ├── LambdaLogger.java │ ├── LambdaRuntime.java │ ├── LambdaRuntimeInternal.java │ ├── RequestHandler.java │ ├── RequestStreamHandler.java │ └── logging │ ├── LogFormat.java │ └── LogLevel.java ├── aws-lambda-java-events-sdk-transformer ├── README.md ├── RELEASE.CHANGELOG.md ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── amazonaws │ │ └── services │ │ └── lambda │ │ └── runtime │ │ └── events │ │ └── transformers │ │ ├── v1 │ │ ├── DynamodbEventTransformer.java │ │ └── dynamodb │ │ │ ├── DynamodbAttributeValueTransformer.java │ │ │ ├── DynamodbIdentityTransformer.java │ │ │ ├── DynamodbRecordTransformer.java │ │ │ └── DynamodbStreamRecordTransformer.java │ │ └── v2 │ │ ├── DynamodbEventTransformer.java │ │ └── dynamodb │ │ ├── DynamodbAttributeValueTransformer.java │ │ ├── DynamodbIdentityTransformer.java │ │ ├── DynamodbRecordTransformer.java │ │ └── DynamodbStreamRecordTransformer.java │ └── test │ └── java │ └── com │ └── amazonaws │ └── services │ └── lambda │ └── runtime │ └── events │ └── transformers │ ├── v1 │ ├── DynamodbEventTransformerTest.java │ └── dynamodb │ │ ├── DynamodbAttributeValueTransformerTest.java │ │ ├── DynamodbIdentityTransformerTest.java │ │ ├── DynamodbRecordTransformerTest.java │ │ └── DynamodbStreamRecordTransformerTest.java │ └── v2 │ ├── DynamodbEventTransformerTest.java │ └── dynamodb │ ├── DynamodbAttributeValueTransformerTest.java │ ├── DynamodbIdentityTransformerTest.java │ ├── DynamodbRecordTransformerTest.java │ └── DynamodbStreamRecordTransformerTest.java ├── aws-lambda-java-events ├── README.md ├── RELEASE.CHANGELOG.md ├── pom.xml └── src │ ├── main │ └── java │ │ ├── com │ │ └── amazonaws │ │ │ └── services │ │ │ └── lambda │ │ │ └── runtime │ │ │ └── events │ │ │ ├── APIGatewayCustomAuthorizerEvent.java │ │ │ ├── APIGatewayProxyRequestEvent.java │ │ │ ├── APIGatewayProxyResponseEvent.java │ │ │ ├── APIGatewayV2CustomAuthorizerEvent.java │ │ │ ├── APIGatewayV2HTTPEvent.java │ │ │ ├── APIGatewayV2HTTPResponse.java │ │ │ ├── APIGatewayV2ProxyRequestEvent.java │ │ │ ├── APIGatewayV2ProxyResponseEvent.java │ │ │ ├── APIGatewayV2WebSocketEvent.java │ │ │ ├── APIGatewayV2WebSocketResponse.java │ │ │ ├── ActiveMQEvent.java │ │ │ ├── AppSyncLambdaAuthorizerEvent.java │ │ │ ├── AppSyncLambdaAuthorizerResponse.java │ │ │ ├── ApplicationLoadBalancerRequestEvent.java │ │ │ ├── ApplicationLoadBalancerResponseEvent.java │ │ │ ├── CloudFormationCustomResourceEvent.java │ │ │ ├── CloudFrontEvent.java │ │ │ ├── CloudWatchCompositeAlarmEvent.java │ │ │ ├── CloudWatchLogsEvent.java │ │ │ ├── CloudWatchMetricAlarmEvent.java │ │ │ ├── CodeCommitEvent.java │ │ │ ├── CognitoEvent.java │ │ │ ├── CognitoUserPoolCreateAuthChallengeEvent.java │ │ │ ├── CognitoUserPoolCustomMessageEvent.java │ │ │ ├── CognitoUserPoolDefineAuthChallengeEvent.java │ │ │ ├── CognitoUserPoolEvent.java │ │ │ ├── CognitoUserPoolMigrateUserEvent.java │ │ │ ├── CognitoUserPoolPostAuthenticationEvent.java │ │ │ ├── CognitoUserPoolPostConfirmationEvent.java │ │ │ ├── CognitoUserPoolPreAuthenticationEvent.java │ │ │ ├── CognitoUserPoolPreSignUpEvent.java │ │ │ ├── CognitoUserPoolPreTokenGenerationEvent.java │ │ │ ├── CognitoUserPoolPreTokenGenerationEventV2.java │ │ │ ├── CognitoUserPoolVerifyAuthChallengeResponseEvent.java │ │ │ ├── ConfigEvent.java │ │ │ ├── ConnectEvent.java │ │ │ ├── DynamodbEvent.java │ │ │ ├── DynamodbTimeWindowEvent.java │ │ │ ├── IamPolicyResponse.java │ │ │ ├── IamPolicyResponseV1.java │ │ │ ├── IoTButtonEvent.java │ │ │ ├── KafkaEvent.java │ │ │ ├── KinesisAnalyticsFirehoseInputPreprocessingEvent.java │ │ │ ├── KinesisAnalyticsInputPreprocessingResponse.java │ │ │ ├── KinesisAnalyticsOutputDeliveryEvent.java │ │ │ ├── KinesisAnalyticsOutputDeliveryResponse.java │ │ │ ├── KinesisAnalyticsStreamsInputPreprocessingEvent.java │ │ │ ├── KinesisEvent.java │ │ │ ├── KinesisFirehoseEvent.java │ │ │ ├── KinesisTimeWindowEvent.java │ │ │ ├── LambdaDestinationEvent.java │ │ │ ├── LexEvent.java │ │ │ ├── MSKFirehoseEvent.java │ │ │ ├── MSKFirehoseResponse.java │ │ │ ├── RabbitMQEvent.java │ │ │ ├── S3BatchEvent.java │ │ │ ├── S3BatchEventV2.java │ │ │ ├── S3BatchResponse.java │ │ │ ├── S3Event.java │ │ │ ├── S3ObjectLambdaEvent.java │ │ │ ├── SNSEvent.java │ │ │ ├── SQSBatchResponse.java │ │ │ ├── SQSEvent.java │ │ │ ├── ScheduledEvent.java │ │ │ ├── SecretsManagerRotationEvent.java │ │ │ ├── SimpleIAMPolicyResponse.java │ │ │ ├── StreamsEventResponse.java │ │ │ ├── TimeWindowEventResponse.java │ │ │ └── models │ │ │ ├── TimeWindow.java │ │ │ ├── dynamodb │ │ │ ├── AttributeValue.java │ │ │ ├── Identity.java │ │ │ ├── OperationType.java │ │ │ ├── Record.java │ │ │ ├── StreamRecord.java │ │ │ └── StreamViewType.java │ │ │ ├── kinesis │ │ │ ├── EncryptionType.java │ │ │ └── Record.java │ │ │ └── s3 │ │ │ └── S3EventNotification.java │ │ └── lombok.config │ └── test │ ├── java │ └── com │ │ └── amazonaws │ │ └── services │ │ └── lambda │ │ └── runtime │ │ └── events │ │ ├── APIGatewayV2CustomAuthorizerEventTest.java │ │ ├── HttpUtils.java │ │ ├── IamPolicyResponseTest.java │ │ ├── IamPolicyResponseV1Test.java │ │ └── models │ │ └── s3 │ │ └── S3EventNotificationTest.java │ └── resources │ ├── iamPolicyResponses │ ├── allow-with-condition.json │ ├── allow.json │ └── deny.json │ └── iamPolicyV1Responses │ ├── allow-with-condition.json │ ├── allow.json │ └── deny.json ├── aws-lambda-java-log4j2 ├── README.md ├── RELEASE.CHANGELOG.md ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── amazonaws │ │ └── services │ │ └── lambda │ │ └── runtime │ │ └── log4j2 │ │ ├── LambdaAppender.java │ │ ├── LambdaJsonFormat.java │ │ └── LambdaTextFormat.java │ └── resources │ └── LambdaLayout.json ├── aws-lambda-java-runtime-interface-client ├── .gitignore ├── Makefile ├── README.md ├── RELEASE.CHANGELOG.md ├── build-tools │ └── checkstyle.xml ├── pom.xml ├── ric-dev-environment │ ├── codeartifact-repo.mk │ ├── publish_snapshot.sh │ ├── settings.xml │ └── test-platform-specific-jar-snapshot.sh ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── amazonaws │ │ │ │ └── services │ │ │ │ └── lambda │ │ │ │ ├── crac │ │ │ │ ├── CheckpointException.java │ │ │ │ ├── Context.java │ │ │ │ ├── ContextImpl.java │ │ │ │ ├── Core.java │ │ │ │ ├── DNSManager.java │ │ │ │ ├── Resource.java │ │ │ │ └── RestoreException.java │ │ │ │ └── runtime │ │ │ │ └── api │ │ │ │ └── client │ │ │ │ ├── AWSLambda.java │ │ │ │ ├── ClasspathLoader.java │ │ │ │ ├── CustomerClassLoader.java │ │ │ │ ├── EventHandlerLoader.java │ │ │ │ ├── HandlerInfo.java │ │ │ │ ├── LambdaEnvironment.java │ │ │ │ ├── LambdaRequestHandler.java │ │ │ │ ├── PojoSerializerLoader.java │ │ │ │ ├── ReservedRuntimeEnvironmentVariables.java │ │ │ │ ├── TooManyServiceProvidersFoundException.java │ │ │ │ ├── UserFault.java │ │ │ │ ├── api │ │ │ │ ├── LambdaClientContext.java │ │ │ │ ├── LambdaClientContextClient.java │ │ │ │ ├── LambdaCognitoIdentity.java │ │ │ │ └── LambdaContext.java │ │ │ │ ├── logging │ │ │ │ ├── AbstractLambdaLogger.java │ │ │ │ ├── FrameType.java │ │ │ │ ├── FramedTelemetryLogSink.java │ │ │ │ ├── JsonLogFormatter.java │ │ │ │ ├── LambdaContextLogger.java │ │ │ │ ├── LogFiltering.java │ │ │ │ ├── LogFormatter.java │ │ │ │ ├── LogSink.java │ │ │ │ ├── StdOutLogSink.java │ │ │ │ ├── StructuredLogMessage.java │ │ │ │ └── TextLogFormatter.java │ │ │ │ ├── runtimeapi │ │ │ │ ├── DtoSerializers.java │ │ │ │ ├── JniHelper.java │ │ │ │ ├── LambdaError.java │ │ │ │ ├── LambdaRuntimeApiClient.java │ │ │ │ ├── LambdaRuntimeApiClientImpl.java │ │ │ │ ├── LambdaRuntimeClientException.java │ │ │ │ ├── NativeClient.java │ │ │ │ ├── RapidErrorType.java │ │ │ │ ├── converters │ │ │ │ │ ├── LambdaErrorConverter.java │ │ │ │ │ └── XRayErrorCauseConverter.java │ │ │ │ └── dto │ │ │ │ │ ├── ErrorRequest.java │ │ │ │ │ ├── InvocationRequest.java │ │ │ │ │ ├── StackElement.java │ │ │ │ │ ├── XRayErrorCause.java │ │ │ │ │ └── XRayException.java │ │ │ │ └── util │ │ │ │ ├── EnvReader.java │ │ │ │ ├── LambdaOutputStream.java │ │ │ │ └── UnsafeUtil.java │ │ └── jni │ │ │ ├── Dockerfile.glibc │ │ │ ├── Dockerfile.musl │ │ │ ├── build-jni-lib.sh │ │ │ ├── com_amazonaws_services_lambda_crac_DNSManager.cpp │ │ │ ├── com_amazonaws_services_lambda_crac_DNSManager.h │ │ │ ├── com_amazonaws_services_lambda_runtime_api_client_runtimeapi_NativeClient.cpp │ │ │ ├── com_amazonaws_services_lambda_runtime_api_client_runtimeapi_NativeClient.h │ │ │ ├── deps │ │ │ ├── aws-lambda-cpp-0.2.7 │ │ │ │ ├── .clang-format │ │ │ │ ├── .clang-tidy │ │ │ │ ├── .github │ │ │ │ │ └── PULL_REQUEST_TEMPLATE.md │ │ │ │ ├── .gitignore │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── CODE_OF_CONDUCT.md │ │ │ │ ├── CONTRIBUTING.md │ │ │ │ ├── LICENSE │ │ │ │ ├── NOTICE │ │ │ │ ├── README.md │ │ │ │ ├── ci │ │ │ │ │ ├── codebuild │ │ │ │ │ │ ├── amazonlinux-2017.03.yml │ │ │ │ │ │ ├── build-cpp-sdk.sh │ │ │ │ │ │ ├── build.sh │ │ │ │ │ │ ├── format-check.sh │ │ │ │ │ │ ├── run-tests.sh │ │ │ │ │ │ └── ubuntu-18.04.yml │ │ │ │ │ └── docker │ │ │ │ │ │ ├── alpine-linux-3.8 │ │ │ │ │ │ ├── amazon-linux-2017.03 │ │ │ │ │ │ └── ubuntu-linux-18.04 │ │ │ │ ├── cmake │ │ │ │ │ └── aws-lambda-runtime-config.cmake │ │ │ │ ├── examples │ │ │ │ │ ├── Dockerfile │ │ │ │ │ ├── api-gateway │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ └── main.cpp │ │ │ │ │ ├── dynamodb │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ └── main.cpp │ │ │ │ │ └── s3 │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ └── main.cpp │ │ │ │ ├── include │ │ │ │ │ └── aws │ │ │ │ │ │ ├── http │ │ │ │ │ │ └── response.h │ │ │ │ │ │ ├── lambda-runtime │ │ │ │ │ │ ├── outcome.h │ │ │ │ │ │ ├── runtime.h │ │ │ │ │ │ └── version.h │ │ │ │ │ │ └── logging │ │ │ │ │ │ └── logging.h │ │ │ │ ├── packaging │ │ │ │ │ └── packager │ │ │ │ ├── src │ │ │ │ │ ├── backward.cpp │ │ │ │ │ ├── backward.h │ │ │ │ │ ├── logging.cpp │ │ │ │ │ ├── runtime.cpp │ │ │ │ │ └── version.cpp.in │ │ │ │ └── tests │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ ├── gtest │ │ │ │ │ ├── .clang-tidy │ │ │ │ │ ├── gtest-all.cc │ │ │ │ │ └── gtest.h │ │ │ │ │ ├── main.cpp │ │ │ │ │ ├── resources │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── lambda_function.cpp │ │ │ │ │ ├── runtime_tests.cpp │ │ │ │ │ └── version_tests.cpp │ │ │ ├── curl-7.83.1.tar.gz │ │ │ └── curl_001_disable_wakeup.patch │ │ │ └── macro.h │ └── test │ │ └── java │ │ ├── com │ │ └── amazonaws │ │ │ └── services │ │ │ └── lambda │ │ │ ├── crac │ │ │ ├── ContextImplTest.java │ │ │ └── DNSCacheManagerTest.java │ │ │ └── runtime │ │ │ └── api │ │ │ └── client │ │ │ ├── ClasspathLoaderTest.java │ │ │ ├── CustomerClassLoaderTest.java │ │ │ ├── EventHandlerLoaderTest.java │ │ │ ├── HandlerInfoTest.java │ │ │ ├── LambdaRequestHandler.java │ │ │ ├── PojoSerializerLoaderTest.java │ │ │ ├── TooManyServiceProvidersFoundExceptionTest.java │ │ │ ├── UserFaultTest.java │ │ │ ├── XRayErrorCauseTest.java │ │ │ ├── api │ │ │ └── LambdaContextTest.java │ │ │ ├── logging │ │ │ ├── AbstractLambdaLoggerTest.java │ │ │ ├── FrameTypeTest.java │ │ │ ├── FramedTelemetryLogSinkTest.java │ │ │ ├── JsonLogFormatterTest.java │ │ │ ├── StdOutLogSinkTest.java │ │ │ └── TextLogFormatterTest.java │ │ │ ├── runtimeapi │ │ │ ├── LambdaRuntimeApiClientImplTest.java │ │ │ └── converters │ │ │ │ └── LambdaErrorConverterTest.java │ │ │ └── util │ │ │ ├── LambdaOutputStreamTest.java │ │ │ └── UnsafeUtilTest.java │ │ ├── test │ │ └── lambda │ │ │ └── handlers │ │ │ ├── POJOHanlderImpl.java │ │ │ ├── RequestHandlerImpl.java │ │ │ └── RequestStreamHandlerImpl.java │ │ └── testpkg │ │ └── StackTraceHelper.java └── test │ └── integration │ ├── .gitignore │ ├── codebuild-local │ ├── Dockerfile.agent │ ├── codebuild_build.sh │ ├── test_all.sh │ └── test_one.sh │ ├── codebuild │ ├── buildspec.os.alpine.yml │ ├── buildspec.os.amazoncorretto.yml │ ├── buildspec.os.amazonlinux.1.yml │ ├── buildspec.os.amazonlinux.2.yml │ ├── buildspec.os.centos.yml │ ├── buildspec.os.debian.yml │ ├── buildspec.os.ubuntu.yml │ └── scripts │ │ ├── clean_up.sh │ │ ├── configure_multi_arch_env.sh │ │ ├── fetch_test_container_logs.sh │ │ └── run_invocation_test.sh │ ├── docker │ ├── Dockerfile.function.alpine │ ├── Dockerfile.function.amazoncorretto │ ├── Dockerfile.function.amazonlinux │ ├── Dockerfile.function.centos │ ├── Dockerfile.function.debian │ └── Dockerfile.function.ubuntu │ ├── resources │ ├── aws-lambda-rie-arm64.tar.gz │ └── aws-lambda-rie.tar.gz │ └── test-handler │ ├── pom.xml │ └── src │ └── main │ └── java │ └── helloworld │ └── App.java ├── aws-lambda-java-serialization ├── RELEASE.CHANGELOG.md ├── pom.xml ├── src │ └── main │ │ └── java │ │ └── com │ │ └── amazonaws │ │ └── services │ │ └── lambda │ │ └── runtime │ │ └── serialization │ │ ├── PojoSerializer.java │ │ ├── events │ │ ├── LambdaEventSerializers.java │ │ ├── mixins │ │ │ ├── CloudFormationCustomResourceEventMixin.java │ │ │ ├── CloudFrontEventMixin.java │ │ │ ├── CloudWatchLogsEventMixin.java │ │ │ ├── CodeCommitEventMixin.java │ │ │ ├── ConnectEventMixin.java │ │ │ ├── DynamodbEventMixin.java │ │ │ ├── DynamodbTimeWindowEventMixin.java │ │ │ ├── KinesisEventMixin.java │ │ │ ├── KinesisTimeWindowEventMixin.java │ │ │ ├── SNSEventMixin.java │ │ │ ├── SQSEventMixin.java │ │ │ ├── ScheduledEventMixin.java │ │ │ └── SecretsManagerRotationEventMixin.java │ │ ├── modules │ │ │ ├── DateModule.java │ │ │ └── DateTimeModule.java │ │ └── serializers │ │ │ ├── OrgJsonSerializer.java │ │ │ └── S3EventSerializer.java │ │ ├── factories │ │ ├── GsonFactory.java │ │ ├── JacksonFactory.java │ │ └── PojoSerializerFactory.java │ │ └── util │ │ ├── Functions.java │ │ ├── LambdaByteArrayOutputStream.java │ │ ├── ReflectUtil.java │ │ └── SerializeUtil.java └── verify-relocation.sh ├── aws-lambda-java-tests ├── README.md ├── RELEASE.CHANGELOG.md ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── amazonaws │ │ └── services │ │ └── lambda │ │ └── runtime │ │ └── tests │ │ ├── EventArgumentsProvider.java │ │ ├── EventLoader.java │ │ ├── EventLoadingException.java │ │ ├── EventsArgumentsProvider.java │ │ ├── HandlerParamsArgumentsProvider.java │ │ └── annotations │ │ ├── Event.java │ │ ├── Events.java │ │ ├── HandlerParams.java │ │ ├── Response.java │ │ └── Responses.java │ └── test │ ├── java │ └── com │ │ └── amazonaws │ │ └── services │ │ └── lambda │ │ └── runtime │ │ └── tests │ │ ├── EventLoaderTest.java │ │ ├── EventTest.java │ │ ├── EventsTest.java │ │ ├── HandlerParamsTest.java │ │ └── S3BatchEventV2Test.java │ └── resources │ ├── apigw │ ├── events │ │ ├── apigw_event.json │ │ └── apigw_event_nobody.json │ └── responses │ │ ├── apigw_response.json │ │ └── apigw_response2.json │ ├── apigw_auth.json │ ├── apigw_auth_v2.json │ ├── apigw_http_event.json │ ├── apigw_rest_event.json │ ├── cloudformation_event.json │ ├── cloudfront_event.json │ ├── cloudwatch_composite_alarm.json │ ├── cloudwatch_event.json │ ├── cloudwatch_metric_alarm.json │ ├── cloudwatchlogs_event.json │ ├── codecommit_event.json │ ├── cognito_user_pool_pre_token_generation_event_v2.json │ ├── config_event.json │ ├── connect_event.json │ ├── ddb │ ├── dynamo_ddb_stream_record.json │ └── dynamo_event.json │ ├── elb_event.json │ ├── firehose_event.json │ ├── kafka_event.json │ ├── kinesis_event.json │ ├── lambda_destination_event.json │ ├── lex_event.json │ ├── mq_event.json │ ├── msk_firehose_event.json │ ├── rabbitmq_event.json │ ├── s3_batch_event_v2.json │ ├── s3_event.json │ ├── secrets_rotation_event.json │ ├── sns_event.json │ └── sqs │ ├── sqs_event_nobody.json │ └── sqs_event_product.json ├── experimental └── aws-lambda-java-profiler │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties │ ├── README.md │ ├── RELEASE.CHANGELOG.md │ ├── docs │ ├── Arch_AWS-Lambda_64.svg │ ├── example-cold-start-flame-graph-small.png │ └── example-cold-start-flame-graph.png │ ├── examples │ ├── cdk │ │ ├── .gitignore │ │ ├── README.md │ │ ├── cdk.json │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── myorg │ │ │ ├── InfraApp.java │ │ │ └── InfraStack.java │ └── function │ │ └── profiling-example │ │ ├── pom.xml │ │ └── src │ │ ├── main │ │ └── java │ │ │ └── helloworld │ │ │ └── App.java │ │ └── test │ │ └── java │ │ └── helloworld │ │ └── AppTest.java │ ├── extension │ ├── build.gradle │ ├── build_layer.sh │ ├── extensions │ │ └── profiler-extension │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── amazonaws │ │ └── services │ │ └── lambda │ │ └── extension │ │ ├── ExtensionClient.java │ │ ├── ExtensionMain.java │ │ ├── Logger.java │ │ ├── PreMain.java │ │ ├── S3Manager.java │ │ └── ShutdownHook.java │ ├── integration_tests │ ├── cleanup.sh │ ├── create_bucket.sh │ ├── create_function.sh │ ├── download_from_s3.sh │ ├── helloworld │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── helloworld │ │ │ │ └── Handler.java │ │ │ └── resources │ │ │ └── wrapper.sh │ ├── invoke_function.sh │ └── publish_layer.sh │ └── update-function.sh ├── git-config └── hooks │ └── pre-commit └── samples ├── custom-serialization ├── .gitignore ├── README.md ├── fastJson │ ├── HelloWorldFunction │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ ├── com │ │ │ │ └── example │ │ │ │ │ └── vehicles │ │ │ │ │ └── serialization │ │ │ │ │ └── FastJsonSerializer.java │ │ │ └── helloworld │ │ │ │ ├── App.java │ │ │ │ └── Vehicle.java │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── services │ │ │ └── com.amazonaws.services.lambda.runtime.CustomPojoSerializer │ ├── README.md │ ├── events │ │ └── event.json │ └── template.yaml ├── gson │ ├── HelloWorldFunction │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ ├── com │ │ │ │ └── example │ │ │ │ │ └── vehicles │ │ │ │ │ └── serialization │ │ │ │ │ └── GsonSerializer.java │ │ │ └── helloworld │ │ │ │ ├── App.java │ │ │ │ └── Vehicle.java │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── services │ │ │ └── com.amazonaws.services.lambda.runtime.CustomPojoSerializer │ ├── README.md │ ├── events │ │ └── event.json │ └── template.yaml ├── jackson-jr │ ├── HelloWorldFunction │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ ├── com │ │ │ │ └── example │ │ │ │ │ └── vehicles │ │ │ │ │ └── serialization │ │ │ │ │ └── JacksonJRSerializer.java │ │ │ └── helloworld │ │ │ │ ├── App.java │ │ │ │ └── Vehicle.java │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── services │ │ │ └── com.amazonaws.services.lambda.runtime.CustomPojoSerializer │ ├── README.md │ ├── events │ │ └── event.json │ └── template.yaml ├── moshi │ ├── HelloWorldFunction │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ ├── com │ │ │ │ └── example │ │ │ │ │ └── vehicles │ │ │ │ │ └── serialization │ │ │ │ │ └── MoshiSerializer.java │ │ │ └── helloworld │ │ │ │ ├── App.java │ │ │ │ └── Vehicle.java │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── services │ │ │ └── com.amazonaws.services.lambda.runtime.CustomPojoSerializer │ ├── README.md │ ├── events │ │ └── event.json │ └── template.yaml └── request-stream-handler │ ├── HelloWorldFunction │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── helloworld │ │ ├── App.java │ │ └── Vehicle.java │ ├── README.md │ ├── events │ └── event.json │ └── template.yaml ├── kinesis-firehose-event-handler ├── pom.xml └── src │ ├── main │ └── java │ │ └── example │ │ └── KinesisFirehoseEventHandler.java │ └── test │ ├── java │ └── example │ │ └── KinesisFirehoseEventHandlerTest.java │ └── resources │ └── event.json └── msk-firehose-event-handler └── src ├── main └── java │ └── example │ └── MSKFirehoseEventHandler.java └── test ├── java └── example │ └── MSKFirehoseEventHandlerTest.java └── resources └── event.json /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | *Target (OCI, Managed Runtime, both):* 6 | 7 | 8 | By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" -------------------------------------------------------------------------------- /.github/workflows/aws-lambda-java-core.yml: -------------------------------------------------------------------------------- 1 | # This workflow will be triggered if there will be changes to aws-lambda-java-core 2 | # package and it builds the package and the packages that depend on it. 3 | 4 | name: Java CI aws-lambda-java-core 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | paths: 10 | - 'aws-lambda-java-core/**' 11 | pull_request: 12 | branches: [ '*' ] 13 | paths: 14 | - 'aws-lambda-java-core/**' 15 | - '.github/workflows/aws-lambda-java-core.yml' 16 | 17 | jobs: 18 | build: 19 | 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | - name: Set up JDK 1.8 25 | uses: actions/setup-java@v4 26 | with: 27 | java-version: 8 28 | distribution: corretto 29 | 30 | # Install base module 31 | - name: Install core with Maven 32 | run: mvn -B install --file aws-lambda-java-core/pom.xml 33 | 34 | # Package modules that depend on base module 35 | - name: Package log4j2 with Maven 36 | run: mvn -B package --file aws-lambda-java-log4j2/pom.xml 37 | 38 | # Test Runtime Interface Client 39 | - name: Run 'pr' target 40 | working-directory: ./aws-lambda-java-runtime-interface-client 41 | run: make pr 42 | env: 43 | IS_JAVA_8: true 44 | -------------------------------------------------------------------------------- /.github/workflows/aws-lambda-java-events-sdk-transformer.yml: -------------------------------------------------------------------------------- 1 | # This workflow will be triggered if there will be changes to 2 | # aws-lambda-java-events-sdk-transformer package and it builds the package. 3 | 4 | name: Java CI aws-lambda-java-events-sdk-transformer 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | paths: 10 | - 'aws-lambda-java-events-sdk-transformer/**' 11 | pull_request: 12 | branches: [ '*' ] 13 | paths: 14 | - 'aws-lambda-java-events-sdk-transformer/**' 15 | - '.github/workflows/aws-lambda-java-events-sdk-transformer.yml' 16 | 17 | jobs: 18 | build: 19 | 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | - name: Set up JDK 1.8 25 | uses: actions/setup-java@v4 26 | with: 27 | java-version: 8 28 | distribution: corretto 29 | 30 | # Install base module 31 | - name: Install events with Maven 32 | run: mvn -B install --file aws-lambda-java-events/pom.xml 33 | # Package target module 34 | - name: Package events-sdk-transformer with Maven 35 | run: mvn -B package --file aws-lambda-java-events-sdk-transformer/pom.xml 36 | 37 | -------------------------------------------------------------------------------- /.github/workflows/aws-lambda-java-events.yml: -------------------------------------------------------------------------------- 1 | # This workflow will be triggered if there will be changes to aws-lambda-java-events 2 | # package and it builds the package and the packages that depend on it. 3 | 4 | name: Java CI aws-lambda-java-events 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | paths: 10 | - 'aws-lambda-java-events/**' 11 | pull_request: 12 | branches: [ '*' ] 13 | paths: 14 | - 'aws-lambda-java-events/**' 15 | - '.github/workflows/aws-lambda-java-events.yml' 16 | 17 | jobs: 18 | build: 19 | 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | - name: Set up JDK 1.8 25 | uses: actions/setup-java@v4 26 | with: 27 | java-version: 8 28 | distribution: corretto 29 | 30 | # Install base module 31 | - name: Install events with Maven 32 | run: mvn -B install --file aws-lambda-java-events/pom.xml 33 | 34 | # Package modules that depend on base module 35 | - name: Package serialization with Maven 36 | run: mvn -B package --file aws-lambda-java-serialization/pom.xml 37 | - name: Package events-sdk-transformer with Maven 38 | run: mvn -B package --file aws-lambda-java-events-sdk-transformer/pom.xml 39 | 40 | -------------------------------------------------------------------------------- /.github/workflows/aws-lambda-java-log4j2.yml: -------------------------------------------------------------------------------- 1 | # This workflow will be triggered if there will be changes to 2 | # aws-lambda-java-log4j2 package and it builds the package. 3 | 4 | name: Java CI aws-lambda-java-log4j2 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | paths: 10 | - 'aws-lambda-java-log4j2/**' 11 | pull_request: 12 | branches: [ '*' ] 13 | paths: 14 | - 'aws-lambda-java-log4j2/**' 15 | - '.github/workflows/aws-lambda-java-log4j2.yml' 16 | 17 | jobs: 18 | build: 19 | 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | - name: Set up JDK 1.8 25 | uses: actions/setup-java@v4 26 | with: 27 | java-version: 8 28 | distribution: corretto 29 | 30 | # Install base module 31 | - name: Install core with Maven 32 | run: mvn -B install --file aws-lambda-java-core/pom.xml 33 | # Package target module 34 | - name: Package log4j2 with Maven 35 | run: mvn -B package --file aws-lambda-java-log4j2/pom.xml 36 | 37 | -------------------------------------------------------------------------------- /.github/workflows/aws-lambda-java-serialization.yml: -------------------------------------------------------------------------------- 1 | # This workflow will be triggered if there will be changes to aws-lambda-java-serialization 2 | # package and it builds the package and the packages that depend on it. 3 | 4 | name: Java CI aws-lambda-java-serialization 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | paths: 10 | - 'aws-lambda-java-serialization/**' 11 | pull_request: 12 | branches: [ '*' ] 13 | paths: 14 | - 'aws-lambda-java-serialization/**' 15 | - '.github/workflows/aws-lambda-java-serialization.yml' 16 | 17 | jobs: 18 | build: 19 | 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | - name: Set up JDK 1.8 25 | uses: actions/setup-java@v4 26 | with: 27 | java-version: 8 28 | distribution: corretto 29 | 30 | # Install base module 31 | - name: Install events with Maven 32 | run: mvn -B install --file aws-lambda-java-events/pom.xml 33 | 34 | # Package and install target module 35 | - name: Package serialization with Maven 36 | run: mvn -B package install --file aws-lambda-java-serialization/pom.xml 37 | 38 | # Run tests 39 | - name: Run tests from aws-lambda-java-tests 40 | run: mvn test --file aws-lambda-java-tests/pom.xml 41 | -------------------------------------------------------------------------------- /.github/workflows/aws-lambda-java-tests.yml: -------------------------------------------------------------------------------- 1 | # This workflow will be triggered if there will be changes to aws-lambda-java-tests 2 | # package and it builds the package and the packages that depend on it. 3 | 4 | name: Java CI aws-lambda-java-tests 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | paths: 10 | - 'aws-lambda-java-tests/**' 11 | pull_request: 12 | branches: [ '*' ] 13 | paths: 14 | - 'aws-lambda-java-tests/**' 15 | - '.github/workflows/aws-lambda-java-tests.yml' 16 | 17 | jobs: 18 | build: 19 | 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | - name: Set up JDK 1.8 25 | uses: actions/setup-java@v4 26 | with: 27 | java-version: 8 28 | distribution: corretto 29 | 30 | # Install base module 31 | - name: Install events with Maven 32 | run: mvn -B install --file aws-lambda-java-events/pom.xml 33 | - name: Install serialization with Maven 34 | run: mvn -B install --file aws-lambda-java-serialization/pom.xml 35 | 36 | # Package target module 37 | - name: Package tests with Maven 38 | run: mvn -B package --file aws-lambda-java-tests/pom.xml 39 | 40 | -------------------------------------------------------------------------------- /.github/workflows/repo-sync.yml: -------------------------------------------------------------------------------- 1 | name: Repo Sync 2 | 3 | on: 4 | schedule: 5 | - cron: "0 8 * * 1-5" # At 08:00 on every day-of-week from Monday through Friday 6 | pull_request: 7 | branches: [ '*' ] 8 | paths: 9 | - '.github/workflows/repo-sync.yml' 10 | workflow_dispatch: 11 | 12 | jobs: 13 | repo-sync: 14 | name: Repo Sync 15 | runs-on: ubuntu-latest 16 | env: 17 | IS_CONFIGURED: ${{ secrets.SOURCE_REPO != '' }} 18 | steps: 19 | - uses: actions/checkout@v4 20 | if: ${{ env.IS_CONFIGURED == 'true' }} 21 | - uses: repo-sync/github-sync@v2 22 | name: Sync repo to branch 23 | if: ${{ env.IS_CONFIGURED == 'true' }} 24 | with: 25 | source_repo: ${{ secrets.SOURCE_REPO }} 26 | source_branch: main 27 | destination_branch: ${{ secrets.INTERMEDIATE_BRANCH }} 28 | github_token: ${{ secrets.GITHUB_TOKEN }} 29 | - uses: repo-sync/pull-request@v2 30 | name: Create pull request 31 | if: ${{ env.IS_CONFIGURED == 'true' }} 32 | with: 33 | source_branch: ${{ secrets.INTERMEDIATE_BRANCH }} 34 | destination_branch: main 35 | github_token: ${{ secrets.GITHUB_TOKEN }} 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | 14 | # Maven build 15 | target/ 16 | dependency-reduced-pom.xml 17 | 18 | # IDEA internal 19 | *.iml 20 | .idea 21 | .gradle 22 | .settings 23 | .classpath 24 | .project 25 | 26 | # OSX 27 | .DS_Store 28 | 29 | # snapshot process 30 | aws-lambda-java-runtime-interface-client/pom.xml.versionsBackup 31 | 32 | # profiler 33 | experimental/aws-lambda-java-profiler/integration_tests/helloworld/build 34 | experimental/aws-lambda-java-profiler/extension/build/ 35 | experimental/aws-lambda-java-profiler/integration_tests/helloworld/bin 36 | !experimental/aws-lambda-java-profiler/extension/gradle/wrapper/*.jar 37 | /scratch/ 38 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /aws-lambda-java-core/RELEASE.CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### May 26, 2025 2 | `1.3.0` 3 | - Adding support for multi tenancy ([#545](https://github.com/aws/aws-lambda-java-libs/pull/545)) 4 | 5 | ### August 17, 2023 6 | `1.2.3`: 7 | - Extended logger interface with level-aware logging backend functions 8 | 9 | ### November 09, 2022 10 | `1.2.2`: 11 | - Added new `CustomPojoSerializer` interface 12 | - Removed unnecessary usage of public on interface methods (aws#172) 13 | 14 | ### April 28, 2020 15 | `1.2.1`: 16 | - Added missing XML namespace declarations to `pom.xml` file ([#97](https://github.com/aws/aws-lambda-java-libs/issues/97)) 17 | - Updated `nexusUrl` in `pom.xml` file ([#108](https://github.com/aws/aws-lambda-java-libs/issues/108)) 18 | 19 | ### November 21, 2017 20 | `1.2.0`: 21 | - Added method to log byte array to `LambdaLogger` 22 | 23 | ### October 07, 2015 24 | `1.1.0`: 25 | - Added `LambdaRuntime` and `LambdaRuntimeInternal` 26 | - Added `getInstallationId()` to `Client` 27 | - Added `getFunctionVersion()` and `getInvokedFunctionArn()` to `Context` 28 | 29 | ### June 15, 2015 30 | `1.0.0`: 31 | - Initial support for java in AWS Lambda 32 | -------------------------------------------------------------------------------- /aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/Client.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime; 4 | 5 | /** 6 | * Contains information about the client application that invoked the Lambda function. 7 | * 8 | */ 9 | public interface Client { 10 | 11 | /** 12 | * Gets the application's installation id 13 | */ 14 | String getInstallationId(); 15 | 16 | /** 17 | * Gets the application's title 18 | * 19 | */ 20 | String getAppTitle(); 21 | 22 | /** 23 | * Gets the application's version 24 | * 25 | */ 26 | String getAppVersionName(); 27 | 28 | /** 29 | * Gets the application's version code 30 | * 31 | */ 32 | String getAppVersionCode(); 33 | 34 | /** 35 | * Gets the application's package name 36 | */ 37 | String getAppPackageName(); 38 | } 39 | -------------------------------------------------------------------------------- /aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/ClientContext.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * 9 | * Provides information about client configuration and execution environment. 10 | * 11 | */ 12 | public interface ClientContext { 13 | /** 14 | * Gets the client information provided by the AWS Mobile SDK 15 | * 16 | */ 17 | Client getClient(); 18 | 19 | /** 20 | * Gets custom values set by the client application 21 | *

22 | * This map is mutable (and not thread-safe if mutated) 23 | *

24 | */ 25 | Map getCustom(); 26 | 27 | /** 28 | * Gets environment information provided by mobile SDK, immutable. 29 | * 30 | */ 31 | Map getEnvironment(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/CognitoIdentity.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime; 4 | 5 | /** 6 | * Provides information related to Amazon Congnito identities. 7 | * 8 | */ 9 | public interface CognitoIdentity { 10 | /** 11 | * Gets the Amazon Cognito identity ID 12 | * 13 | */ 14 | String getIdentityId(); 15 | 16 | /** 17 | * Gets the Amazon Cognito identity pool ID 18 | * 19 | */ 20 | String getIdentityPoolId(); 21 | } 22 | -------------------------------------------------------------------------------- /aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/CustomPojoSerializer.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime; 4 | 5 | import java.io.InputStream; 6 | import java.io.OutputStream; 7 | 8 | import java.lang.reflect.Type; 9 | 10 | /** 11 | * Interface required to implement a custom plain old java objects serializer 12 | */ 13 | public interface CustomPojoSerializer { 14 | 15 | /** 16 | * Deserializes from input stream to plain old java object 17 | * @param input input stream 18 | * @param type plain old java object type 19 | * @return deserialized plain old java object of type T 20 | */ 21 | T fromJson(InputStream input, Type type); 22 | 23 | /** 24 | * Deserializes from String to plain old java object 25 | * @param input input string 26 | * @param type plain old java object type 27 | * @return deserialized plain old java object of type T 28 | */ 29 | T fromJson(String input, Type type); 30 | 31 | /** 32 | * Serializes plain old java object to output stream 33 | * @param value instance of type T to be serialized 34 | * @param output OutputStream to serialize plain old java object to 35 | * @param type plain old java object type 36 | */ 37 | void toJson(T value, OutputStream output, Type type); 38 | } 39 | -------------------------------------------------------------------------------- /aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/LambdaLogger.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime; 4 | 5 | import com.amazonaws.services.lambda.runtime.logging.LogLevel; 6 | 7 | /** 8 | * A low level Lambda runtime logger 9 | * 10 | */ 11 | public interface LambdaLogger { 12 | 13 | /** 14 | * Logs a string to AWS CloudWatch Logs 15 | * 16 | *

17 | * Logging will not be done: 18 | *

    19 | *
  • 20 | * If the container is not configured to log to CloudWatch. 21 | *
  • 22 | *
  • 23 | * If the role provided to the function does not have sufficient permissions. 24 | *
  • 25 | *
26 | *

27 | * 28 | * @param message A string containing the event to log. 29 | */ 30 | void log(String message); 31 | 32 | /** 33 | * Logs a byte array to AWS CloudWatch Logs 34 | * @param message byte array containing logs 35 | */ 36 | void log(byte[] message); 37 | 38 | /** 39 | * LogLevel aware logging backend function. 40 | * 41 | * @param message in String format 42 | * @param logLevel 43 | */ 44 | default void log(String message, LogLevel logLevel) { 45 | log(message); 46 | } 47 | 48 | /** 49 | * LogLevel aware logging backend function. 50 | * 51 | * @param message in byte[] format 52 | * @param logLevel 53 | */ 54 | default void log(byte[] message, LogLevel logLevel) { 55 | log(message); 56 | } 57 | 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/LambdaRuntime.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | package com.amazonaws.services.lambda.runtime; 3 | 4 | import java.io.IOException; 5 | 6 | public final class LambdaRuntime { 7 | private LambdaRuntime() {} 8 | 9 | private static volatile LambdaLogger logger = new LambdaLogger() { 10 | 11 | public void log(String message) { 12 | System.out.print(message); 13 | } 14 | 15 | public void log(byte[] message) { 16 | try { 17 | System.out.write(message); 18 | } catch (IOException e) { 19 | // NOTE: When actually running on AWS Lambda, an IOException would never happen 20 | e.printStackTrace(); 21 | } 22 | } 23 | }; 24 | 25 | /** 26 | * Returns the global lambda logger instance 27 | * 28 | */ 29 | public static LambdaLogger getLogger() { 30 | return logger; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/LambdaRuntimeInternal.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime; 4 | 5 | /** 6 | * This class is used internally by Lambda Runtime. 7 | */ 8 | public final class LambdaRuntimeInternal { 9 | private LambdaRuntimeInternal() {} 10 | 11 | private static boolean useLog4jAppender; 12 | 13 | public static void setUseLog4jAppender(boolean useLog4j) { 14 | useLog4jAppender = useLog4j; 15 | } 16 | 17 | public static boolean getUseLog4jAppender() { 18 | return useLog4jAppender; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime; 2 | 3 | import com.amazonaws.services.lambda.runtime.Context; 4 | 5 | /** 6 | * 7 | * Lambda request handlers implement AWS Lambda Function application logic using plain old java objects 8 | * as input and output. 9 | * 10 | * @param The input parameter type 11 | * @param The output parameter type 12 | */ 13 | public interface RequestHandler { 14 | /** 15 | * Handles a Lambda Function request 16 | * @param input The Lambda Function input 17 | * @param context The Lambda execution environment context object. 18 | * @return The Lambda Function output 19 | */ 20 | O handleRequest(I input, Context context); 21 | } 22 | -------------------------------------------------------------------------------- /aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestStreamHandler.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime; 4 | 5 | import java.io.InputStream; 6 | import java.io.OutputStream; 7 | import java.io.IOException; 8 | 9 | /** 10 | * Low-level request-handling interface, Lambda stream request handlers implement AWS Lambda Function application logic 11 | * using input and output stream 12 | */ 13 | public interface RequestStreamHandler { 14 | /** 15 | * Handles a Lambda Function request 16 | * @param input The Lambda Function input stream 17 | * @param output The Lambda function output stream 18 | * @param context The Lambda execution environment context object. 19 | * @throws IOException 20 | */ 21 | void handleRequest(InputStream input, OutputStream output, Context context) throws IOException; 22 | } 23 | -------------------------------------------------------------------------------- /aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/logging/LogFormat.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.logging; 4 | 5 | 6 | public enum LogFormat { 7 | JSON, 8 | TEXT; 9 | 10 | public static LogFormat fromString(String logFormat) { 11 | try { 12 | return LogFormat.valueOf(logFormat.toUpperCase()); 13 | } catch (Exception e) { 14 | throw new IllegalArgumentException("Invalid log format: '" + logFormat + "' expected one of [JSON, TEXT]"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/logging/LogLevel.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.logging; 4 | 5 | 6 | public enum LogLevel { 7 | // UNDEFINED log level is used when the legacy LambdaLogger::log(String) function is called 8 | // where the loglevel is not defined. In this case we're not filtering the message in the runtime 9 | UNDEFINED, 10 | TRACE, 11 | DEBUG, 12 | INFO, 13 | WARN, 14 | ERROR, 15 | FATAL; 16 | 17 | public static LogLevel fromString(String logLevel) { 18 | try { 19 | return LogLevel.valueOf(logLevel.toUpperCase()); 20 | } catch (Exception e) { 21 | throw new IllegalArgumentException( 22 | "Invalid log level: '" + logLevel + "' expected one of [TRACE, DEBUG, INFO, WARN, ERROR, FATAL]"); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v1/DynamodbEventTransformer.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events.transformers.v1; 2 | 3 | import com.amazonaws.services.dynamodbv2.model.Record; 4 | import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; 5 | import com.amazonaws.services.lambda.runtime.events.transformers.v1.dynamodb.DynamodbRecordTransformer; 6 | 7 | import java.util.List; 8 | import java.util.Objects; 9 | import java.util.stream.Collectors; 10 | 11 | public class DynamodbEventTransformer { 12 | 13 | public static List toRecordsV1(final DynamodbEvent dynamodbEvent) { 14 | return dynamodbEvent 15 | .getRecords() 16 | .stream() 17 | .filter(record -> !Objects.isNull(record)) 18 | .map(DynamodbRecordTransformer::toRecordV1) 19 | .collect(Collectors.toList()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v1/dynamodb/DynamodbIdentityTransformer.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events.transformers.v1.dynamodb; 2 | 3 | import com.amazonaws.services.dynamodbv2.model.Identity; 4 | 5 | public class DynamodbIdentityTransformer { 6 | 7 | public static Identity toIdentityV1(final com.amazonaws.services.lambda.runtime.events.models.dynamodb.Identity identity) { 8 | return new Identity() 9 | .withPrincipalId(identity.getPrincipalId()) 10 | .withType(identity.getType()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v1/dynamodb/DynamodbRecordTransformer.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events.transformers.v1.dynamodb; 2 | 3 | import com.amazonaws.services.dynamodbv2.model.Record; 4 | import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; 5 | 6 | public class DynamodbRecordTransformer { 7 | 8 | public static Record toRecordV1(final DynamodbEvent.DynamodbStreamRecord record) { 9 | return new Record() 10 | .withAwsRegion(record.getAwsRegion()) 11 | .withDynamodb( 12 | DynamodbStreamRecordTransformer.toStreamRecordV1(record.getDynamodb()) 13 | ) 14 | .withEventID(record.getEventID()) 15 | .withEventName(record.getEventName()) 16 | .withEventSource(record.getEventSource()) 17 | .withEventVersion(record.getEventVersion()) 18 | .withUserIdentity( 19 | record.getUserIdentity() != null 20 | ? DynamodbIdentityTransformer.toIdentityV1(record.getUserIdentity()) 21 | : null 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2/DynamodbEventTransformer.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events.transformers.v2; 2 | 3 | import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; 4 | import com.amazonaws.services.lambda.runtime.events.transformers.v2.dynamodb.DynamodbRecordTransformer; 5 | import software.amazon.awssdk.services.dynamodb.model.Record; 6 | 7 | import java.util.List; 8 | import java.util.Objects; 9 | import java.util.stream.Collectors; 10 | 11 | public class DynamodbEventTransformer { 12 | 13 | public static List toRecordsV2(final DynamodbEvent dynamodbEvent) { 14 | return dynamodbEvent 15 | .getRecords() 16 | .stream() 17 | .filter(record -> !Objects.isNull(record)) 18 | .map(DynamodbRecordTransformer::toRecordV2) 19 | .collect(Collectors.toList()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2/dynamodb/DynamodbIdentityTransformer.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events.transformers.v2.dynamodb; 2 | 3 | import software.amazon.awssdk.services.dynamodb.model.Identity; 4 | 5 | public class DynamodbIdentityTransformer { 6 | 7 | public static Identity toIdentityV2(final com.amazonaws.services.lambda.runtime.events.models.dynamodb.Identity identity) { 8 | return Identity.builder() 9 | .principalId(identity.getPrincipalId()) 10 | .type(identity.getType()) 11 | .build(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2/dynamodb/DynamodbRecordTransformer.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events.transformers.v2.dynamodb; 2 | 3 | import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; 4 | import software.amazon.awssdk.services.dynamodb.model.Record; 5 | 6 | public class DynamodbRecordTransformer { 7 | 8 | public static Record toRecordV2(final DynamodbEvent.DynamodbStreamRecord record) { 9 | return Record.builder() 10 | .awsRegion(record.getAwsRegion()) 11 | .dynamodb( 12 | DynamodbStreamRecordTransformer.toStreamRecordV2(record.getDynamodb()) 13 | ) 14 | .eventID(record.getEventID()) 15 | .eventName(record.getEventName()) 16 | .eventSource(record.getEventSource()) 17 | .eventVersion(record.getEventVersion()) 18 | .userIdentity( 19 | record.getUserIdentity() != null 20 | ? DynamodbIdentityTransformer.toIdentityV2(record.getUserIdentity()) 21 | : null 22 | ) 23 | .build(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2/dynamodb/DynamodbStreamRecordTransformer.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events.transformers.v2.dynamodb; 2 | 3 | import software.amazon.awssdk.services.dynamodb.model.StreamRecord; 4 | 5 | public class DynamodbStreamRecordTransformer { 6 | 7 | public static StreamRecord toStreamRecordV2(final com.amazonaws.services.lambda.runtime.events.models.dynamodb.StreamRecord streamRecord) { 8 | 9 | return StreamRecord.builder() 10 | .approximateCreationDateTime( 11 | streamRecord.getApproximateCreationDateTime().toInstant() 12 | ) 13 | .keys( 14 | DynamodbAttributeValueTransformer.toAttributeValueMapV2(streamRecord.getKeys()) 15 | ) 16 | .newImage( 17 | streamRecord.getNewImage() != null 18 | ? DynamodbAttributeValueTransformer.toAttributeValueMapV2(streamRecord.getNewImage()) 19 | : null 20 | ) 21 | .oldImage( 22 | streamRecord.getOldImage() != null 23 | ? DynamodbAttributeValueTransformer.toAttributeValueMapV2(streamRecord.getOldImage()) 24 | : null 25 | ) 26 | .sequenceNumber(streamRecord.getSequenceNumber()) 27 | .sizeBytes(streamRecord.getSizeBytes()) 28 | .streamViewType(streamRecord.getStreamViewType()) 29 | .build(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/v1/dynamodb/DynamodbIdentityTransformerTest.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events.transformers.v1.dynamodb; 2 | 3 | import com.amazonaws.services.dynamodbv2.model.Identity; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Test; 6 | 7 | class DynamodbIdentityTransformerTest { 8 | 9 | private static final String principalId = "1234567890"; 10 | private static final String identityType = "type"; 11 | 12 | //region Identity_event 13 | public static final com.amazonaws.services.lambda.runtime.events.models.dynamodb.Identity identity_event = new com.amazonaws.services.lambda.runtime.events.models.dynamodb.Identity() 14 | .withPrincipalId(principalId) 15 | .withType(identityType); 16 | //endregion 17 | 18 | //region Identity_v1 19 | public static final Identity identity_v1 = new Identity() 20 | .withPrincipalId(principalId) 21 | .withType(identityType); 22 | //endregion 23 | 24 | @Test 25 | public void testToIdentityV1() { 26 | Identity convertedIdentity = DynamodbIdentityTransformer.toIdentityV1(identity_event); 27 | Assertions.assertEquals(identity_v1, convertedIdentity); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /aws-lambda-java-events-sdk-transformer/src/test/java/com/amazonaws/services/lambda/runtime/events/transformers/v2/dynamodb/DynamodbIdentityTransformerTest.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events.transformers.v2.dynamodb; 2 | 3 | import org.junit.jupiter.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | import software.amazon.awssdk.services.dynamodb.model.Identity; 6 | 7 | class DynamodbIdentityTransformerTest { 8 | 9 | private static final String principalId = "1234567890"; 10 | private static final String identityType = "type"; 11 | 12 | //region Identity_event 13 | public static final com.amazonaws.services.lambda.runtime.events.models.dynamodb.Identity identity_event = 14 | new com.amazonaws.services.lambda.runtime.events.models.dynamodb.Identity() 15 | .withPrincipalId(principalId) 16 | .withType(identityType); 17 | //endregion 18 | 19 | //region Identity_v2 20 | public static final Identity identity_v2 = Identity.builder() 21 | .principalId(principalId) 22 | .type(identityType) 23 | .build(); 24 | //endregion 25 | 26 | @Test 27 | public void testToIdentityV2() { 28 | Identity convertedIdentity = DynamodbIdentityTransformer.toIdentityV2(identity_event); 29 | Assertions.assertEquals(identity_v2, convertedIdentity); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2HTTPResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with 5 | * the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 10 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.amazonaws.services.lambda.runtime.events; 15 | 16 | import lombok.AllArgsConstructor; 17 | import lombok.Builder; 18 | import lombok.Data; 19 | import lombok.NoArgsConstructor; 20 | 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | @AllArgsConstructor 25 | @Builder(setterPrefix = "with") 26 | @Data 27 | @NoArgsConstructor 28 | public class APIGatewayV2HTTPResponse { 29 | private int statusCode; 30 | private Map headers; 31 | private Map> multiValueHeaders; 32 | private List cookies; 33 | private String body; 34 | private boolean isBase64Encoded; 35 | } 36 | -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyRequestEvent.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events; 2 | 3 | /** 4 | * @deprecated 5 | * This class is for use with API Gateway WebSockets, and has been renamed explicitly as {@link APIGatewayV2WebSocketEvent} 6 | * To integrate with API Gateway's HTTP API Events, use one of: 7 | * * {@link APIGatewayV2HTTPEvent} (payload version 2.0) 8 | * * {@link APIGatewayProxyRequestEvent} (payload version 1.0) 9 | */ 10 | @Deprecated() 11 | public class APIGatewayV2ProxyRequestEvent extends APIGatewayV2WebSocketEvent {} 12 | -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyResponseEvent.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events; 2 | 3 | /** 4 | * @deprecated 5 | * This class is for responding to API Gateway WebSocket events, and has been renamed explicitly as {@link APIGatewayV2WebSocketResponse} 6 | * To response to API Gateway's HTTP API Events, use {@link APIGatewayV2HTTPResponse} 7 | */ 8 | @Deprecated 9 | public class APIGatewayV2ProxyResponseEvent extends APIGatewayV2WebSocketResponse {} 10 | -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/AppSyncLambdaAuthorizerResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with 5 | * the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 10 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | package com.amazonaws.services.lambda.runtime.events; 14 | 15 | import java.util.Map; 16 | import java.util.List; 17 | 18 | import lombok.AllArgsConstructor; 19 | import lombok.Builder; 20 | import lombok.Data; 21 | import lombok.NoArgsConstructor; 22 | 23 | /** 24 | * Class that represents the output from an AppSync Lambda authorizer invocation. 25 | */ 26 | @Data 27 | @Builder(setterPrefix = "with") 28 | @NoArgsConstructor 29 | @AllArgsConstructor 30 | public class AppSyncLambdaAuthorizerResponse { 31 | 32 | private boolean isAuthorized; 33 | private Map resolverContext; 34 | private List deniedFields; 35 | private int ttlOverride; 36 | } -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ApplicationLoadBalancerRequestEvent.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | 6 | import java.io.Serializable; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | /** 11 | * Class to represent the request event from Application Load Balancer. 12 | * 13 | * @see Using AWS Lambda with an Application Load Balancer 14 | * 15 | * @author msailes 16 | */ 17 | 18 | @NoArgsConstructor 19 | @Data 20 | public class ApplicationLoadBalancerRequestEvent implements Serializable, Cloneable { 21 | 22 | @NoArgsConstructor 23 | @Data 24 | public static class Elb implements Serializable, Cloneable { 25 | 26 | private String targetGroupArn; 27 | 28 | } 29 | 30 | @NoArgsConstructor 31 | @Data 32 | public static class RequestContext implements Serializable, Cloneable { 33 | 34 | private Elb elb; 35 | 36 | } 37 | 38 | private RequestContext requestContext; 39 | private String httpMethod; 40 | private String path; 41 | private Map queryStringParameters; 42 | private Map> multiValueQueryStringParameters; 43 | private Map headers; 44 | private Map> multiValueHeaders; 45 | private String body; 46 | private boolean isBase64Encoded; 47 | 48 | } 49 | -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ApplicationLoadBalancerResponseEvent.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | 6 | import java.io.Serializable; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | /** 11 | * Class to represent the response event to Application Load Balancer. 12 | * 13 | * @see Using AWS Lambda with an Application Load Balancer 14 | * 15 | * @author msailes 16 | */ 17 | 18 | @NoArgsConstructor 19 | @Data 20 | public class ApplicationLoadBalancerResponseEvent implements Serializable, Cloneable { 21 | 22 | private int statusCode; 23 | private String statusDescription; 24 | private boolean isBase64Encoded; 25 | private Map headers; 26 | private Map> multiValueHeaders; 27 | private String body; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/MSKFirehoseEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.events; 7 | 8 | import java.nio.ByteBuffer; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | import lombok.AllArgsConstructor; 13 | import lombok.Builder; 14 | import lombok.Data; 15 | import lombok.NoArgsConstructor; 16 | 17 | @Data 18 | @Builder(setterPrefix = "with") 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | 22 | public class MSKFirehoseEvent { 23 | 24 | private String invocationId; 25 | 26 | private String deliveryStreamArn; 27 | 28 | private String sourceMSKArn; 29 | 30 | private String region; 31 | 32 | private List records; 33 | 34 | @Data 35 | @Builder(setterPrefix = "with") 36 | @NoArgsConstructor 37 | @AllArgsConstructor 38 | public static class Record { 39 | 40 | private ByteBuffer kafkaRecordValue; 41 | 42 | private String recordId; 43 | 44 | private Long approximateArrivalEpoch; 45 | 46 | private Long approximateArrivalTimestamp; 47 | 48 | private Map mskRecordMetadata; 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/S3BatchEvent.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Event to represent the payload which is sent to Lambda by S3 Batch to perform a custom 12 | * action. 13 | * 14 | * https://docs.aws.amazon.com/AmazonS3/latest/dev/batch-ops-invoke-lambda.html 15 | */ 16 | 17 | @Data 18 | @Builder(setterPrefix = "with") 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | public class S3BatchEvent { 22 | 23 | private String invocationSchemaVersion; 24 | private String invocationId; 25 | private Job job; 26 | private List tasks; 27 | 28 | @Data 29 | @Builder(setterPrefix = "with") 30 | @NoArgsConstructor 31 | @AllArgsConstructor 32 | public static class Job { 33 | 34 | private String id; 35 | } 36 | 37 | @Data 38 | @Builder(setterPrefix = "with") 39 | @NoArgsConstructor 40 | @AllArgsConstructor 41 | public static class Task { 42 | 43 | private String taskId; 44 | private String s3Key; 45 | private String s3VersionId; 46 | private String s3BucketArn; 47 | } 48 | } -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/S3BatchEventV2.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * Event to represent the payload which is sent to Lambda by S3 Batch to perform a custom 13 | * action when using invocation schema version 2.0. 14 | * 15 | * https://docs.aws.amazon.com/AmazonS3/latest/dev/batch-ops-invoke-lambda.html 16 | */ 17 | 18 | @Data 19 | @Builder(setterPrefix = "with") 20 | @NoArgsConstructor 21 | @AllArgsConstructor 22 | public class S3BatchEventV2 { 23 | 24 | private String invocationSchemaVersion; 25 | private String invocationId; 26 | private Job job; 27 | private List tasks; 28 | 29 | @Data 30 | @Builder(setterPrefix = "with") 31 | @NoArgsConstructor 32 | @AllArgsConstructor 33 | public static class Job { 34 | 35 | private String id; 36 | private Map userArguments; 37 | } 38 | 39 | @Data 40 | @Builder(setterPrefix = "with") 41 | @NoArgsConstructor 42 | @AllArgsConstructor 43 | public static class Task { 44 | 45 | private String taskId; 46 | private String s3Key; 47 | private String s3VersionId; 48 | private String s3Bucket; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with 5 | * the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 10 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.amazonaws.services.lambda.runtime.events; 15 | 16 | import lombok.AllArgsConstructor; 17 | import lombok.Builder; 18 | import lombok.Data; 19 | import lombok.NoArgsConstructor; 20 | 21 | /** 22 | * Class to represent the events which are sent during a Secrets Manager rotation process. 23 | * 24 | * @see Rotating secrets lambda function overview 25 | * 26 | * @author msailes 27 | */ 28 | 29 | @Data 30 | @Builder(setterPrefix = "with") 31 | @NoArgsConstructor 32 | @AllArgsConstructor 33 | public class SecretsManagerRotationEvent { 34 | 35 | private String step; 36 | private String secretId; 37 | private String clientRequestToken; 38 | private String rotationToken; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SimpleIAMPolicyResponse.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * The simplified IAM Policy response object as described in https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html 12 | * 13 | */ 14 | 15 | @Data 16 | @Builder(setterPrefix = "with") 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | public class SimpleIAMPolicyResponse { 20 | 21 | private boolean isAuthorized; 22 | private Map context; 23 | } -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/models/TimeWindow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with 5 | * the License. A copy of the License is located at 6 | * 7 | * http://aws.amazon.com/apache2.0 8 | * 9 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 10 | * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.amazonaws.services.lambda.runtime.events.models; 15 | 16 | import lombok.AllArgsConstructor; 17 | import lombok.Builder; 18 | import lombok.Data; 19 | import lombok.NoArgsConstructor; 20 | 21 | /** 22 | * Represents a time window. 23 | */ 24 | @Data 25 | @Builder(setterPrefix = "with") 26 | @NoArgsConstructor 27 | @AllArgsConstructor 28 | public class TimeWindow { 29 | 30 | /** 31 | * Window start instant represented as ISO-8601 string. 32 | */ 33 | private String start; 34 | 35 | /** 36 | * Window end instant represented as ISO-8601 string. 37 | */ 38 | private String end; 39 | } 40 | -------------------------------------------------------------------------------- /aws-lambda-java-events/src/main/java/lombok.config: -------------------------------------------------------------------------------- 1 | lombok.getter.noIsPrefix = true 2 | -------------------------------------------------------------------------------- /aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2CustomAuthorizerEventTest.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.events; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import java.time.Instant; 6 | 7 | import static org.junit.jupiter.api.Assertions.assertEquals; 8 | import static org.junit.jupiter.api.Assertions.assertNotNull; 9 | 10 | public class APIGatewayV2CustomAuthorizerEventTest { 11 | 12 | private static final long TIME_EPOCH = 1601306426515L; 13 | private static final String TIME = "28/Sep/2020:15:14:43 +0000"; 14 | 15 | @Test 16 | public void testEpochLongAsAnInstant() { 17 | APIGatewayV2CustomAuthorizerEvent customAuthorizerEvent = APIGatewayV2CustomAuthorizerEvent.builder() 18 | .withRequestContext(APIGatewayV2CustomAuthorizerEvent.RequestContext.builder() 19 | .withTimeEpoch(TIME_EPOCH) 20 | .build()) 21 | .build(); 22 | 23 | assertEquals(Instant.ofEpochMilli(1601306426515L), customAuthorizerEvent.getRequestContext().getTimeEpoch()); 24 | } 25 | 26 | @Test 27 | public void testTimeStringAsDateTime() { 28 | APIGatewayV2CustomAuthorizerEvent customAuthorizerEvent = APIGatewayV2CustomAuthorizerEvent.builder() 29 | .withRequestContext(APIGatewayV2CustomAuthorizerEvent.RequestContext.builder() 30 | .withTime(TIME) 31 | .build()) 32 | .build(); 33 | 34 | assertNotNull(customAuthorizerEvent.getRequestContext().getTime()); 35 | } 36 | } -------------------------------------------------------------------------------- /aws-lambda-java-events/src/test/resources/iamPolicyResponses/allow-with-condition.json: -------------------------------------------------------------------------------- 1 | { 2 | "principalId": "me", 3 | "policyDocument": { 4 | "Version": "2012-10-17", 5 | "Statement": [{ 6 | "Action": "execute-api:Invoke", 7 | "Resource": ["arn:aws:execute-api:eu-west-1:123456789012:1234abc/$deafult/*/*"], 8 | "Effect": "Allow", 9 | "Condition": {"DateGreaterThan": {"aws:TokenIssueTime": "2020-01-01T00:00:01Z"}} 10 | }] 11 | }, 12 | "context":null 13 | } -------------------------------------------------------------------------------- /aws-lambda-java-events/src/test/resources/iamPolicyResponses/allow.json: -------------------------------------------------------------------------------- 1 | { 2 | "principalId": "me", 3 | "policyDocument": { 4 | "Version": "2012-10-17", 5 | "Statement": [{ 6 | "Action": "execute-api:Invoke", 7 | "Resource": ["arn:aws:execute-api:eu-west-1:123456789012:1234abc/$deafult/*/*"], 8 | "Effect": "Allow", 9 | "Condition": null 10 | }] 11 | }, 12 | "context":null 13 | } -------------------------------------------------------------------------------- /aws-lambda-java-events/src/test/resources/iamPolicyResponses/deny.json: -------------------------------------------------------------------------------- 1 | { 2 | "principalId": "me", 3 | "policyDocument": { 4 | "Version": "2012-10-17", 5 | "Statement": [{ 6 | "Action": "execute-api:Invoke", 7 | "Resource": ["arn:aws:execute-api:eu-west-1:123456789012:1234abc/$deafult/*/*"], 8 | "Effect": "Deny", 9 | "Condition": null 10 | }] 11 | }, 12 | "context":null 13 | } -------------------------------------------------------------------------------- /aws-lambda-java-events/src/test/resources/iamPolicyV1Responses/allow-with-condition.json: -------------------------------------------------------------------------------- 1 | { 2 | "principalId": "me", 3 | "policyDocument": { 4 | "Version": "2012-10-17", 5 | "Statement": [{ 6 | "Action": "execute-api:Invoke", 7 | "Resource": ["arn:aws:execute-api:eu-west-1:123456789012:1234abc/$deafult/*/*"], 8 | "Effect": "Allow", 9 | "Condition": {"DateGreaterThan": {"aws:TokenIssueTime": "2020-01-01T00:00:01Z"}} 10 | }] 11 | }, 12 | "context":null, 13 | "usageIdentifierKey": "123ABC" 14 | } -------------------------------------------------------------------------------- /aws-lambda-java-events/src/test/resources/iamPolicyV1Responses/allow.json: -------------------------------------------------------------------------------- 1 | { 2 | "principalId": "me", 3 | "policyDocument": { 4 | "Version": "2012-10-17", 5 | "Statement": [{ 6 | "Action": "execute-api:Invoke", 7 | "Resource": ["arn:aws:execute-api:eu-west-1:123456789012:1234abc/$deafult/*/*"], 8 | "Effect": "Allow", 9 | "Condition": null 10 | }] 11 | }, 12 | "context":null, 13 | "usageIdentifierKey": "123ABC" 14 | } -------------------------------------------------------------------------------- /aws-lambda-java-events/src/test/resources/iamPolicyV1Responses/deny.json: -------------------------------------------------------------------------------- 1 | { 2 | "principalId": "me", 3 | "policyDocument": { 4 | "Version": "2012-10-17", 5 | "Statement": [{ 6 | "Action": "execute-api:Invoke", 7 | "Resource": ["arn:aws:execute-api:eu-west-1:123456789012:1234abc/$deafult/*/*"], 8 | "Effect": "Deny", 9 | "Condition": null 10 | }] 11 | }, 12 | "context":null, 13 | "usageIdentifierKey": "123ABC" 14 | } -------------------------------------------------------------------------------- /aws-lambda-java-log4j2/RELEASE.CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### October 24, 2023 2 | `1.6.0`: 3 | - Log level and log format support 4 | 5 | ### January 04, 2022 6 | `1.5.1`: 7 | - Updated `log4j-core` and `log4j-api` dependencies to `2.17.1` 8 | 9 | ### December 18, 2021 10 | `1.5.0`: 11 | - Updated `log4j-core` and `log4j-api` dependencies to `2.17.0` 12 | 13 | ### December 15, 2021 14 | `1.4.0`: 15 | - Updated `log4j-core` and `log4j-api` dependencies to `2.16.0` 16 | 17 | ### December 10, 2021 18 | `1.3.0`: 19 | - Updated `log4j-core` and `log4j-api` dependencies to `2.15.0` 20 | 21 | ### May 05, 2020 22 | `1.2.0`: 23 | - Updated `log4j-core` and `log4j-api` dependencies to `2.13.2` 24 | 25 | ### April 28, 2020 26 | `1.1.1`: 27 | - Added missing XML namespace declarations to `pom.xml` file ([#97](https://github.com/aws/aws-lambda-java-libs/issues/97)) 28 | - Updated `nexusUrl` in `pom.xml` file ([#108](https://github.com/aws/aws-lambda-java-libs/issues/108)) 29 | - Updated `aws-lambda-java-core` to `1.2.1` 30 | 31 | ### November 21, 2017 32 | `1.1.0`: 33 | - Changed `LambdaAppender.append()` to make use of `LambdaLogger` from `com.amazonaws:aws-lambda-java-core:1.2.0` 34 | 35 | ### June 29, 2017 36 | `1.0.0`: 37 | - Initial release of AWS Lambda Log4j2 support 38 | -------------------------------------------------------------------------------- /aws-lambda-java-log4j2/src/main/java/com/amazonaws/services/lambda/runtime/log4j2/LambdaJsonFormat.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.log4j2; 4 | 5 | import org.apache.logging.log4j.core.Layout; 6 | import org.apache.logging.log4j.core.config.plugins.Plugin; 7 | import org.apache.logging.log4j.core.config.plugins.PluginElement; 8 | import org.apache.logging.log4j.core.config.plugins.PluginFactory; 9 | 10 | import java.io.Serializable; 11 | 12 | @Plugin(name = "LambdaJsonFormat", category = "core", printObject = true) 13 | public class LambdaJsonFormat { 14 | 15 | private Layout layout; 16 | 17 | @PluginFactory 18 | public static LambdaJsonFormat createNode(@PluginElement("Layout") Layout layout) { 19 | return new LambdaJsonFormat(layout); 20 | } 21 | 22 | private LambdaJsonFormat(Layout layout) { 23 | this.layout = layout; 24 | } 25 | 26 | public Layout getLayout() { 27 | return layout; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /aws-lambda-java-log4j2/src/main/java/com/amazonaws/services/lambda/runtime/log4j2/LambdaTextFormat.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.log4j2; 4 | 5 | import org.apache.logging.log4j.core.Layout; 6 | import org.apache.logging.log4j.core.config.plugins.Plugin; 7 | import org.apache.logging.log4j.core.config.plugins.PluginElement; 8 | import org.apache.logging.log4j.core.config.plugins.PluginFactory; 9 | 10 | import java.io.Serializable; 11 | 12 | @Plugin(name = "LambdaTextFormat", category = "core", printObject = true) 13 | public class LambdaTextFormat { 14 | 15 | private Layout layout; 16 | 17 | @PluginFactory 18 | public static LambdaTextFormat createNode(@PluginElement("Layout") Layout layout) { 19 | return new LambdaTextFormat(layout); 20 | } 21 | 22 | private LambdaTextFormat(Layout layout) { 23 | this.layout = layout; 24 | } 25 | 26 | public Layout getLayout() { 27 | return layout; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /aws-lambda-java-log4j2/src/main/resources/LambdaLayout.json: -------------------------------------------------------------------------------- 1 | { 2 | "timestamp": { 3 | "$resolver": "timestamp", 4 | "pattern": { 5 | "format": "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", 6 | "timeZone": "UTC" 7 | } 8 | }, 9 | "level": { 10 | "$resolver": "level", 11 | "field": "name" 12 | }, 13 | "message": { 14 | "$resolver": "message" 15 | }, 16 | "logger": { 17 | "$resolver": "logger", 18 | "field": "name" 19 | }, 20 | 21 | "errorType": { 22 | "$resolver": "exception", 23 | "field": "className" 24 | }, 25 | "errorMessage": { 26 | "$resolver": "exception", 27 | "field": "message" 28 | }, 29 | "stackTrace": { 30 | "$resolver": "exception", 31 | "field": "stackTrace" 32 | }, 33 | 34 | "labels": { 35 | "$resolver": "mdc", 36 | "flatten": true, 37 | "stringified": true 38 | } 39 | } -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/.gitignore: -------------------------------------------------------------------------------- 1 | compile-flags.txt 2 | ric-dev-environment/codeartifact-properties.mk 3 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/ric-dev-environment/codeartifact-repo.mk: -------------------------------------------------------------------------------- 1 | 2 | ifneq ("$(wildcard ric-dev-environment/codeartifact-properties.mk)","") 3 | 4 | include ric-dev-environment/codeartifact-properties.mk 5 | $(info Found codeartifact-properties.mk module) 6 | 7 | export MAVEN_REPO_URL:=$(shell aws codeartifact get-repository-endpoint \ 8 | --domain ${CODE_ARTIFACT_DOMAIN} \ 9 | --repository ${CODE_ARTIFACT_REPO_NAME} \ 10 | --format maven \ 11 | --output text \ 12 | --region ${CODE_ARTIFACT_REPO_REGION}) 13 | 14 | export MAVEN_REPO_PASSWORD:=$(shell aws codeartifact get-authorization-token \ 15 | --domain ${CODE_ARTIFACT_DOMAIN} \ 16 | --domain-owner ${CODE_ARTIFACT_REPO_ACCOUNT} \ 17 | --query authorizationToken \ 18 | --output text \ 19 | --region ${CODE_ARTIFACT_REPO_REGION}) 20 | 21 | export MAVEN_REPO_USERNAME:=aws 22 | 23 | $(info MAVEN_REPO_URL: $(MAVEN_REPO_URL)) 24 | # $(info MAVEN_REPO_PASSWORD: $(MAVEN_REPO_PASSWORD)) 25 | $(info MAVEN_REPO_USERNAME: $(MAVEN_REPO_USERNAME)) 26 | $(info CODE_ARTIFACT_REPO_NAME: $(CODE_ARTIFACT_REPO_NAME)) 27 | endif 28 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/ric-dev-environment/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | dev-ci 5 | 6 | 7 | ci-repo 8 | ${env.MAVEN_REPO_URL} 9 | 10 | 11 | 12 | 13 | 14 | 15 | ci-repo 16 | ${env.MAVEN_REPO_USERNAME} 17 | ${env.MAVEN_REPO_PASSWORD} 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/ric-dev-environment/test-platform-specific-jar-snapshot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | projectVersion=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) 6 | 7 | 8 | # test uber jar 9 | mvn -B -X -P ci-repo \ 10 | dependency:get \ 11 | -DremoteRepositories=ci-repo::::$MAVEN_REPO_URL \ 12 | -Dartifact=com.amazonaws:aws-lambda-java-runtime-interface-client:${projectVersion}-SNAPSHOT \ 13 | -Dtransitive=false \ 14 | --settings ric-dev-environment/settings.xml 15 | 16 | 17 | PLATFORM_ARRAY=("linux-x86_64" "linux_musl-x86_64" "linux-aarch_64" "linux_musl-aarch_64") 18 | 19 | for classifier in "${PLATFORM_ARRAY[@]}"; do 20 | # Test platform specific jar 21 | mvn -B -P ci-repo \ 22 | dependency:get \ 23 | -DremoteRepositories=ci-repo::::$MAVEN_REPO_URL \ 24 | -Dartifact=com.amazonaws:aws-lambda-java-runtime-interface-client:${projectVersion}-SNAPSHOT:jar:${classifier} \ 25 | -Dtransitive=false \ 26 | --settings ric-dev-environment/settings.xml 27 | done -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/crac/CheckpointException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.crac; 7 | 8 | public class CheckpointException extends Exception { 9 | private static final long serialVersionUID = -4956873658083157585L; 10 | public CheckpointException() { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/crac/Context.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.crac; 7 | 8 | public abstract class Context implements Resource { 9 | 10 | protected Context() { 11 | } 12 | 13 | @Override 14 | public abstract void beforeCheckpoint(Context context) 15 | throws CheckpointException; 16 | 17 | @Override 18 | public abstract void afterRestore(Context context) 19 | throws RestoreException; 20 | 21 | public abstract void register(R resource); 22 | } 23 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/crac/Core.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.crac; 7 | 8 | /** 9 | * Provides the global context for registering resources. 10 | */ 11 | public final class Core { 12 | 13 | private static Context globalContext = new ContextImpl(); 14 | 15 | private Core() { 16 | } 17 | 18 | public static Context getGlobalContext() { 19 | return globalContext; 20 | } 21 | 22 | public static void checkpointRestore() { 23 | throw new UnsupportedOperationException(); 24 | } 25 | 26 | static void resetGlobalContext() { 27 | globalContext = new ContextImpl(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/crac/DNSManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.crac; 7 | 8 | class DNSManager { 9 | static native void clearCache(); 10 | } 11 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/crac/Resource.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.crac; 7 | 8 | public interface Resource { 9 | void afterRestore(Context context) throws Exception; 10 | 11 | void beforeCheckpoint(Context context) throws Exception; 12 | } 13 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/crac/RestoreException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.crac; 7 | 8 | public class RestoreException extends Exception { 9 | private static final long serialVersionUID = -823900409868237860L; 10 | 11 | public RestoreException() { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/LambdaRequestHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client; 7 | 8 | import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.dto.InvocationRequest; 9 | import java.io.ByteArrayOutputStream; 10 | 11 | public interface LambdaRequestHandler { 12 | ByteArrayOutputStream call(InvocationRequest request) throws Error, Exception; 13 | 14 | static LambdaRequestHandler initErrorHandler(final Throwable e, String className) { 15 | return new UserFaultHandler(UserFault.makeInitErrorUserFault(e, className)); 16 | } 17 | 18 | static LambdaRequestHandler classNotFound(final Throwable e, String className) { 19 | return new UserFaultHandler(UserFault.makeClassNotFoundUserFault(e, className)); 20 | } 21 | 22 | class UserFaultHandler implements LambdaRequestHandler { 23 | public final UserFault fault; 24 | 25 | public UserFaultHandler(UserFault fault) { 26 | this.fault = fault; 27 | } 28 | 29 | public ByteArrayOutputStream call(InvocationRequest request) { 30 | throw fault; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/TooManyServiceProvidersFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client; 7 | 8 | public class TooManyServiceProvidersFoundException extends RuntimeException { 9 | public TooManyServiceProvidersFoundException() { 10 | } 11 | 12 | public TooManyServiceProvidersFoundException(String errorMessage) { 13 | super(errorMessage); 14 | } 15 | 16 | public TooManyServiceProvidersFoundException(Throwable cause) { 17 | super(cause); 18 | } 19 | 20 | public TooManyServiceProvidersFoundException(String message, Throwable cause) { 21 | super(message, cause); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/api/LambdaClientContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.api; 7 | 8 | import com.amazonaws.services.lambda.runtime.Client; 9 | import com.amazonaws.services.lambda.runtime.ClientContext; 10 | import java.util.Map; 11 | 12 | public class LambdaClientContext implements ClientContext { 13 | 14 | private LambdaClientContextClient client; 15 | private Map custom; 16 | private Map env; 17 | 18 | public Client getClient() { 19 | return client; 20 | } 21 | 22 | public Map getCustom() { 23 | return custom; 24 | } 25 | 26 | public Map getEnvironment() { 27 | return env; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/api/LambdaClientContextClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.api; 7 | 8 | import com.amazonaws.services.lambda.runtime.Client; 9 | 10 | public class LambdaClientContextClient implements Client { 11 | 12 | private String installation_id; 13 | 14 | private String app_title; 15 | 16 | private String app_version_name; 17 | 18 | private String app_version_code; 19 | 20 | private String app_package_name; 21 | 22 | public String getInstallationId() { 23 | return installation_id; 24 | } 25 | 26 | public String getAppTitle() { 27 | return app_title; 28 | } 29 | 30 | public String getAppVersionName() { 31 | return app_version_name; 32 | } 33 | 34 | public String getAppVersionCode() { 35 | return app_version_code; 36 | } 37 | 38 | public String getAppPackageName() { 39 | return app_package_name; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/api/LambdaCognitoIdentity.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.api; 7 | 8 | import com.amazonaws.services.lambda.runtime.CognitoIdentity; 9 | 10 | public class LambdaCognitoIdentity implements CognitoIdentity { 11 | 12 | private final String cognitoIdentityId; 13 | private final String cognitoIdentityPoolId; 14 | 15 | public LambdaCognitoIdentity(String identityid, String poolid) { 16 | this.cognitoIdentityId = identityid; 17 | this.cognitoIdentityPoolId = poolid; 18 | } 19 | 20 | public String getIdentityId() { 21 | return this.cognitoIdentityId; 22 | } 23 | 24 | public String getIdentityPoolId() { 25 | return this.cognitoIdentityPoolId; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/logging/LambdaContextLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.logging; 7 | 8 | import com.amazonaws.services.lambda.runtime.logging.LogFormat; 9 | import com.amazonaws.services.lambda.runtime.logging.LogLevel; 10 | import java.io.Closeable; 11 | import java.io.IOException; 12 | import static java.nio.charset.StandardCharsets.UTF_8; 13 | 14 | public class LambdaContextLogger extends AbstractLambdaLogger implements Closeable { 15 | // If a null string is passed in, replace it with "null", 16 | // replicating the behavior of System.out.println(null); 17 | private static final byte[] NULL_BYTES_VALUE = "null".getBytes(UTF_8); 18 | 19 | private final transient LogSink sink; 20 | 21 | public LambdaContextLogger(LogSink sink, LogLevel logLevel, LogFormat logFormat) { 22 | super(logLevel, logFormat); 23 | this.sink = sink; 24 | } 25 | 26 | @Override 27 | protected void logMessage(byte[] message, LogLevel logLevel) { 28 | if (message == null) { 29 | sink.log(logLevel, this.logFormat, NULL_BYTES_VALUE); 30 | } else { 31 | sink.log(logLevel, this.logFormat, message); 32 | } 33 | } 34 | 35 | @Override 36 | public void close() throws IOException { 37 | sink.close(); 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/logging/LogFiltering.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.logging; 7 | 8 | import com.amazonaws.services.lambda.runtime.logging.LogLevel; 9 | 10 | public class LogFiltering { 11 | private final LogLevel minimumLogLevel; 12 | 13 | public LogFiltering(LogLevel minimumLogLevel) { 14 | this.minimumLogLevel = minimumLogLevel; 15 | } 16 | 17 | boolean isEnabled(LogLevel logLevel) { 18 | return (logLevel == LogLevel.UNDEFINED || logLevel.ordinal() >= minimumLogLevel.ordinal()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/logging/LogFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.logging; 7 | 8 | import com.amazonaws.services.lambda.runtime.api.client.api.LambdaContext; 9 | import com.amazonaws.services.lambda.runtime.logging.LogLevel; 10 | 11 | public interface LogFormatter { 12 | String format(String message, LogLevel logLevel); 13 | 14 | default void setLambdaContext(LambdaContext context) { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/logging/LogSink.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.logging; 7 | 8 | import com.amazonaws.services.lambda.runtime.logging.LogFormat; 9 | import com.amazonaws.services.lambda.runtime.logging.LogLevel; 10 | import java.io.Closeable; 11 | 12 | public interface LogSink extends Closeable { 13 | 14 | void log(byte[] message); 15 | 16 | void log(LogLevel logLevel, LogFormat logFormat, byte[] message); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/logging/StdOutLogSink.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.logging; 7 | 8 | import com.amazonaws.services.lambda.runtime.logging.LogFormat; 9 | import com.amazonaws.services.lambda.runtime.logging.LogLevel; 10 | import java.io.IOException; 11 | 12 | public class StdOutLogSink implements LogSink { 13 | @Override 14 | public void log(byte[] message) { 15 | log(LogLevel.UNDEFINED, LogFormat.TEXT, message); 16 | } 17 | 18 | public void log(LogLevel logLevel, LogFormat logFormat, byte[] message) { 19 | try { 20 | System.out.write(message); 21 | } catch (IOException e) { 22 | e.printStackTrace(); 23 | } 24 | } 25 | 26 | @Override 27 | public void close() { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/logging/StructuredLogMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.logging; 7 | 8 | import com.amazonaws.services.lambda.runtime.logging.LogLevel; 9 | 10 | class StructuredLogMessage { 11 | public String timestamp; 12 | public String message; 13 | public LogLevel level; 14 | public String AWSRequestId; 15 | public String tenantId; 16 | } 17 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/logging/TextLogFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.logging; 7 | 8 | import com.amazonaws.services.lambda.runtime.logging.LogLevel; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | public class TextLogFormatter implements LogFormatter { 13 | private static final Map logLevelMapper = new HashMap() { 14 | { 15 | for (LogLevel logLevel: LogLevel.values()) { 16 | put(logLevel, "[" + logLevel.toString() + "] "); 17 | } 18 | } 19 | }; 20 | 21 | @Override 22 | public String format(String message, LogLevel logLevel) { 23 | if (logLevel == LogLevel.UNDEFINED) { 24 | return message; 25 | } 26 | 27 | return new StringBuilder(). 28 | append(logLevelMapper. 29 | get(logLevel)).append(message). 30 | toString(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/runtimeapi/LambdaError.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | package com.amazonaws.services.lambda.runtime.api.client.runtimeapi; 6 | 7 | import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.dto.ErrorRequest; 8 | import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.dto.XRayErrorCause; 9 | 10 | public class LambdaError { 11 | 12 | public final ErrorRequest errorRequest; 13 | 14 | public final XRayErrorCause xRayErrorCause; 15 | 16 | public final RapidErrorType errorType; 17 | 18 | public LambdaError(ErrorRequest errorRequest, XRayErrorCause xRayErrorCause, RapidErrorType errorType) { 19 | this.errorRequest = errorRequest; 20 | this.xRayErrorCause = xRayErrorCause; 21 | this.errorType = errorType; 22 | } 23 | 24 | public LambdaError(ErrorRequest errorRequest, RapidErrorType errorType) { 25 | this(errorRequest, null, errorType); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/runtimeapi/LambdaRuntimeClientException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | package com.amazonaws.services.lambda.runtime.api.client.runtimeapi; 6 | 7 | public class LambdaRuntimeClientException extends RuntimeException { 8 | public LambdaRuntimeClientException(String message, int responseCode) { 9 | super(message + " Response code: '" + responseCode + "'."); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/runtimeapi/NativeClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | package com.amazonaws.services.lambda.runtime.api.client.runtimeapi; 6 | 7 | import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.dto.InvocationRequest; 8 | import static com.amazonaws.services.lambda.runtime.api.client.runtimeapi.LambdaRuntimeApiClientImpl.USER_AGENT; 9 | 10 | /** 11 | * This module defines the native Runtime Interface Client which is responsible for HTTP 12 | * interactions with the Runtime API. 13 | */ 14 | class NativeClient { 15 | static void init(String awsLambdaRuntimeApi) { 16 | JniHelper.load(); 17 | initializeClient(USER_AGENT.getBytes(), awsLambdaRuntimeApi.getBytes()); 18 | } 19 | 20 | static native void initializeClient(byte[] userAgent, byte[] awsLambdaRuntimeApi); 21 | 22 | static native InvocationRequest next(); 23 | 24 | static native void postInvocationResponse(byte[] requestId, byte[] response); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/runtimeapi/RapidErrorType.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | package com.amazonaws.services.lambda.runtime.api.client.runtimeapi; 6 | 7 | public enum RapidErrorType { 8 | BadFunctionCode, 9 | UserException, 10 | BeforeCheckpointError, 11 | AfterRestoreError; 12 | 13 | public String getRapidError() { 14 | return "Runtime." + this; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/runtimeapi/converters/LambdaErrorConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | package com.amazonaws.services.lambda.runtime.api.client.runtimeapi.converters; 6 | 7 | import com.amazonaws.services.lambda.runtime.api.client.UserFault; 8 | import com.amazonaws.services.lambda.runtime.api.client.runtimeapi.dto.ErrorRequest; 9 | 10 | public class LambdaErrorConverter { 11 | private LambdaErrorConverter() { 12 | } 13 | 14 | public static ErrorRequest fromUserFault(UserFault userFault) { 15 | // Not setting stacktrace for compatibility with legacy/native runtime 16 | return new ErrorRequest(userFault.msg, userFault.exception, null); 17 | } 18 | 19 | public static ErrorRequest fromThrowable(Throwable throwable) { 20 | String errorMessage = throwable.getLocalizedMessage() == null 21 | ? throwable.getClass().getName() 22 | : throwable.getLocalizedMessage(); 23 | String errorType = throwable.getClass().getName(); 24 | 25 | StackTraceElement[] trace = throwable.getStackTrace(); 26 | String[] stackTrace = new String[trace.length]; 27 | for (int i = 0; i < trace.length; i++) { 28 | stackTrace[i] = trace[i].toString(); 29 | } 30 | return new ErrorRequest(errorMessage, errorType, stackTrace); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/runtimeapi/dto/ErrorRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | package com.amazonaws.services.lambda.runtime.api.client.runtimeapi.dto; 6 | 7 | public class ErrorRequest { 8 | public String errorMessage; 9 | public String errorType; 10 | public String[] stackTrace; 11 | 12 | @SuppressWarnings("unused") 13 | public ErrorRequest() { 14 | } 15 | 16 | public ErrorRequest(String errorMessage, String errorType, String[] stackTrace) { 17 | this.errorMessage = errorMessage; 18 | this.errorType = errorType; 19 | this.stackTrace = stackTrace; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/runtimeapi/dto/StackElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | package com.amazonaws.services.lambda.runtime.api.client.runtimeapi.dto; 6 | 7 | public class StackElement { 8 | public String label; 9 | public String path; 10 | public int line; 11 | 12 | @SuppressWarnings("unused") 13 | public StackElement() { 14 | } 15 | 16 | public StackElement(String label, String path, int line) { 17 | this.label = label; 18 | this.path = path; 19 | this.line = line; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/runtimeapi/dto/XRayErrorCause.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | package com.amazonaws.services.lambda.runtime.api.client.runtimeapi.dto; 6 | 7 | import java.util.Collection; 8 | 9 | public class XRayErrorCause { 10 | public String working_directory; 11 | public Collection exceptions; 12 | public Collection paths; 13 | 14 | @SuppressWarnings("unused") 15 | public XRayErrorCause() { 16 | 17 | } 18 | 19 | public XRayErrorCause(String working_directory, Collection exceptions, Collection paths) { 20 | this.working_directory = working_directory; 21 | this.exceptions = exceptions; 22 | this.paths = paths; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/runtimeapi/dto/XRayException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | package com.amazonaws.services.lambda.runtime.api.client.runtimeapi.dto; 6 | 7 | import java.util.List; 8 | 9 | public class XRayException { 10 | public String message; 11 | public String type; 12 | public List stack; 13 | 14 | @SuppressWarnings("unused") 15 | public XRayException() { 16 | } 17 | 18 | public XRayException(String message, String type, List stack) { 19 | this.message = message; 20 | this.type = type; 21 | this.stack = stack; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/util/EnvReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.util; 7 | 8 | import java.util.Map; 9 | 10 | public class EnvReader { 11 | 12 | public Map getEnv() { 13 | return System.getenv(); 14 | } 15 | 16 | public String getEnv(String envVariableName) { 17 | return System.getenv(envVariableName); 18 | } 19 | 20 | public String getEnvOrDefault(String envVariableName, String defaultVal) { 21 | String val = getEnv(envVariableName); 22 | return val == null ? defaultVal : val; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/util/LambdaOutputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.util; 7 | 8 | import java.io.IOException; 9 | import java.io.OutputStream; 10 | 11 | public class LambdaOutputStream extends OutputStream { 12 | private final OutputStream inner; 13 | 14 | public LambdaOutputStream(OutputStream inner) { 15 | this.inner = inner; 16 | } 17 | 18 | @Override 19 | public void write(int b) throws IOException { 20 | write(new byte[]{(byte) b}); 21 | } 22 | 23 | @Override 24 | public void write(byte[] bytes) throws IOException { 25 | write(bytes, 0, bytes.length); 26 | 27 | } 28 | 29 | @Override 30 | public void write(byte[] bytes, int offset, int length) throws IOException { 31 | inner.write(bytes, offset, length); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/util/UnsafeUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package com.amazonaws.services.lambda.runtime.api.client.util; 7 | 8 | import java.lang.reflect.Field; 9 | import sun.misc.Unsafe; 10 | 11 | /** 12 | * Utilities for easy access to sun.misc.Unsafe 13 | */ 14 | public final class UnsafeUtil { 15 | public static final Unsafe TheUnsafe; 16 | 17 | static { 18 | try { 19 | final Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); 20 | theUnsafe.setAccessible(true); 21 | TheUnsafe = (Unsafe) theUnsafe.get(null); 22 | } catch (Exception e) { 23 | throw new Error("failed to load Unsafe", e); 24 | } 25 | } 26 | 27 | private UnsafeUtil() { 28 | } 29 | 30 | public static void disableIllegalAccessWarning() { 31 | try { 32 | Class illegalAccessLoggerClass = Class.forName("jdk.internal.module.IllegalAccessLogger"); 33 | Field loggerField = illegalAccessLoggerClass.getDeclaredField("logger"); 34 | TheUnsafe.putObjectVolatile(illegalAccessLoggerClass, TheUnsafe.staticFieldOffset(loggerField), null); 35 | } catch (Throwable t) { /* ignore */ } 36 | } 37 | 38 | public static RuntimeException throwException(Throwable t) { 39 | TheUnsafe.throwException(t); 40 | throw new Error("should never get here"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/com_amazonaws_services_lambda_crac_DNSManager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | #include 6 | #include "macro.h" 7 | #include "com_amazonaws_services_lambda_crac_DNSManager.h" 8 | 9 | JNIEXPORT void JNICALL Java_com_amazonaws_services_lambda_crac_DNSManager_clearCache 10 | (JNIEnv *env, jclass thisClass) { 11 | jclass iNetAddressClass; 12 | jclass concurrentMap; 13 | jfieldID cacheFieldID; 14 | jobject cacheObj; 15 | jmethodID clearMethodID; 16 | CHECK_EXCEPTION(env, iNetAddressClass = env->FindClass("java/net/InetAddress")); 17 | CHECK_EXCEPTION(env, concurrentMap = env->FindClass("java/util/concurrent/ConcurrentMap")); 18 | CHECK_EXCEPTION(env, cacheFieldID = env->GetStaticFieldID(iNetAddressClass, "cache", "Ljava/util/concurrent/ConcurrentMap;")); 19 | CHECK_EXCEPTION(env, cacheObj = (jobject) env->GetStaticObjectField(iNetAddressClass, cacheFieldID)); 20 | CHECK_EXCEPTION(env, clearMethodID = env->GetMethodID(concurrentMap, "clear", "()V")); 21 | CHECK_EXCEPTION(env, env->CallVoidMethod(cacheObj, clearMethodID)); 22 | return; 23 | 24 | ERROR: 25 | // we need to fail silently here 26 | env->ExceptionClear(); 27 | } 28 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/com_amazonaws_services_lambda_crac_DNSManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | #include 6 | 7 | #ifndef _Included_com_amazonaws_services_lambda_crac_DNSManager 8 | #define _Included_com_amazonaws_services_lambda_crac_DNSManager 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | JNIEXPORT void JNICALL Java_com_amazonaws_services_lambda_crac_DNSManager_clearCache 14 | (JNIEnv *, jclass); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | #endif 20 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/com_amazonaws_services_lambda_runtime_api_client_runtimeapi_NativeClient.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | #include 6 | 7 | #ifndef _Included_com_amazonaws_services_lambda_runtime_api_client_runtimeapi_NativeClient 8 | #define _Included_com_amazonaws_services_lambda_runtime_api_client_runtimeapi_NativeClient 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | JNIEXPORT void JNICALL Java_com_amazonaws_services_lambda_runtime_api_client_runtimeapi_NativeClient_initializeClient 14 | (JNIEnv *, jobject, jbyteArray, jbyteArray); 15 | 16 | JNIEXPORT jobject JNICALL Java_com_amazonaws_services_lambda_runtime_api_client_runtimeapi_NativeClient_next 17 | (JNIEnv *, jobject); 18 | 19 | JNIEXPORT void JNICALL Java_com_amazonaws_services_lambda_runtime_api_client_runtimeapi_NativeClient_postInvocationResponse 20 | (JNIEnv *, jobject, jbyteArray, jbyteArray); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | #endif 26 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | 6 | By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. 7 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | tags 3 | TODO 4 | compile_commands.json 5 | .clangd 6 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/NOTICE: -------------------------------------------------------------------------------- 1 | AWS Lambda Cpp Runtime 2 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/ci/codebuild/amazonlinux-2017.03.yml: -------------------------------------------------------------------------------- 1 | version: 0.1 2 | # This uses the docker image specified in ci/docker/amazon-linux-2017.03 3 | phases: 4 | pre_build: 5 | commands: 6 | - alias cmake=cmake3 7 | - pip install awscli 8 | - ci/codebuild/build-cpp-sdk.sh 9 | build: 10 | commands: 11 | - echo Build started on `date` 12 | - ci/codebuild/build.sh -DENABLE_TESTS=ON -DTEST_RESOURCE_PREFIX=amzn201703 13 | - ci/codebuild/run-tests.sh aws-lambda-package-lambda-test-fun amzn201703 14 | - ci/codebuild/run-tests.sh aws-lambda-package-lambda-test-fun-no-glibc amzn201703 15 | post_build: 16 | commands: 17 | - echo Build completed on `date` 18 | 19 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/ci/codebuild/build-cpp-sdk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | # build the AWS C++ SDK 6 | cd /aws-sdk-cpp 7 | git pull 8 | mkdir build 9 | cd build 10 | cmake .. -GNinja -DBUILD_ONLY="lambda" \ 11 | -DCMAKE_BUILD_TYPE=Release \ 12 | -DENABLE_UNITY_BUILD=ON \ 13 | -DBUILD_SHARED_LIBS=ON \ 14 | -DENABLE_TESTING=OFF \ 15 | -DCMAKE_INSTALL_PREFIX=/install $@ 16 | ninja 17 | ninja install 18 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/ci/codebuild/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | # build the lambda-runtime 6 | cd $CODEBUILD_SRC_DIR 7 | mkdir build 8 | cd build 9 | cmake .. -GNinja -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/install $@ 10 | ninja 11 | ninja install 12 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/ci/codebuild/format-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | CLANG_FORMAT=clang-format 6 | 7 | if NOT type $CLANG_FORMAT > /dev/null 2>&1; then 8 | echo "No appropriate clang-format found." 9 | exit 1 10 | fi 11 | 12 | FAIL=0 13 | SOURCE_FILES=$(find src include tests -type f -name "*.h" -o -name "*.cpp") 14 | for i in $SOURCE_FILES 15 | do 16 | if [ $($CLANG_FORMAT -output-replacements-xml $i | grep -c " 18 | DEPENDS ${target}) 19 | endfunction() 20 | 21 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/examples/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | RUN apk update && apk add cmake make git g++ bash curl-dev zlib-dev 4 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/examples/api-gateway/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | set(CMAKE_CXX_STANDARD 11) 3 | 4 | project(api LANGUAGES CXX) 5 | 6 | find_package(aws-lambda-runtime REQUIRED) 7 | find_package(AWSSDK COMPONENTS core) 8 | 9 | add_executable(${PROJECT_NAME} "main.cpp") 10 | target_link_libraries(${PROJECT_NAME} PUBLIC AWS::aws-lambda-runtime ${AWSSDK_LINK_LIBRARIES}) 11 | 12 | aws_lambda_package_target(${PROJECT_NAME}) 13 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/examples/dynamodb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | set(CMAKE_CXX_STANDARD 11) 3 | project(ddb-demo LANGUAGES CXX) 4 | 5 | find_package(aws-lambda-runtime) 6 | find_package(AWSSDK COMPONENTS dynamodb) 7 | 8 | add_executable(${PROJECT_NAME} "main.cpp") 9 | 10 | target_link_libraries(${PROJECT_NAME} PUBLIC AWS::aws-lambda-runtime ${AWSSDK_LINK_LIBRARIES}) 11 | 12 | target_compile_options(${PROJECT_NAME} PRIVATE 13 | "-fno-exceptions" 14 | "-fno-rtti" 15 | "-Wall" 16 | "-Wextra" 17 | "-Werror" 18 | "-Wconversion" 19 | "-Wno-sign-conversion") 20 | 21 | target_compile_features(${PROJECT_NAME} PRIVATE "cxx_std_11") 22 | 23 | aws_lambda_package_target(${PROJECT_NAME}) 24 | 25 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/examples/s3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | set(CMAKE_CXX_STANDARD 11) 3 | project(encoder LANGUAGES CXX) 4 | 5 | find_package(aws-lambda-runtime) 6 | find_package(AWSSDK COMPONENTS s3) 7 | 8 | add_executable(${PROJECT_NAME} "main.cpp") 9 | 10 | target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-lambda-runtime ${AWSSDK_LINK_LIBRARIES}) 11 | 12 | target_compile_options(${PROJECT_NAME} PRIVATE 13 | "-Wall" 14 | "-Wextra" 15 | "-Wconversion" 16 | "-Wshadow" 17 | "-Wno-sign-conversion") 18 | 19 | target_compile_features(${PROJECT_NAME} PRIVATE "cxx_std_11") 20 | 21 | aws_lambda_package_target(${PROJECT_NAME}) 22 | 23 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/include/aws/lambda-runtime/version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /* 3 | * Copyright 2018-present Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"). 6 | * You may not use this file except in compliance with the License. 7 | * A copy of the License is located at 8 | * 9 | * http://aws.amazon.com/apache2.0 10 | * 11 | * or in the "license" file accompanying this file. This file is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 | * express or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | namespace aws { 18 | namespace lambda_runtime { 19 | 20 | /** 21 | * Returns the major component of the library version. 22 | */ 23 | unsigned get_version_major(); 24 | 25 | /** 26 | * Returns the minor component of the library version. 27 | */ 28 | unsigned get_version_minor(); 29 | 30 | /** 31 | * Returns the patch component of the library version. 32 | */ 33 | unsigned get_version_patch(); 34 | 35 | /** 36 | * Returns the semantic version of the library in the form Major.Minor.Patch 37 | */ 38 | char const* get_version(); 39 | 40 | } // namespace lambda_runtime 41 | } // namespace aws 42 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/src/backward.cpp: -------------------------------------------------------------------------------- 1 | // Pick your poison. 2 | // 3 | // On GNU/Linux, you have few choices to get the most out of your stack trace. 4 | // 5 | // By default you get: 6 | // - object filename 7 | // - function name 8 | // 9 | // In order to add: 10 | // - source filename 11 | // - line and column numbers 12 | // - source code snippet (assuming the file is accessible) 13 | 14 | // Install one of the following library then uncomment one of the macro (or 15 | // better, add the detection of the lib and the macro definition in your build 16 | // system) 17 | 18 | // - apt-get install libdw-dev ... 19 | // - g++/clang++ -ldw ... 20 | // #define BACKWARD_HAS_DW 1 21 | 22 | // - apt-get install binutils-dev ... 23 | // - g++/clang++ -lbfd ... 24 | // #define BACKWARD_HAS_BFD 1 25 | 26 | #include "backward.h" 27 | 28 | namespace backward { 29 | 30 | backward::SignalHandling sh; 31 | 32 | } // namespace backward 33 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/src/version.cpp.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-present Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | #define AWS_LAMBDA_RUNTIME_API __attribute__((visibility("default"))) 17 | 18 | namespace aws { 19 | namespace lambda_runtime { 20 | 21 | /* clang-format off */ 22 | AWS_LAMBDA_RUNTIME_API 23 | unsigned get_version_major() 24 | { 25 | return @PROJECT_VERSION_MAJOR@; // NOLINT 26 | } 27 | 28 | AWS_LAMBDA_RUNTIME_API 29 | unsigned get_version_minor() 30 | { 31 | return @PROJECT_VERSION_MINOR@; // NOLINT 32 | } 33 | 34 | AWS_LAMBDA_RUNTIME_API 35 | unsigned get_version_patch() 36 | { 37 | return @PROJECT_VERSION_PATCH@; // NOLINT 38 | } 39 | /* clang-format on */ 40 | 41 | AWS_LAMBDA_RUNTIME_API 42 | char const* get_version() 43 | { 44 | return "@PROJECT_VERSION@"; 45 | } 46 | 47 | } // namespace lambda_runtime 48 | } // namespace aws 49 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(aws-lambda-runtime-tests LANGUAGES CXX) 2 | find_package(AWSSDK COMPONENTS lambda iam) 3 | 4 | add_executable(${PROJECT_NAME} 5 | main.cpp 6 | runtime_tests.cpp 7 | version_tests.cpp 8 | gtest/gtest-all.cc) 9 | 10 | target_link_libraries(${PROJECT_NAME} PRIVATE ${AWSSDK_LINK_LIBRARIES} aws-lambda-runtime) 11 | 12 | include(GoogleTest) 13 | gtest_discover_tests(${PROJECT_NAME} EXTRA_ARGS "--aws_prefix=${TEST_RESOURCE_PREFIX}") # requires CMake 3.10 or later 14 | 15 | add_subdirectory(resources) 16 | 17 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/tests/gtest/.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | Checks: '-*,llvm-twine-local' 3 | ... 4 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/tests/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "gtest/gtest.h" 4 | 5 | std::function()> get_console_logger_factory() 6 | { 7 | return [] { 8 | return Aws::MakeShared( 9 | "console_logger", Aws::Utils::Logging::LogLevel::Warn); 10 | }; 11 | } 12 | 13 | std::string aws_prefix; 14 | 15 | void parse_args(int argc, char** argv) 16 | { 17 | const std::string resource_prefix_option = "--aws_prefix="; 18 | for (int i = 1; i < argc; i++) { 19 | std::string arg = argv[i]; 20 | if (arg.find(resource_prefix_option) == 0) { 21 | aws_prefix = arg.substr(resource_prefix_option.length()); // get whatever value after the '=' 22 | break; 23 | } 24 | } 25 | } 26 | 27 | int main(int argc, char** argv) 28 | { 29 | parse_args(argc, argv); 30 | Aws::SDKOptions options; 31 | options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Warn; 32 | options.loggingOptions.logger_create_fn = get_console_logger_factory(); 33 | Aws::InitAPI(options); 34 | ::testing::InitGoogleTest(&argc, argv); 35 | int exit_code = RUN_ALL_TESTS(); 36 | Aws::ShutdownAPI(options); 37 | return exit_code; 38 | } 39 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/tests/resources/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(lambda-test-fun LANGUAGES CXX) 2 | 3 | # resources are the actual lambda functions deployed and exercised by the tests 4 | add_executable(${PROJECT_NAME} lambda_function.cpp) 5 | target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include) 6 | target_link_libraries(${PROJECT_NAME} PRIVATE aws-lambda-runtime) 7 | # package the lambda function into lambda.zip 8 | add_custom_target(aws-lambda-package-lambda-test-fun 9 | COMMAND "${CMAKE_SOURCE_DIR}/packaging/packager" "${CMAKE_CURRENT_BINARY_DIR}/lambda-test-fun" 10 | DEPENDS ${PROJECT_NAME}) 11 | 12 | add_custom_target(aws-lambda-package-lambda-test-fun-no-glibc 13 | COMMAND "${CMAKE_SOURCE_DIR}/packaging/packager" -d "${CMAKE_CURRENT_BINARY_DIR}/lambda-test-fun" 14 | DEPENDS ${PROJECT_NAME}) 15 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/aws-lambda-cpp-0.2.7/tests/version_tests.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "gtest/gtest.h" 3 | 4 | using namespace aws::lambda_runtime; 5 | 6 | TEST(VersionTests, get_version_major) 7 | { 8 | auto version = get_version_major(); 9 | ASSERT_EQ(0, version); 10 | } 11 | 12 | TEST(VersionTests, get_version_minor) 13 | { 14 | auto version = get_version_minor(); 15 | ASSERT_GE(version, 1); 16 | } 17 | 18 | TEST(VersionTests, get_version_patch) 19 | { 20 | auto version = get_version_patch(); 21 | ASSERT_GE(version, 0); 22 | } 23 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/curl-7.83.1.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws/aws-lambda-java-libs/5a0f8ad9e9b8ff61ba626e71c4b5de62134e82e4/aws-lambda-java-runtime-interface-client/src/main/jni/deps/curl-7.83.1.tar.gz -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/deps/curl_001_disable_wakeup.patch: -------------------------------------------------------------------------------- 1 | diff --git a/multihandle.h b/multihandle.h 2 | index a26fb619a..18080f1c3 100644 3 | --- a/multihandle.h 4 | +++ b/multihandle.h 5 | @@ -70,10 +70,6 @@ typedef enum { 6 | 7 | #define CURLPIPE_ANY (CURLPIPE_MULTIPLEX) 8 | 9 | -#if !defined(CURL_DISABLE_SOCKETPAIR) 10 | -#define ENABLE_WAKEUP 11 | -#endif 12 | - 13 | /* value for MAXIMUM CONCURRENT STREAMS upper limit */ 14 | #define INITIAL_MAX_CONCURRENT_STREAMS ((1U << 31) - 1) -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/main/jni/macro.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | #ifndef _Included_macros 7 | #define _Included_macros 8 | 9 | #define CHECK_EXCEPTION(env, expr) \ 10 | expr; \ 11 | if ((env)->ExceptionOccurred()) \ 12 | goto ERROR; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/test/java/com/amazonaws/services/lambda/runtime/api/client/logging/FrameTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.api.client.logging; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import org.junit.jupiter.api.Test; 6 | 7 | import com.amazonaws.services.lambda.runtime.logging.LogLevel; 8 | import com.amazonaws.services.lambda.runtime.logging.LogFormat; 9 | 10 | public class FrameTypeTest { 11 | 12 | @Test 13 | public void logFrames() { 14 | assertHexEquals( 15 | 0xa55a0003, 16 | FrameType.getValue(LogLevel.UNDEFINED, LogFormat.TEXT) 17 | ); 18 | 19 | assertHexEquals( 20 | 0xa55a001b, 21 | FrameType.getValue(LogLevel.FATAL, LogFormat.TEXT) 22 | ); 23 | } 24 | 25 | 26 | /** 27 | * Helper function to make it easier to debug failing test. 28 | * 29 | * @param expected Expected value as int 30 | * @param actual Actual value as int 31 | */ 32 | private void assertHexEquals(int expected, int actual) { 33 | assertEquals( 34 | Integer.toHexString(expected), 35 | Integer.toHexString(actual) 36 | ); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/test/java/com/amazonaws/services/lambda/runtime/api/client/logging/TextLogFormatterTest.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.api.client.logging; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static org.junit.jupiter.api.Assertions.assertEquals; 6 | 7 | import com.amazonaws.services.lambda.runtime.logging.LogLevel; 8 | 9 | class TextLogFormatterTest { 10 | @Test 11 | void testFormattingStringWithLogLevel() { 12 | assertFormatsString("test log", LogLevel.WARN, "[WARN] test log"); 13 | } 14 | 15 | @Test 16 | void testFormattingStringWithoutLogLevel() { 17 | assertFormatsString("test log", LogLevel.UNDEFINED, "test log"); 18 | } 19 | 20 | void assertFormatsString(String input, LogLevel logLevel, String expected) { 21 | LogFormatter logFormatter = new TextLogFormatter(); 22 | String output = logFormatter.format(input, logLevel); 23 | assertEquals(expected, output); 24 | } 25 | } -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/test/java/test/lambda/handlers/POJOHanlderImpl.java: -------------------------------------------------------------------------------- 1 | package test.lambda.handlers; 2 | 3 | import com.amazonaws.services.lambda.runtime.Context; 4 | 5 | @SuppressWarnings("unused") 6 | public class POJOHanlderImpl { 7 | @SuppressWarnings("unused") 8 | public String noParamsHandler() { 9 | return "success"; 10 | } 11 | 12 | @SuppressWarnings("unused") 13 | public String oneParamHandler_event(String event) { 14 | return "success"; 15 | } 16 | 17 | @SuppressWarnings("unused") 18 | public String oneParamHandler_context(Context context) { 19 | return "success"; 20 | } 21 | 22 | @SuppressWarnings("unused") 23 | public String twoParamsHandler(String event, Context context) { 24 | return "success"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/test/java/test/lambda/handlers/RequestHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package test.lambda.handlers; 2 | 3 | import com.amazonaws.services.lambda.runtime.Context; 4 | import com.amazonaws.services.lambda.runtime.RequestHandler; 5 | 6 | 7 | public class RequestHandlerImpl implements RequestHandler { 8 | @Override 9 | public String handleRequest(String event, Context context) { 10 | return "success"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/test/java/test/lambda/handlers/RequestStreamHandlerImpl.java: -------------------------------------------------------------------------------- 1 | package test.lambda.handlers; 2 | 3 | import com.amazonaws.services.lambda.runtime.Context; 4 | import com.amazonaws.services.lambda.runtime.RequestStreamHandler; 5 | 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.io.OutputStream; 9 | 10 | @SuppressWarnings("unused") 11 | public class RequestStreamHandlerImpl implements RequestStreamHandler { 12 | @Override 13 | public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException { 14 | output.write("\"success\"".getBytes()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/src/test/java/testpkg/StackTraceHelper.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package testpkg; 4 | 5 | import com.amazonaws.services.lambda.crac.CheckpointException; 6 | 7 | /** 8 | * A helper class for throwing exception which is not in the com.amazonaws.services.lambda.runtime.api.client package 9 | * to avoid the stack traces from being filtered out. 10 | * 11 | */ 12 | public class StackTraceHelper { 13 | /** 14 | * Throws a RuntimeException directly with msg as the message. 15 | */ 16 | public static void throwRuntimeException(String msg){ 17 | throw new RuntimeException(msg); 18 | } 19 | 20 | /** 21 | * Calls another method which throws a RuntimeException with msg as the message. 22 | */ 23 | public static void callThenThrowRuntimeException(String msg){ 24 | throwRuntimeException(msg); 25 | } 26 | 27 | public static void throwCheckpointExceptionWithTwoSuppressedExceptions(String msg1, String msg2) throws CheckpointException { 28 | CheckpointException e1 = new CheckpointException(); 29 | e1.addSuppressed(new RuntimeException(msg1)); 30 | e1.addSuppressed(new RuntimeException(msg2)); 31 | throw e1; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/.gitignore: -------------------------------------------------------------------------------- 1 | generated.docker-compose.*.yml 2 | .idea -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/Dockerfile.agent: -------------------------------------------------------------------------------- 1 | FROM public.ecr.aws/amazoncorretto/amazoncorretto:8 2 | 3 | # Install docker and buildx extension 4 | RUN amazon-linux-extras enable docker && \ 5 | yum clean metadata && \ 6 | yum install -y docker tar gzip unzip file 7 | 8 | COPY --from=docker/buildx-bin:latest /buildx /usr/libexec/docker/cli-plugins/docker-buildx 9 | 10 | # Install maven from apache.org, as version in the yum repository doesn't support latest maven plugins 11 | ENV PATH="$PATH:/apache-maven/bin" 12 | RUN mkdir /apache-maven && \ 13 | curl https://archive.apache.org/dist/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz | \ 14 | tar -xz -C /apache-maven --strip-components 1 -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | set -euo pipefail 5 | 6 | echo "Cleaning up..." 7 | docker stop "${OS_DISTRIBUTION}-app" || true 8 | docker rm --force "${OS_DISTRIBUTION}-app" || true 9 | docker stop "${OS_DISTRIBUTION}-tester" || true 10 | docker rm --force "${OS_DISTRIBUTION}-tester" || true 11 | docker network rm "${OS_DISTRIBUTION}-network" || true 12 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/configure_multi_arch_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | set -euo pipefail 5 | 6 | echo "Setting up multi-arch build environment" 7 | ARCHITECTURE=$(arch) 8 | if [[ "$ARCHITECTURE" == "x86_64" ]]; then 9 | TARGET_EMULATOR="arm64" 10 | elif [[ "$ARCHITECTURE" == "aarch64" ]]; then 11 | TARGET_EMULATOR="amd64" 12 | else 13 | echo "Architecture $ARCHITECTURE is not currently supported." 14 | exit 1 15 | fi 16 | 17 | echo "Installing ${TARGET_EMULATOR} emulator" 18 | docker pull public.ecr.aws/eks-distro-build-tooling/binfmt-misc:qemu-v6.1.0 19 | docker run --rm --privileged public.ecr.aws/eks-distro-build-tooling/binfmt-misc:qemu-v6.1.0 --install ${TARGET_EMULATOR} 20 | echo "Setting docker build command to default to buildx" 21 | echo "Docker buildx version: $(docker buildx version)" 22 | docker buildx install 23 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | set -euo pipefail 5 | 6 | echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" 7 | echo 8 | docker logs "${OS_DISTRIBUTION}-app" || true 9 | echo 10 | echo "---------------------------------------------------" 11 | echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" 12 | echo 13 | docker logs "${OS_DISTRIBUTION}-tester" || true 14 | echo 15 | echo "---------------------------------------------------" 16 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/docker/Dockerfile.function.alpine: -------------------------------------------------------------------------------- 1 | ARG DISTRO_VERSION 2 | 3 | FROM public.ecr.aws/docker/library/alpine:${DISTRO_VERSION} 4 | 5 | RUN apk update && \ 6 | apk add openjdk8 7 | 8 | ADD aws-lambda-java-runtime-interface-client/test/integration/test-handler/target/HelloWorld-1.0.jar . 9 | 10 | ENTRYPOINT ["java", "-jar", "./HelloWorld-1.0.jar"] 11 | 12 | CMD ["helloworld.App"] 13 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/docker/Dockerfile.function.amazoncorretto: -------------------------------------------------------------------------------- 1 | ARG RUNTIME_VERSION 2 | 3 | FROM public.ecr.aws/amazoncorretto/amazoncorretto:${RUNTIME_VERSION} 4 | 5 | ADD aws-lambda-java-runtime-interface-client/test/integration/test-handler/target/HelloWorld-1.0.jar . 6 | 7 | ENTRYPOINT ["java", "-jar", "./HelloWorld-1.0.jar"] 8 | 9 | CMD ["helloworld.App"] 10 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/docker/Dockerfile.function.amazonlinux: -------------------------------------------------------------------------------- 1 | ARG DISTRO_VERSION 2 | 3 | FROM public.ecr.aws/amazonlinux/amazonlinux:${DISTRO_VERSION} 4 | 5 | RUN yum install -y java-1.8.0-openjdk 6 | 7 | ADD aws-lambda-java-runtime-interface-client/test/integration/test-handler/target/HelloWorld-1.0.jar . 8 | 9 | ENTRYPOINT ["java", "-jar", "./HelloWorld-1.0.jar"] 10 | 11 | CMD ["helloworld.App"] 12 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/docker/Dockerfile.function.centos: -------------------------------------------------------------------------------- 1 | ARG DISTRO_VERSION 2 | 3 | FROM public.ecr.aws/docker/library/centos:centos${DISTRO_VERSION} 4 | 5 | RUN rpm --import https://yum.corretto.aws/corretto.key && \ 6 | curl -L -o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo && \ 7 | yum install -y java-11-amazon-corretto-devel 8 | 9 | ADD aws-lambda-java-runtime-interface-client/test/integration/test-handler/target/HelloWorld-1.0.jar . 10 | 11 | ENTRYPOINT ["java", "-jar", "./HelloWorld-1.0.jar"] 12 | 13 | CMD ["helloworld.App"] 14 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/docker/Dockerfile.function.debian: -------------------------------------------------------------------------------- 1 | ARG DISTRO_VERSION 2 | 3 | FROM public.ecr.aws/debian/debian:${DISTRO_VERSION} as build-image 4 | 5 | RUN apt-get update && \ 6 | apt-get install -y wget gpg software-properties-common && \ 7 | wget -O- https://apt.corretto.aws/corretto.key | apt-key add - && \ 8 | add-apt-repository 'deb https://apt.corretto.aws stable main' && \ 9 | apt-get update && \ 10 | apt-get install -y java-11-amazon-corretto-jdk 11 | 12 | FROM public.ecr.aws/debian/debian:${DISTRO_VERSION} 13 | 14 | COPY --from=build-image /usr/lib/jvm /usr/lib/jvm 15 | 16 | ADD aws-lambda-java-runtime-interface-client/test/integration/test-handler/target/HelloWorld-1.0.jar . 17 | 18 | ENV PATH=/usr/lib/jvm/java-11-amazon-corretto/bin/:$PATH 19 | 20 | ENTRYPOINT ["java", "-jar", "./HelloWorld-1.0.jar"] 21 | 22 | CMD ["helloworld.App"] 23 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/docker/Dockerfile.function.ubuntu: -------------------------------------------------------------------------------- 1 | ARG DISTRO_VERSION 2 | 3 | FROM public.ecr.aws/ubuntu/ubuntu:${DISTRO_VERSION} as build-image 4 | 5 | RUN apt-get update && \ 6 | apt-get install -y apt-transport-https ca-certificates && \ 7 | apt-get install -y wget gnupg software-properties-common && \ 8 | wget -O- https://apt.corretto.aws/corretto.key | apt-key add - && \ 9 | add-apt-repository 'deb https://apt.corretto.aws stable main' && \ 10 | apt-get update && \ 11 | apt-get install -y java-11-amazon-corretto-jdk 12 | 13 | FROM public.ecr.aws/ubuntu/ubuntu:${DISTRO_VERSION} 14 | 15 | COPY --from=build-image /usr/lib/jvm /usr/lib/jvm 16 | 17 | ADD aws-lambda-java-runtime-interface-client/test/integration/test-handler/target/HelloWorld-1.0.jar . 18 | 19 | ENV PATH=/usr/lib/jvm/java-11-amazon-corretto/bin/:$PATH 20 | 21 | ENTRYPOINT ["java", "-jar", "./HelloWorld-1.0.jar"] 22 | 23 | CMD ["helloworld.App"] 24 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/resources/aws-lambda-rie-arm64.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws/aws-lambda-java-libs/5a0f8ad9e9b8ff61ba626e71c4b5de62134e82e4/aws-lambda-java-runtime-interface-client/test/integration/resources/aws-lambda-rie-arm64.tar.gz -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/resources/aws-lambda-rie.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws/aws-lambda-java-libs/5a0f8ad9e9b8ff61ba626e71c4b5de62134e82e4/aws-lambda-java-runtime-interface-client/test/integration/resources/aws-lambda-rie.tar.gz -------------------------------------------------------------------------------- /aws-lambda-java-runtime-interface-client/test/integration/test-handler/src/main/java/helloworld/App.java: -------------------------------------------------------------------------------- 1 | package helloworld; 2 | 3 | import com.amazonaws.services.lambda.runtime.Context; 4 | import com.amazonaws.services.lambda.runtime.RequestHandler; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * Handler for requests to Lambda function. 10 | */ 11 | public class App implements RequestHandler, String>{ 12 | @Override 13 | public String handleRequest(Map event, Context context) 14 | { 15 | String response = new String("success"); 16 | return response; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/RELEASE.CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### December 1, 2023 2 | `1.1.5`: 3 | - Add support for DynamodbEvent.DynamodbStreamRecord serialization 4 | 5 | ### October 19, 2023 6 | `1.1.4`: 7 | - Update org.json version to 20231013 8 | - Rollback relocation changes(1.1.3 version) 9 | 10 | ### September 21, 2023 11 | `1.1.3`: 12 | - Add support for event v4 lib 13 | 14 | ### February 22, 2023 15 | `1.1.1`: 16 | - Register `JodaModule` to JacksonFactory 17 | 18 | ### February 17, 2023 19 | `1.1.0`: 20 | - Update `jackson-databind` dependency from 2.13.4.1 to 2.14.2 21 | - Register `JavaTimeModule` and `Jdk8Module` modules to `jackson-databind` 22 | 23 | ### February 09, 2023 24 | `1.0.2`: 25 | - Updated `gson` dependency from 2.8.9 to 2.10.1 26 | 27 | ### November 21, 2022 28 | `1.0.1`: 29 | - Updated `jackson-databind` dependency from 2.12.6.1 to 2.13.4.1 30 | 31 | ### December 01, 2020 32 | `1.0.0`: 33 | - Initial release of AWS Lambda Java Serialization -------------------------------------------------------------------------------- /aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/PojoSerializer.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.serialization; 4 | 5 | import java.io.InputStream; 6 | import java.io.OutputStream; 7 | 8 | public interface PojoSerializer { 9 | T fromJson(InputStream input); 10 | T fromJson(String input); 11 | void toJson(T value, OutputStream output); 12 | } 13 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/CloudFrontEventMixin.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.serialization.events.mixins; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Mixin for CloudFrontEvent 11 | */ 12 | public abstract class CloudFrontEventMixin { 13 | 14 | // needed because jackson expects "records" instead of "Records" 15 | @JsonProperty("Records") abstract List getRecords(); 16 | @JsonProperty("Records") abstract void setRecords(List records); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/CloudWatchLogsEventMixin.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.serialization.events.mixins; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | /** 8 | * Interface with Jackson annotations for CloudWatchLogsEvent 9 | */ 10 | public abstract class CloudWatchLogsEventMixin { 11 | 12 | // needed because jackson expects "awsLogs" instead of "awslogs" 13 | @JsonProperty("awslogs") abstract Object getAwsLogs(); 14 | @JsonProperty("awslogs") abstract void setAwsLogs(Object awsLogs); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/CodeCommitEventMixin.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.serialization.events.mixins; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * interface with Jackson annotations for CodeCommitEvent 11 | */ 12 | public abstract class CodeCommitEventMixin { 13 | 14 | // needed because Jackson expects "records" instead of "Records" 15 | @JsonProperty("Records") abstract List getRecords(); 16 | @JsonProperty("Records") abstract void setRecords(List records); 17 | 18 | public abstract class RecordMixin { 19 | 20 | // needed because Jackson expects "codeCommit" instead of "codeCommit" 21 | @JsonProperty("codecommit") abstract Object getCodeCommit(); 22 | @JsonProperty("codecommit") abstract void setCodeCommit(Object codeCommit); 23 | // needed because Jackson expects "eventSourceArn" instead of "eventSourceARN" 24 | @JsonProperty("eventSourceARN") abstract String getEventSourceArn(); 25 | @JsonProperty("eventSourceARN") abstract void setEventSourceArn(String eventSourceArn); 26 | // needed because Jackson expects "userIdentityArn" instead of "UserIdentityArn" 27 | @JsonProperty("userIdentityARN") abstract String getUserIdentityArn(); 28 | @JsonProperty("userIdentityARN") abstract void setUserIdentityArn(String userIdentityArn); 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/DynamodbTimeWindowEventMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | */ 4 | 5 | package com.amazonaws.services.lambda.runtime.serialization.events.mixins; 6 | 7 | import com.fasterxml.jackson.annotation.JsonProperty; 8 | 9 | public abstract class DynamodbTimeWindowEventMixin extends DynamodbEventMixin { 10 | 11 | // needed because Jackson expects "eventSourceArn" instead of "eventSourceARN" 12 | @JsonProperty("eventSourceARN") abstract String getEventSourceArn(); 13 | @JsonProperty("eventSourceARN") abstract void setEventSourceArn(String eventSourceArn); 14 | } 15 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/KinesisEventMixin.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.serialization.events.mixins; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | import java.util.List; 8 | 9 | public abstract class KinesisEventMixin { 10 | 11 | // needed because Jackson expects "records" instead of "Records" 12 | @JsonProperty("Records") abstract List getRecords(); 13 | @JsonProperty("Records") abstract void setRecords(List records); 14 | 15 | public abstract class RecordMixin { 16 | 17 | // needed because Jackson cannot distinguish between Enum encryptionType and String encryptionType 18 | @JsonProperty("encryptionType") abstract String getEncryptionType(); 19 | @JsonProperty("encryptionType") abstract void setEncryptionType(String encryptionType); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/KinesisTimeWindowEventMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | */ 4 | 5 | package com.amazonaws.services.lambda.runtime.serialization.events.mixins; 6 | 7 | import com.fasterxml.jackson.annotation.JsonProperty; 8 | 9 | public abstract class KinesisTimeWindowEventMixin extends KinesisEventMixin { 10 | 11 | // needed because Jackson expects "eventSourceArn" instead of "eventSourceARN" 12 | @JsonProperty("eventSourceARN") abstract String getEventSourceArn(); 13 | @JsonProperty("eventSourceARN") abstract void setEventSourceArn(String eventSourceArn); 14 | } 15 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/SNSEventMixin.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.serialization.events.mixins; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | import java.util.List; 8 | 9 | public abstract class SNSEventMixin { 10 | 11 | // needed because Jackson expects "records" instead of "Records" 12 | @JsonProperty("Records") abstract List getRecords(); 13 | @JsonProperty("Records") abstract void setRecords(List records); 14 | 15 | public abstract class SNSRecordMixin { 16 | 17 | // needed because Jackson expects "getSns" instead of "getSNS" 18 | @JsonProperty("Sns") abstract Object getSNS(); 19 | @JsonProperty("Sns") abstract void setSns(Object sns); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/SQSEventMixin.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.serialization.events.mixins; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | import java.util.List; 8 | 9 | public abstract class SQSEventMixin { 10 | 11 | // Needed because Jackson expects "records" instead of "Records" 12 | @JsonProperty("Records") abstract List getRecords(); 13 | @JsonProperty("Records") abstract void setRecords(List records); 14 | 15 | public abstract class SQSMessageMixin { 16 | 17 | // needed because Jackson expects "eventSourceArn" instead of "eventSourceARN" 18 | @JsonProperty("eventSourceARN") abstract String getEventSourceArn(); 19 | @JsonProperty("eventSourceARN") abstract void setEventSourceArn(String eventSourceArn); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/ScheduledEventMixin.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.serialization.events.mixins; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | /** 8 | * Jackson annotations for ScheduledEvent 9 | */ 10 | public abstract class ScheduledEventMixin { 11 | 12 | // needed because Jackson expects "detailType" instead of "detail-type" 13 | @JsonProperty("detail-type") abstract String getDetailType(); 14 | @JsonProperty("detail-type") abstract void setDetailType(String detailType); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/SecretsManagerRotationEventMixin.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.serialization.events.mixins; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | /** 8 | * Jackson annotations for SecretsManagerRotationEvent 9 | */ 10 | 11 | public abstract class SecretsManagerRotationEventMixin { 12 | 13 | // needed because Jackson expects "step" instead of "Step" 14 | @JsonProperty("Step") abstract String getStep(); 15 | @JsonProperty("Step") abstract void setStep(String step); 16 | 17 | // needed because Jackson expects "secretId" instead of "SecretId" 18 | @JsonProperty("SecretId") abstract String getSecretId(); 19 | @JsonProperty("SecretId") abstract void setSecretId(String secretId); 20 | 21 | // needed because Jackson expects "clientRequestToken" instead of "ClientRequestToken" 22 | @JsonProperty("ClientRequestToken") abstract String getClientRequestToken(); 23 | @JsonProperty("ClientRequestToken") abstract void setClientRequestToken(String clientRequestToken); 24 | 25 | // needed because Jackson expects "rotationToken" instead of "RotationToken" 26 | @JsonProperty("RotationToken") abstract String getRotationToken(); 27 | @JsonProperty("RotationToken") abstract void setRotationToken(String rotationToken); 28 | } 29 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/factories/PojoSerializerFactory.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | 3 | package com.amazonaws.services.lambda.runtime.serialization.factories; 4 | 5 | import com.amazonaws.services.lambda.runtime.serialization.PojoSerializer; 6 | 7 | import java.lang.reflect.Type; 8 | 9 | public interface PojoSerializerFactory { 10 | PojoSerializer getSerializer(Class clazz); 11 | PojoSerializer getSerializer(Type type); 12 | } 13 | -------------------------------------------------------------------------------- /aws-lambda-java-serialization/verify-relocation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | # This script runs after the aws-lambda-java-serialization package phase. It verifies that no unexpected transitive 5 | # dependencies were missed from the relocation of third party classes. 6 | 7 | set -euo pipefail 8 | 9 | ARTIFACT_PATH=${1} 10 | RELOCATION_PREFIX=${2} 11 | SERIALIZATION_MODULE_PATTERN=${3} 12 | 13 | echo 'Validating that serialization module classes were not relocated' 14 | OUTPUT=$(zipinfo ${ARTIFACT_PATH} | grep '.class' | grep ${RELOCATION_PREFIX//.//} | grep ${SERIALIZATION_MODULE_PATTERN//.//} || true) 15 | if [[ ! -z "$OUTPUT" ]]; then 16 | echo "Serialization module classes were unexpectedly relocated" 17 | echo ${OUTPUT} 18 | exit 1 19 | fi 20 | 21 | echo 'Validating that everything other than serialization module classes were relocated' 22 | OUTPUT=$(zipinfo ${ARTIFACT_PATH} | grep '.class' | grep -v ${SERIALIZATION_MODULE_PATTERN//.//} | grep -v 'META-INF' | grep -v ${RELOCATION_PREFIX//.//} || true) 23 | if [[ ! -z "$OUTPUT" ]]; then 24 | echo "Some classes were not relocated" 25 | echo ${OUTPUT} 26 | exit 1 27 | fi 28 | 29 | echo 'Validating that META-INF/services were relocated' 30 | OUTPUT=$(zipinfo ${ARTIFACT_PATH} | grep 'META-INF/services/.\+' | grep -v ${RELOCATION_PREFIX} || true) 31 | if [[ ! -z "$OUTPUT" ]]; then 32 | echo "Some meta-inf services were not relocated" 33 | echo ${OUTPUT} 34 | exit 1 35 | fi 36 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/RELEASE.CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### August 26, 2021 2 | `1.1.1`: 3 | - Bumped `aws-lambda-java-events` to version `3.11.0` 4 | 5 | ### August 26, 2021 6 | `1.1.0`: 7 | - Added test for `RabbitMQEvent` ([#256](https://github.com/aws/aws-lambda-java-libs/pull/256)) 8 | - Added test for `KafkaEventRecord` headers ([#260](https://github.com/aws/aws-lambda-java-libs/pull/260)) 9 | - Bumped `aws-lambda-java-events` to version `3.10.0` 10 | 11 | ### March 24, 2021 12 | `1.0.2`: 13 | - Bumped `aws-lambda-java-events` to version `3.9.0` 14 | 15 | ### March 24, 2021 16 | `1.0.1`: 17 | - Added sorting to the event/response files to guarantee order ([#218](https://github.com/aws/aws-lambda-java-libs/pull/218)) 18 | - Added `bootstrapServers` to Kafka Event tests ([#216](https://github.com/aws/aws-lambda-java-libs/pull/216)) 19 | - Bumped `aws-lambda-java-events` to version `3.8.0` 20 | 21 | ### December 10, 2020 22 | `1.0.0`: 23 | - Initial release of AWS Lambda Java Tests 24 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/EventArgumentsProvider.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | package com.amazonaws.services.lambda.runtime.tests; 3 | 4 | import com.amazonaws.services.lambda.runtime.tests.annotations.Event; 5 | import org.junit.jupiter.api.extension.ExtensionContext; 6 | import org.junit.jupiter.params.provider.Arguments; 7 | import org.junit.jupiter.params.provider.ArgumentsProvider; 8 | import org.junit.jupiter.params.support.AnnotationConsumer; 9 | 10 | import java.util.stream.Stream; 11 | 12 | /** 13 | * Used to process @{@link Event} com.amazonaws.services.lambda.runtime.tests.annotations 14 | */ 15 | public class EventArgumentsProvider implements ArgumentsProvider, AnnotationConsumer { 16 | 17 | private Event event; 18 | 19 | @Override 20 | public Stream provideArguments(ExtensionContext extensionContext) { 21 | Object o = EventLoader.loadEvent(event.value(), event.type()); 22 | return Stream.of(Arguments.of(o)); 23 | } 24 | 25 | @Override 26 | public void accept(Event event) { 27 | this.event = event; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/EventLoadingException.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | package com.amazonaws.services.lambda.runtime.tests; 3 | 4 | public class EventLoadingException extends RuntimeException { 5 | 6 | private static final long serialVersionUID = 5766526909472206270L; 7 | 8 | public EventLoadingException() { 9 | } 10 | 11 | public EventLoadingException(String message) { 12 | super(message); 13 | } 14 | 15 | public EventLoadingException(String message, Throwable cause) { 16 | super(message, cause); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/annotations/Event.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | package com.amazonaws.services.lambda.runtime.tests.annotations; 3 | 4 | import com.amazonaws.services.lambda.runtime.tests.EventArgumentsProvider; 5 | import org.junit.jupiter.params.provider.ArgumentsSource; 6 | 7 | import java.lang.annotation.*; 8 | 9 | /** 10 | * This annotation must be used in conjunction with {@link org.junit.jupiter.params.ParameterizedTest}.
11 | * It enables to inject an event (loaded from a json file) of the desired type into the current test.
12 | * Example:
13 | *
14 |  *     @ParameterizedTest
15 |  *     @Event(value = "sqs_event.json", type = SQSEvent.class)
16 |  *     public void testInjectEvent(SQSEvent event) {
17 |  *         assertThat(event).isNotNull();
18 |  *         assertThat(event.getRecords()).hasSize(1);
19 |  *     }
20 |  * 
21 | */ 22 | @Documented 23 | @Target(ElementType.METHOD) 24 | @Retention(RetentionPolicy.RUNTIME) 25 | @ArgumentsSource(EventArgumentsProvider.class) 26 | public @interface Event { 27 | 28 | /** 29 | * Path and file name of the json event 30 | * @return the file name (including the path) 31 | */ 32 | String value(); 33 | 34 | /** 35 | * Type of the event (for example, one of the aws-lambda-java-events), or your own type 36 | * @return the type of the event 37 | */ 38 | Class type() default Void.class; 39 | } 40 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/annotations/Response.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | package com.amazonaws.services.lambda.runtime.tests.annotations; 3 | 4 | import java.lang.annotation.*; 5 | 6 | /** 7 | * This annotation must be used in conjunction with {@link HandlerParams}. 8 | */ 9 | @Documented 10 | @Target(ElementType.METHOD) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | public @interface Response { 13 | 14 | /** 15 | * Path and file name of the json response 16 | * @return the file name (including the path) 17 | */ 18 | String value(); 19 | 20 | /** 21 | * Type of the response 22 | * @return the type of the response 23 | */ 24 | Class type() default Void.class; 25 | } 26 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/annotations/Responses.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | package com.amazonaws.services.lambda.runtime.tests.annotations; 3 | 4 | import java.lang.annotation.*; 5 | 6 | /** 7 | * This annotation must be used in conjunction with {@link HandlerParams}. 8 | */ 9 | @Documented 10 | @Target(ElementType.METHOD) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | public @interface Responses { 13 | 14 | /** 15 | * Folder where to find json files containing responses 16 | * @return the folder name 17 | */ 18 | String folder() default ""; 19 | 20 | /** 21 | * Type of the responses 22 | * @return the type of the responses 23 | */ 24 | Class type() default Void.class; 25 | 26 | /** 27 | * Mutually exclusive with folder 28 | * @return the array of responses 29 | */ 30 | Response[] responses() default {}; 31 | } 32 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/java/com/amazonaws/services/lambda/runtime/tests/EventTest.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ 2 | package com.amazonaws.services.lambda.runtime.tests; 3 | 4 | import com.amazonaws.services.lambda.runtime.events.SQSEvent; 5 | import com.amazonaws.services.lambda.runtime.tests.annotations.Event; 6 | import org.junit.jupiter.params.ParameterizedTest; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | public class EventTest { 11 | 12 | @ParameterizedTest 13 | @Event(value = "sqs/sqs_event_nobody.json", type = SQSEvent.class) 14 | public void testInjectEvent(SQSEvent event) { 15 | assertThat(event).isNotNull(); 16 | assertThat(event.getRecords()).hasSize(1); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/java/com/amazonaws/services/lambda/runtime/tests/S3BatchEventV2Test.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.services.lambda.runtime.tests; 2 | 3 | import com.amazonaws.services.lambda.runtime.events.S3BatchEventV2; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.assertj.core.api.Assertions.*; 7 | 8 | public class S3BatchEventV2Test { 9 | 10 | @Test 11 | public void testS3BatchEventV2() { 12 | S3BatchEventV2 event = EventLoader.loadS3BatchEventV2("s3_batch_event_v2.json"); 13 | assertThat(event).isNotNull(); 14 | assertThat(event.getInvocationId()).isEqualTo("Jr3s8KZqYWRmaiBhc2RmdW9hZHNmZGpmaGFzbGtkaGZzatx7Ruy"); 15 | assertThat(event.getJob()).isNotNull(); 16 | assertThat(event.getJob().getUserArguments().get("MyDestinationBucket")).isEqualTo("destination-directory-bucket-name"); 17 | assertThat(event.getTasks()).hasSize(1); 18 | assertThat(event.getTasks().get(0).getS3Key()).isEqualTo("s3objectkey"); 19 | assertThat(event.getTasks().get(0).getS3Bucket()).isEqualTo("source-directory-bucket-name"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/apigw/responses/apigw_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "body": "{\"message\": \"Lambda rocks\"}", 3 | "statusCode": 200, 4 | "headers": { 5 | "Cache-Control": "max-age=0", 6 | "Host": "1234567890.execute-api.us-east-1.amazonaws.com", 7 | "Upgrade-Insecure-Requests": "1", 8 | "User-Agent": "Custom User Agent String", 9 | "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", 10 | "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", 11 | "X-Forwarded-For": "127.0.0.1, 127.0.0.2", 12 | "X-Forwarded-Port": "443", 13 | "X-Forwarded-Proto": "https" 14 | }, 15 | "isBase64Encoded": false 16 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/apigw/responses/apigw_response2.json: -------------------------------------------------------------------------------- 1 | { 2 | "body": "", 3 | "statusCode": 200, 4 | "headers": { 5 | "Cache-Control": "max-age=0", 6 | "Host": "1234567890.execute-api.us-east-1.amazonaws.com", 7 | "Upgrade-Insecure-Requests": "1", 8 | "User-Agent": "Custom User Agent String", 9 | "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", 10 | "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", 11 | "X-Forwarded-For": "127.0.0.1, 127.0.0.2", 12 | "X-Forwarded-Port": "443", 13 | "X-Forwarded-Proto": "https" 14 | }, 15 | "isBase64Encoded": false 16 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/apigw_auth.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "type": "REQUEST", 4 | "methodArn": "arn:aws:execute-api:us-east-1:123456789012:abcdef123/test/GET/request", 5 | "identitySource": "user1,123", 6 | "authorizationToken": "user1,123", 7 | "resource": "/request", 8 | "path": "/request", 9 | "httpMethod": "GET", 10 | "headers": { 11 | "X-AMZ-Date": "20170718T062915Z", 12 | "Accept": "*/*", 13 | "HeaderAuth1": "headerValue1", 14 | "CloudFront-Viewer-Country": "US", 15 | "CloudFront-Forwarded-Proto": "https", 16 | "CloudFront-Is-Tablet-Viewer": "false", 17 | "CloudFront-Is-Mobile-Viewer": "false", 18 | "User-Agent": "..." 19 | }, 20 | "queryStringParameters": { 21 | "QueryString1": "queryValue1" 22 | }, 23 | "pathParameters": {}, 24 | "stageVariables": { 25 | "StageVar1": "stageValue1" 26 | }, 27 | "requestContext": { 28 | "path": "/request", 29 | "accountId": "123456789012", 30 | "resourceId": "05c7jb", 31 | "stage": "test", 32 | "requestId": "...", 33 | "identity": { 34 | "apiKey": "...", 35 | "sourceIp": "..." 36 | }, 37 | "resourcePath": "/request", 38 | "httpMethod": "GET", 39 | "apiId": "abcdef123" 40 | } 41 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/apigw_auth_v2.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "type": "REQUEST", 4 | "routeArn": "arn:aws:execute-api:us-east-1:123456789012:abcdef123/test/GET/request", 5 | "identitySource": ["user1", "123"], 6 | "routeKey": "$default", 7 | "rawPath": "/my/path", 8 | "rawQueryString": "parameter1=value1¶meter1=value2¶meter2=value", 9 | "cookies": [ "cookie1", "cookie2" ], 10 | "headers": { 11 | "Header1": "value1", 12 | "Header2": "value2" 13 | }, 14 | "queryStringParameters": { "parameter1": "value1,value2", "parameter2": "value" }, 15 | "requestContext": { 16 | "accountId": "123456789012", 17 | "apiId": "api-id", 18 | "domainName": "id.execute-api.us-east-1.amazonaws.com", 19 | "domainPrefix": "id", 20 | "http": { 21 | "method": "POST", 22 | "path": "/my/path", 23 | "protocol": "HTTP/1.1", 24 | "sourceIp": "IP", 25 | "userAgent": "agent" 26 | }, 27 | "requestId": "id", 28 | "routeKey": "$default", 29 | "stage": "$default", 30 | "time": "12/Mar/2020:19:03:58 +0000", 31 | "timeEpoch": 1583348638390 32 | }, 33 | "pathParameters": {"parameter1": "value1"}, 34 | "stageVariables": {"stageVariable1": "value1", "stageVariable2": "value2"} 35 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/cloudformation_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "RequestType": "Update", 3 | "ResponseURL": "http://pre-signed-S3-url-for-response", 4 | "StackId": "arn:aws:cloudformation:eu-central-1:123456789012:stack/MyStack/guid", 5 | "RequestId": "unique id for this create request", 6 | "ResourceType": "Custom::TestResource", 7 | "LogicalResourceId": "MyTestResource", 8 | "PhysicalResourceId": "MyTestResourceId", 9 | "ServiceToken": "abcd", 10 | "ResourceProperties": { 11 | "StackName": "MyStack", 12 | "List": [ 13 | "1", 14 | "2", 15 | "3" 16 | ] 17 | }, 18 | "OldResourceProperties": { 19 | "StackName": "MyStack", 20 | "List": [ 21 | "1" 22 | ] 23 | } 24 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/cloudfront_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "cf": { 5 | "config": { 6 | "distributionId": "EXAMPLE" 7 | }, 8 | "request": { 9 | "uri": "/test", 10 | "querystring": "auth=test&foo=bar", 11 | "method": "GET", 12 | "clientIp": "2001:cdba::3257:9652", 13 | "headers": { 14 | "host": [ 15 | { 16 | "key": "Host", 17 | "value": "d123.cf.net" 18 | } 19 | ], 20 | "user-agent": [ 21 | { 22 | "key": "User-Agent", 23 | "value": "Test Agent" 24 | } 25 | ], 26 | "user-name": [ 27 | { 28 | "key": "User-Name", 29 | "value": "aws-cloudfront" 30 | } 31 | ] 32 | } 33 | } 34 | } 35 | } 36 | ] 37 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/cloudwatch_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0", 3 | "id": "fae0433b-7a0e-e383-7849-7e10153eaa47", 4 | "detail-type": "Scheduled Event", 5 | "source": "aws.events", 6 | "account": "123456789012", 7 | "time": "2020-09-30T15:58:34Z", 8 | "region": "eu-central-1", 9 | "resources": [ 10 | "arn:aws:events:eu-central-1:123456789012:rule/demoschedule" 11 | ], 12 | "detail": { 13 | 14 | } 15 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/cloudwatchlogs_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "awslogs": { 3 | "data": "H4sIAAAAAAAAAHWPwQqCQBCGX0Xm7EFtK+smZBEUgXoLCdMhFtKV3akI8d0bLYmibvPPN3wz00CJxmQnTO41whwWQRIctmEcB6sQbFC3CjW3XW8kxpOpP+OC22d1Wml1qZkQGtoMsScxaczKN3plG8zlaHIta5KqWsozoTYw3/djzwhpLwivWFGHGpAFe7DL68JlBUk+l7KSN7tCOEJ4M3/qOI49vMHj+zCKdlFqLaU2ZHV2a4Ct/an0/ivdX8oYc1UVX860fQDQiMdxRQEAAA==" 4 | } 5 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/codecommit_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "awsRegion": "eu-central-1", 5 | "codecommit": { 6 | "references": [ 7 | { 8 | "commit": "5c4ef1049f1d27deadbeeff313e0730018be182b", 9 | "ref": "refs/heads/master" 10 | } 11 | ] 12 | }, 13 | "customData": "this is custom data", 14 | "eventId": "5a824061-17ca-46a9-bbf9-114edeadbeef", 15 | "eventName": "TriggerEventTest", 16 | "eventPartNumber": 1, 17 | "eventSource": "aws:codecommit", 18 | "eventSourceARN": "arn:aws:codecommit:eu-central-1:123456789012:my-repo", 19 | "eventTime": "2016-01-01T23:59:59.000+0000", 20 | "eventTotalParts": 1, 21 | "eventTriggerConfigId": "5a824061-17ca-46a9-bbf9-114edeadbeef", 22 | "eventTriggerName": "my-trigger", 23 | "eventVersion": "1.0", 24 | "userIdentityARN": "arn:aws:iam::123456789012:root" 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/config_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "invokingEvent": "{\"configurationItem\":{\"configurationItemCaptureTime\":\"2016-10-06T16:46:16.261Z\",\"awsAccountId\":\"123456789012\",\"configurationItemStatus\":\"OK\",\"resourceId\":\"i-00000000\",\"resourceName\":\"foo\",\"configurationStateMd5Hash\":\"8f1ee69b297895a0f8bc5753eca68e96\",\"resourceCreationTime\":\"2016-10-06T16:46:10.489Z\",\"configurationStateId\":0,\"configurationItemVersion\":\"1.2\",\"ARN\":\"arn:aws:ec2:eu-central-1:123456789012:instance/i-00000000\",\"awsRegion\":\"eu-central-1\",\"availabilityZone\":\"eu-central-1\",\"resourceType\":\"AWS::EC2::Instance\",\"tags\":{\"\":\"\"},\"relationships\":[{\"resourceId\":\"eipalloc-00000000\",\"resourceType\":\"AWS::EC2::EIP\",\"name\":\"Is attached to ElasticIp\"}],\"configuration\":{\"\":\"\"}},\"messageType\":\"ConfigurationItemChangeNotification\"}", 3 | "ruleParameters": "{\"\":\"\"}", 4 | "resultToken": "myResultToken", 5 | "eventLeftScope": false, 6 | "executionRoleArn": "arn:aws:iam::123456789012:role/config-role", 7 | "configRuleArn": "arn:aws:config:eu-central-1:123456789012:config-rule/config-rule-0123456", 8 | "configRuleName": "change-triggered-config-rule", 9 | "configRuleId": "config-rule-0123456", 10 | "accountId": "123456789012", 11 | "version": "1.0" 12 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/connect_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Name": "ContactFlowEvent", 3 | "Details": { 4 | "ContactData": { 5 | "Attributes": {}, 6 | "Channel": "VOICE", 7 | "ContactId": "5ca32fbd-8f92-46af-92a5-6b0f970f0efe", 8 | "CustomerEndpoint": { 9 | "Address": "+11234567890", 10 | "Type": "TELEPHONE_NUMBER" 11 | }, 12 | "InitialContactId": "6ca32fbd-8f92-46af-92a5-6b0f970f0efe", 13 | "InitiationMethod": "API", 14 | "InstanceARN": "arn:aws:connect:eu-central-1:123456789012:instance/9308c2a1-9bc6-4cea-8290-6c0b4a6d38fa", 15 | "MediaStreams": { 16 | "Customer": { 17 | "Audio": { 18 | "StartFragmentNumber": "91343852333181432392682062622220590765191907586", 19 | "StartTimestamp": "1565781909613", 20 | "StreamARN": "arn:aws:kinesisvideo:eu-central-1:123456789012:stream/connect-contact-a3d73b84-ce0e-479a-a9dc-5637c9d30ac9/1565272947806" 21 | } 22 | } 23 | }, 24 | "PreviousContactId": "4ca32fbd-8f92-46af-92a5-6b0f970f0efe", 25 | "Queue": null, 26 | "SystemEndpoint": { 27 | "Address": "+21234567890", 28 | "Type": "TELEPHONE_NUMBER" 29 | } 30 | }, 31 | "Parameters": {} 32 | } 33 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/ddb/dynamo_ddb_stream_record.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventID": "c81e728d9d4c2f636f067f89cc14862c", 3 | "eventName": "MODIFY", 4 | "eventVersion": "1.1", 5 | "eventSource": "aws:dynamodb", 6 | "awsRegion": "eu-central-1", 7 | "dynamodb": { 8 | "Keys": { 9 | "Id": { 10 | "N": "101" 11 | } 12 | }, 13 | "NewImage": { 14 | "Message": { 15 | "S": "This item has changed" 16 | }, 17 | "Id": { 18 | "N": "101" 19 | } 20 | }, 21 | "OldImage": { 22 | "Message": { 23 | "S": "New item!" 24 | }, 25 | "Id": { 26 | "N": "101" 27 | } 28 | }, 29 | "ApproximateCreationDateTime": 1.635734407123456789E9, 30 | "SequenceNumber": "4421584500000000017450439092", 31 | "SizeBytes": 59, 32 | "StreamViewType": "NEW_AND_OLD_IMAGES" 33 | }, 34 | "eventSourceARN": "arn:aws:dynamodb:eu-central-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899" 35 | } 36 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/elb_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "requestContext": { 3 | "elb": { 4 | "targetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:XXXXXXXXXXX:targetgroup/sample/6d0ecf831eec9f09" 5 | } 6 | }, 7 | "httpMethod": "GET", 8 | "path": "/", 9 | "queryStringParameters": {}, 10 | "headers": { 11 | "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", 12 | "accept-encoding": "gzip", 13 | "accept-language": "en-US,en;q=0.5", 14 | "connection": "keep-alive", 15 | "cookie": "name=value", 16 | "host": "lambda-YYYYYYYY.elb.amazonaws.com", 17 | "upgrade-insecure-requests": "1", 18 | "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:60.0) Gecko/20100101 Firefox/60.0", 19 | "x-amzn-trace-id": "Root=1-5bdb40ca-556d8b0c50dc66f0511bf520", 20 | "x-forwarded-for": "192.0.2.1", 21 | "x-forwarded-port": "80", 22 | "x-forwarded-proto": "http" 23 | }, 24 | "body": "Hello from ELB", 25 | "isBase64Encoded": false 26 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/firehose_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "invocationId": "invocationIdExample", 3 | "deliveryStreamArn": "arn:aws:kinesis:EXAMPLE", 4 | "region": "eu-central-1", 5 | "records": [ 6 | { 7 | "recordId": "49546986683135544286507457936321625675700192471156785154", 8 | "approximateArrivalTimestamp": 1495072949453, 9 | "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/kafka_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSource": "aws:kafka", 3 | "eventSourceArn": "arn:aws:kafka:us-east-1:123456789012:cluster/vpc-3432434/4834-3547-3455-9872-7929", 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 | "mytopic-01": [ 7 | { 8 | "topic": "mytopic", 9 | "partition": 0, 10 | "offset": 15, 11 | "timestamp": 1596480920837, 12 | "timestampType": "CREATE_TIME", 13 | "value": "SGVsbG8gZnJvbSBLYWZrYSAhIQ==", 14 | "headers": [ 15 | { 16 | "headerKey": [ 17 | 104, 18 | 101, 19 | 97, 20 | 100, 21 | 101, 22 | 114, 23 | 86, 24 | 97, 25 | 108, 26 | 117, 27 | 101 28 | ] 29 | } 30 | ] 31 | } 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/kinesis_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "kinesis": { 5 | "partitionKey": "partitionKey-03", 6 | "kinesisSchemaVersion": "1.0", 7 | "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=", 8 | "sequenceNumber": "49545115243490985018280067714973144582180062593244200961", 9 | "approximateArrivalTimestamp": 1428537600, 10 | "encryptionType": "NONE" 11 | }, 12 | "eventSource": "aws:kinesis", 13 | "eventID": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961", 14 | "invokeIdentityArn": "arn:aws:iam::EXAMPLE", 15 | "eventVersion": "1.0", 16 | "eventName": "aws:kinesis:record", 17 | "eventSourceARN": "arn:aws:kinesis:EXAMPLE", 18 | "awsRegion": "eu-central-1" 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/lambda_destination_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "timestamp": "2019-11-24T21:52:47.333Z", 4 | "requestContext": { 5 | "requestId": "8ea123e4-1db7-4aca-ad10-d9ca1234c1fd", 6 | "functionArn": "arn:aws:lambda:sa-east-1:123456678912:function:event-destinations:$LATEST", 7 | "condition": "RetriesExhausted", 8 | "approximateInvokeCount": 3 9 | }, 10 | "requestPayload": { 11 | "Success": false 12 | }, 13 | "responseContext": { 14 | "statusCode": 200, 15 | "executedVersion": "$LATEST", 16 | "functionError": "Handled" 17 | }, 18 | "responsePayload": { 19 | "errorMessage": "Failure from event, Success = false, I am failing!", 20 | "errorType": "Error", 21 | "stackTrace": [ "exports.handler (/var/task/index.js:18:18)" ] 22 | } 23 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/lex_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "messageVersion": "1.0", 3 | "invocationSource": "DialogCodeHook", 4 | "userId": "John", 5 | "sessionAttributes": { 6 | "key": "value" 7 | }, 8 | "bot": { 9 | "name": "BookTrip", 10 | "alias": "$LATEST", 11 | "version": "$LATEST" 12 | }, 13 | "outputDialogMode": "Text", 14 | "currentIntent": { 15 | "name": "BookHotel", 16 | "slots": { 17 | "Location": "Chicago", 18 | "CheckInDate": "2030-11-08", 19 | "Nights": 4, 20 | "RoomType": "queen" 21 | }, 22 | "confirmationStatus": "None" 23 | } 24 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/mq_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSource": "aws:amq", 3 | "eventSourceArn": "arn:aws:mq:us-west-2:112556298976:broker:test:b-9bcfa592-423a-4942-879d-eb284b418fc8", 4 | "messages": [ 5 | { 6 | "messageID": "ID:b-9bcfa592-423a-4942-879d-eb284b418fc8-1.mq.us-west-2.amazonaws.com-37557-1234520418293-4:1:1:1:1", 7 | "messageType": "jms/text-message", 8 | "data": "QUJDOkFBQUE=", 9 | "connectionId": "myJMSCoID", 10 | "redelivered": false, 11 | "destination": { 12 | "physicalname": "testQueue" 13 | }, 14 | "timestamp": 1598827811958, 15 | "brokerInTime": 1598827811958, 16 | "brokerOutTime": 1598827811959, 17 | "properties": { 18 | "testKey": "testValue" 19 | } 20 | }, 21 | { 22 | "messageID": "ID:b-8bcfa572-428a-4642-879d-eb284b418fc8-1.mq.us-west-2.amazonaws.com-37557-1234520418293-4:1:1:1:1", 23 | "messageType": "jms/bytes-message", 24 | "data": "3DTOOW7crj51prgVLQaGQ82S48k=", 25 | "connectionId": "myJMSCoID1", 26 | "persistent": false, 27 | "destination": { 28 | "physicalname": "testQueue" 29 | }, 30 | "timestamp": 1598827811958, 31 | "brokerInTime": 1598827811958, 32 | "brokerOutTime": 1598827811959, 33 | "properties": { 34 | "testKey": "testValue" 35 | } 36 | } 37 | ] 38 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/msk_firehose_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "invocationId": "12345621-4787-0000-a418-36e56Example", 3 | "sourceMSKArn": "arn:aws:kafka:EXAMPLE", 4 | "deliveryStreamArn": "arn:aws:firehose:EXAMPLE", 5 | "region": "us-east-1", 6 | "records": [ 7 | { 8 | "recordId": "00000000000000000000000000000000000000000000000000000000000000", 9 | "approximateArrivalTimestamp": 1716369573887, 10 | "mskRecordMetadata": { 11 | "offset": "0", 12 | "partitionId": "1", 13 | "approximateArrivalTimestamp": 1716369573887 14 | }, 15 | "kafkaRecordValue": "eyJOYW1lIjoiSGVsbG8gV29ybGQifQ==" 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/rabbitmq_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "eventSource": "aws:rmq", 3 | "eventSourceArn": "arn:aws:mq:us-west-2:112556298976:broker:test:b-9bcfa592-423a-4942-879d-eb284b418fc8", 4 | "rmqMessagesByQueue": { 5 | "test::/": [ 6 | { 7 | "basicProperties": { 8 | "contentType": "text/plain", 9 | "contentEncoding": null, 10 | "headers": { 11 | "header1": { 12 | "bytes": [ 13 | 118, 14 | 97, 15 | 108, 16 | 117, 17 | 101, 18 | 49 19 | ] 20 | }, 21 | "header2": { 22 | "bytes": [ 23 | 118, 24 | 97, 25 | 108, 26 | 117, 27 | 101, 28 | 50 29 | ] 30 | }, 31 | "numberInHeader": 10 32 | }, 33 | "deliveryMode": 1, 34 | "priority": 34, 35 | "correlationId": null, 36 | "replyTo": null, 37 | "expiration": "60000", 38 | "messageId": null, 39 | "timestamp": "Jan 1, 1970, 12:33:41 AM", 40 | "type": null, 41 | "userId": "AIDACKCEVSQ6C2EXAMPLE", 42 | "appId": null, 43 | "clusterId": null, 44 | "bodySize": 80 45 | }, 46 | "redelivered": false, 47 | "data": "eyJ0aW1lb3V0IjowLCJkYXRhIjoiQ1pybWYwR3c4T3Y0YnFMUXhENEUifQ==" 48 | } 49 | ] 50 | } 51 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/s3_batch_event_v2.json: -------------------------------------------------------------------------------- 1 | { 2 | "invocationSchemaVersion": "2.0", 3 | "invocationId": "Jr3s8KZqYWRmaiBhc2RmdW9hZHNmZGpmaGFzbGtkaGZzatx7Ruy", 4 | "job": { 5 | "id": "ry77cd60-61f6-4a2b-8a21-d07600c874gf", 6 | "userArguments": { 7 | "MyDestinationBucket": "destination-directory-bucket-name", 8 | "MyDestinationBucketRegion": "us-east-1", 9 | "MyDestinationPrefix": "copied/", 10 | "MyDestinationObjectKeySuffix": "_new_suffix" 11 | } 12 | }, 13 | "tasks": [ 14 | { 15 | "taskId": "y5R3a2lkZ29lc2hlurcS", 16 | "s3Key": "s3objectkey", 17 | "s3VersionId": null, 18 | "s3Bucket": "source-directory-bucket-name" 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/s3_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "eventVersion": "2.0", 5 | "eventSource": "aws:s3", 6 | "awsRegion": "eu-central-1", 7 | "eventTime": "1970-01-01T00:00:00.000Z", 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": "EXAMPLE123456789", 17 | "x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH" 18 | }, 19 | "s3": { 20 | "s3SchemaVersion": "1.0", 21 | "configurationId": "testConfigRule", 22 | "bucket": { 23 | "name": "example-bucket", 24 | "ownerIdentity": { 25 | "principalId": "EXAMPLE" 26 | }, 27 | "arn": "arn:aws:s3:::example-bucket" 28 | }, 29 | "object": { 30 | "key": "test/key", 31 | "size": 1024, 32 | "eTag": "0123456789abcdef0123456789abcdef", 33 | "sequencer": "0A1B2C3D4E5F678901" 34 | } 35 | } 36 | } 37 | ] 38 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/secrets_rotation_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Step" : "CreateSecret", 3 | "SecretId" : "arn:aws:secretsmanager:eu-central-1:123456789012:secret:/powertools/secretparam-xBPaJ5", 4 | "ClientRequestToken" : "123e4567-e89b-12d3-a456-426614174000", 5 | "RotationToken": "8a4cc1ac-82ea-47c7-bd9f-aeb370b1b6a6" 6 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/sns_event.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "EventSource": "aws:sns", 5 | "EventVersion": "1.0", 6 | "EventSubscriptionArn": "arn:aws:sns:eu-central-1:123456789012:TopicSendToMe:e3ddc7d5-2f86-40b8-a13d-3362f94fd8dd", 7 | "Sns": { 8 | "Type": "Notification", 9 | "MessageId": "dc918f50-80c6-56a2-ba33-d8a9bbf013ab", 10 | "TopicArn": "arn:aws:sns:eu-central-1:123456789012:TopicSendToMe", 11 | "Subject": "Test sns message", 12 | "Message": "{\n \"id\": 42,\n \"name\": \"Bob\"\n}", 13 | "Timestamp": "2020-10-08T16:06:14.656Z", 14 | "SignatureVersion": "1", 15 | "Signature": "UWnPpkqPAphyr+6PXzUF9++4zJcw==", 16 | "SigningCertUrl": "https://sns.eu-central-1.amazonaws.com/SimpleNotificationService-a86cb10b4e1f29c941702d737128f7b6.pem", 17 | "UnsubscribeUrl": "https://sns.eu-central-1.amazonaws.com/?Action=Unsubscribe", 18 | "MessageAttributes": { 19 | "name": { 20 | "Type": "String", 21 | "Value": "Bob" 22 | } 23 | } 24 | } 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/sqs/sqs_event_nobody.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "messageId": "d9144555-9a4f-4ec3-99a0-fc4e625a8db2", 5 | "receiptHandle": "7kam5bfzbDsjtcjElvhSbxeLJbeey3A==", 6 | "body": "", 7 | "attributes": { 8 | "ApproximateReceiveCount": "1", 9 | "SentTimestamp": "1601975709495", 10 | "SenderId": "AROAIFU457DVZ5L2J53F2", 11 | "ApproximateFirstReceiveTimestamp": "1601975709499" 12 | }, 13 | "messageAttributes": { 14 | 15 | }, 16 | "md5OfBody": "0f96e88a291edb4429f2f7b9fdc3df96", 17 | "eventSource": "aws:sqs", 18 | "eventSourceARN": "arn:aws:sqs:eu-central-1:123456789012:TestLambda", 19 | "awsRegion": "eu-central-1" 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /aws-lambda-java-tests/src/test/resources/sqs/sqs_event_product.json: -------------------------------------------------------------------------------- 1 | { 2 | "Records": [ 3 | { 4 | "messageId": "d9144555-9a4f-4ec3-99a0-34ce359b4b54", 5 | "receiptHandle": "13e7f7851d2eaa5c01f208ebadbf1e72==", 6 | "body": "{\n \"id\": 1234,\n \"name\": \"Product1234\",\n \"price\": 450\n}", 7 | "attributes": { 8 | "ApproximateReceiveCount": "1", 9 | "SentTimestamp": "1601975706495", 10 | "SenderId": "AROAIFU437PVZ5L2J53F5", 11 | "ApproximateFirstReceiveTimestamp": "1601975706499" 12 | }, 13 | "messageAttributes": { 14 | 15 | }, 16 | "md5OfBody": "13e7f7851d2eaa5c01f208ebadbf1e72", 17 | "eventSource": "aws:sqs", 18 | "eventSourceARN": "arn:aws:sqs:eu-central-1:123456789012:TestLambda", 19 | "awsRegion": "eu-central-1" 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/.gitignore: -------------------------------------------------------------------------------- 1 | *.zip 2 | /.idea/ 3 | /target/ 4 | -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip 20 | -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/RELEASE.CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### March 31, 2025 2 | `0.1.1` [link to tag](https://github.com/aws/aws-lambda-java-libs/releases/tag/profiler-extension-0.1.1) 3 | - fix: use PROFILER_STOP_COMMAND in Shutdown hooks ([#537](https://github.com/aws/aws-lambda-java-libs/pull/537)) 4 | 5 | ### March 18, 2025 6 | `0.1.0` [link to tag](https://github.com/aws/aws-lambda-java-libs/releases/tag/profiler-extension-0.1.0) 7 | - Initial release -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/docs/example-cold-start-flame-graph-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws/aws-lambda-java-libs/5a0f8ad9e9b8ff61ba626e71c4b5de62134e82e4/experimental/aws-lambda-java-profiler/docs/example-cold-start-flame-graph-small.png -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/docs/example-cold-start-flame-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws/aws-lambda-java-libs/5a0f8ad9e9b8ff61ba626e71c4b5de62134e82e4/experimental/aws-lambda-java-profiler/docs/example-cold-start-flame-graph.png -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/examples/cdk/.gitignore: -------------------------------------------------------------------------------- 1 | .classpath.txt 2 | target 3 | .classpath 4 | .project 5 | .idea 6 | .settings 7 | .vscode 8 | *.iml 9 | 10 | # CDK asset staging directory 11 | .cdk.staging 12 | cdk.out 13 | 14 | -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/examples/cdk/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to your CDK Java project! 2 | 3 | This is a blank project for CDK development with Java. 4 | 5 | The `cdk.json` file tells the CDK Toolkit how to execute your app. 6 | 7 | It is a [Maven](https://maven.apache.org/) based project, so you can open this project with any Maven compatible Java IDE to build and run tests. 8 | 9 | ## Useful commands 10 | 11 | * `mvn package` compile and run tests 12 | * `cdk ls` list all stacks in the app 13 | * `cdk synth` emits the synthesized CloudFormation template 14 | * `cdk deploy` deploy this stack to your default AWS account/region 15 | * `cdk diff` compare deployed stack with current state 16 | * `cdk docs` open CDK documentation 17 | 18 | Enjoy! 19 | -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/examples/function/profiling-example/src/test/java/helloworld/AppTest.java: -------------------------------------------------------------------------------- 1 | package helloworld; 2 | 3 | import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; 4 | import static org.junit.Assert.assertEquals; 5 | import static org.junit.Assert.assertNotNull; 6 | import static org.junit.Assert.assertTrue; 7 | import org.junit.Test; 8 | 9 | public class AppTest { 10 | @Test 11 | public void successfulResponse() { 12 | App app = new App(); 13 | APIGatewayProxyResponseEvent result = app.handleRequest(null, null); 14 | assertEquals(200, result.getStatusCode().intValue()); 15 | assertEquals("application/json", result.getHeaders().get("Content-Type")); 16 | String content = result.getBody(); 17 | assertNotNull(content); 18 | assertTrue(content.contains("\"message\"")); 19 | assertTrue(content.contains("\"hello world\"")); 20 | assertTrue(content.contains("\"location\"")); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/extension/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id "com.gradleup.shadow" version "8.3.3" 4 | } 5 | 6 | repositories { 7 | mavenCentral() 8 | } 9 | 10 | sourceCompatibility = 11 11 | targetCompatibility = 11 12 | 13 | dependencies { 14 | implementation 'com.amazonaws:aws-lambda-java-core:1.2.3' 15 | implementation 'com.amazonaws:aws-lambda-java-events:3.11.5' 16 | implementation("tools.profiler:async-profiler:3.0") 17 | implementation("software.amazon.awssdk:s3:2.31.2") { 18 | exclude group: 'software.amazon.awssdk', module: 'netty-nio-client' 19 | } 20 | } 21 | 22 | jar { 23 | manifest { 24 | attributes 'Main-Class': 'com.amazonaws.services.lambda.extension.ExtensionMain' 25 | attributes 'Premain-Class': 'com.amazonaws.services.lambda.extension.PreMain' 26 | attributes 'Can-Redefine-Class': true 27 | } 28 | } 29 | 30 | shadowJar { 31 | archiveFileName = "profiler-extension.jar" 32 | } 33 | 34 | build.dependsOn jar 35 | -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/extension/build_layer.sh: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | ./gradlew :shadowJar 5 | 6 | chmod +x extensions/profiler-extension 7 | archive="extension.zip" 8 | if [ -f "$archive" ] ; then 9 | rm "$archive" 10 | fi 11 | 12 | zip "$archive" -j build/libs/profiler-extension.jar 13 | zip "$archive" extensions/* -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/extension/extensions/profiler-extension: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # SPDX-License-Identifier: MIT-0 4 | 5 | set -euo pipefail 6 | exec -- java -jar /opt/profiler-extension.jar -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/extension/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws/aws-lambda-java-libs/5a0f8ad9e9b8ff61ba626e71c4b5de62134e82e4/experimental/aws-lambda-java-profiler/extension/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/extension/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/extension/src/main/java/com/amazonaws/services/lambda/extension/Logger.java: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | package com.amazonaws.services.lambda.extension; 4 | 5 | public class Logger { 6 | 7 | private static final boolean IS_DEBUG_ENABLED = initializeDebugFlag(); 8 | private static final String PREFIX = "[PROFILER] "; 9 | 10 | private static boolean initializeDebugFlag() { 11 | String envValue = System.getenv("AWS_LAMBDA_PROFILER_DEBUG"); 12 | return "true".equalsIgnoreCase(envValue) || "1".equals(envValue); 13 | } 14 | 15 | public static void debug(String message) { 16 | if(IS_DEBUG_ENABLED) { 17 | System.out.println(PREFIX + message); 18 | } 19 | } 20 | 21 | public static void error(String message) { 22 | System.out.println(PREFIX + message); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/extension/src/main/java/com/amazonaws/services/lambda/extension/ShutdownHook.java: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: MIT-0 3 | package com.amazonaws.services.lambda.extension; 4 | 5 | import one.profiler.AsyncProfiler; 6 | 7 | public class ShutdownHook implements Runnable { 8 | 9 | private String stopCommand; 10 | 11 | public ShutdownHook(String stopCommand) { 12 | this.stopCommand = stopCommand; 13 | } 14 | 15 | @Override 16 | public void run() { 17 | Logger.debug("running ShutdownHook"); 18 | try { 19 | final String fileName = "/tmp/profiling-data-shutdown.html"; 20 | Logger.debug("stopping the profiler"); 21 | AsyncProfiler.getInstance().execute(String.format(this.stopCommand, fileName)); 22 | } catch (Exception e) { 23 | Logger.error("could not stop the profiler"); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/integration_tests/cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Set variables 4 | LAYER_ARN=$(cat /tmp/layer_arn) 5 | FUNCTION_NAME="aws-lambda-java-profiler-function-${GITHUB_RUN_ID}" 6 | ROLE_NAME="aws-lambda-java-profiler-role-${GITHUB_RUN_ID}" 7 | 8 | # Function to check if a command was successful 9 | check_success() { 10 | if [ $? -eq 0 ]; then 11 | echo "Success: $1" 12 | else 13 | echo "Error: Failed to $1" 14 | exit 1 15 | fi 16 | } 17 | 18 | # Delete Lambda Layer 19 | echo "Deleting Lambda Layer..." 20 | aws lambda delete-layer-version --layer-name $(echo $LAYER_ARN | cut -d: -f7) --version-number $(echo $LAYER_ARN | cut -d: -f8) 21 | check_success "delete Lambda Layer" 22 | 23 | # Delete Lambda Function 24 | echo "Deleting Lambda Function..." 25 | aws lambda delete-function --function-name $FUNCTION_NAME 26 | check_success "delete Lambda Function" 27 | 28 | # Delete IAM Role 29 | echo "Deleting IAM Role..." 30 | # First, detach all policies from the role 31 | for policy in $(aws iam list-attached-role-policies --role-name $ROLE_NAME --query 'AttachedPolicies[*].PolicyArn' --output text); do 32 | aws iam detach-role-policy --role-name $ROLE_NAME --policy-arn $policy 33 | check_success "detach policy $policy from role $ROLE_NAME" 34 | done 35 | 36 | # Remove s3 inline policy 37 | aws iam delete-role-policy --role-name $ROLE_NAME --policy-name "s3PutObject" 38 | check_success "deleted inline policy" 39 | 40 | 41 | # Then delete the role 42 | aws iam delete-role --role-name $ROLE_NAME 43 | check_success "delete IAM Role" 44 | 45 | echo "All deletions completed successfully." -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/integration_tests/create_bucket.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PROFILER_RESULTS_BUCKET_NAME="aws-lambda-java-profiler-bucket-${GITHUB_RUN_ID}" 4 | 5 | # Create the S3 bucket 6 | aws s3 mb s3://"$PROFILER_RESULTS_BUCKET_NAME" 7 | 8 | # Check if the bucket was created successfully 9 | if [ $? -eq 0 ]; then 10 | echo "Bucket '$PROFILER_RESULTS_BUCKET_NAME' created successfully." 11 | else 12 | echo "Error: Failed to create bucket '$PROFILER_RESULTS_BUCKET_NAME'." 13 | exit 1 14 | fi -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/integration_tests/download_from_s3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # S3 bucket name 4 | PROFILER_RESULTS_BUCKET_NAME="aws-lambda-java-profiler-bucket-${GITHUB_RUN_ID}" 5 | 6 | # Local directory to store downloaded files 7 | LOCAL_DIR="/tmp/s3-artifacts" 8 | 9 | # Create local directory if it doesn't exist 10 | mkdir -p "$LOCAL_DIR" 11 | 12 | # Download all files from the S3 bucket 13 | echo "Downloading all files from s3://$PROFILER_RESULTS_BUCKET_NAME to $LOCAL_DIR" 14 | aws s3 sync "s3://$PROFILER_RESULTS_BUCKET_NAME" "$LOCAL_DIR" 15 | 16 | 17 | 18 | # Check if the download was successful 19 | if [ $? -eq 0 ]; then 20 | echo "Download completed successfully." 21 | ls -lh $LOCAL_DIR 22 | else 23 | echo "Error occurred during download." 24 | exit 1 25 | fi 26 | 27 | # rename files as GitHub does not allow ":" in filenames 28 | for file in "$LOCAL_DIR"/*; do 29 | if [ -f "$file" ]; then 30 | dir=$(dirname "$file") 31 | filename=$(basename "$file") 32 | new_filename=$(echo "$filename" | tr -d ':') 33 | new_file="$dir/$new_filename" 34 | if [ "$filename" != "$new_filename" ]; then 35 | mv "$file" "$new_file" 36 | echo "Renamed: $filename -> $new_filename" 37 | else 38 | echo "No change: $filename" 39 | fi 40 | fi 41 | done 42 | 43 | echo "All files processed." -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/integration_tests/helloworld/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | repositories { 4 | mavenCentral() 5 | } 6 | 7 | sourceCompatibility = 21 8 | targetCompatibility = 21 9 | 10 | dependencies { 11 | implementation ( 12 | 'com.amazonaws:aws-lambda-java-core:1.2.3', 13 | 'com.amazonaws:aws-lambda-java-events:3.11.0', 14 | 'org.slf4j:slf4j-api:2.0.13' 15 | ) 16 | } 17 | 18 | task buildZip(type: Zip) { 19 | archiveBaseName = "code" 20 | from compileJava 21 | from processResources 22 | into('lib') { 23 | from configurations.runtimeClasspath 24 | } 25 | } 26 | 27 | build.dependsOn buildZip -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/integration_tests/helloworld/src/main/resources/wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # the path to the interpreter and all of the originally intended arguments 4 | args=("$@") 5 | 6 | # the extra options to pass to the interpreter 7 | echo "${args[@]}" 8 | 9 | # start the runtime with the extra options 10 | exec "${args[@]}" -------------------------------------------------------------------------------- /experimental/aws-lambda-java-profiler/integration_tests/publish_layer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Set variables 4 | LAYER_NAME="aws-lambda-java-profiler-test" 5 | DESCRIPTION="AWS Lambda Java Profiler Test Layer" 6 | ZIP_FILE="./extension/extension.zip" 7 | RUNTIME="java21" 8 | ARCHITECTURE="x86_64" 9 | 10 | # Check if AWS CLI is installed 11 | if ! command -v aws &> /dev/null; then 12 | echo "AWS CLI is not installed. Please install it first." 13 | exit 1 14 | fi 15 | 16 | # Check if the ZIP file exists 17 | if [ ! -f "$ZIP_FILE" ]; then 18 | echo "ZIP file $ZIP_FILE not found. Please make sure it exists." 19 | exit 1 20 | fi 21 | 22 | # Publish the layer 23 | echo "Publishing layer $LAYER_NAME..." 24 | RESPONSE=$(aws lambda publish-layer-version \ 25 | --layer-name "$LAYER_NAME" \ 26 | --description "$DESCRIPTION" \ 27 | --zip-file "fileb://$ZIP_FILE" \ 28 | --compatible-runtimes "$RUNTIME" \ 29 | --compatible-architectures "$ARCHITECTURE") 30 | 31 | # Check if the layer was published successfully 32 | if [ $? -eq 0 ]; then 33 | LAYER_VERSION=$(echo $RESPONSE | jq -r '.Version') 34 | LAYER_ARN=$(echo $RESPONSE | jq -r '.LayerVersionArn') 35 | echo "Layer published successfully!" 36 | echo "Layer Version: $LAYER_VERSION" 37 | echo "Layer ARN: $LAYER_ARN" 38 | echo $LAYER_ARN > /tmp/layer_arn 39 | else 40 | echo "Failed to publish layer. Please check your AWS credentials and permissions." 41 | exit 1 42 | fi -------------------------------------------------------------------------------- /git-config/hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # based on : https://hdpe.me/post/maven-checkstyle-pre-commit-hook/ 4 | # 5 | # DESCRIPTION 6 | # Considering only the staged .java files, it walks the filesystem tree 7 | # to look for any modules (it considers a module if it has a pom.xml file). 8 | # For each module found it runs Checkstyle on it. 9 | 10 | function get_module() { 11 | local path=$1; 12 | while true; do 13 | path=$(dirname $path); 14 | if [ -f "$path/pom.xml" ]; then 15 | echo "$path"; 16 | return; 17 | elif [[ "./" =~ "$path" ]]; then 18 | return; 19 | fi 20 | done 21 | } 22 | 23 | modules=(); 24 | 25 | for file in $(git diff --name-only --cached \*.java); do 26 | module=$(get_module "$file"); 27 | if [ "" != "$module" ] \ 28 | && [[ ! " ${modules[@]} " =~ " $module " ]]; then 29 | modules+=("$module"); 30 | fi 31 | done; 32 | 33 | if [ ${#modules[@]} -eq 0 ]; then 34 | exit; 35 | fi 36 | 37 | for dir in ${modules[@]}; do 38 | cd ${dir}; 39 | mvn checkstyle:check -Dcheckstyle.config.location=google_checks.xml -Dcheckstyle.consoleOutput=true; 40 | cd ..; 41 | done; 42 | -------------------------------------------------------------------------------- /samples/custom-serialization/.gitignore: -------------------------------------------------------------------------------- 1 | **/target/ 2 | **/HelloWorld.iml 3 | **/samconfig.toml 4 | **/dependency-reduced-pom.xml 5 | **/.aws-sam 6 | **/.gradle 7 | **/bin 8 | -------------------------------------------------------------------------------- /samples/custom-serialization/README.md: -------------------------------------------------------------------------------- 1 | The Lambda Java managed runtimes support custom serialization for JSON events. 2 | https://docs.aws.amazon.com/lambda/latest/dg/java-custom-serialization.html 3 | 4 | ## Sample projects 5 | In this repository you will find a number of sample projects from AWS to help you get started with the custom serialization feature. 6 | -------------------------------------------------------------------------------- /samples/custom-serialization/fastJson/HelloWorldFunction/src/main/java/helloworld/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package helloworld; 7 | 8 | import com.amazonaws.services.lambda.runtime.Context; 9 | import com.amazonaws.services.lambda.runtime.RequestHandler; 10 | import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; 11 | 12 | /** 13 | * Handler for requests to Lambda function. 14 | */ 15 | public class App implements RequestHandler { 16 | 17 | public APIGatewayProxyResponseEvent handleRequest(Vehicle vehicle, Context context) { 18 | System.out.println("input: " + vehicle); 19 | 20 | return new APIGatewayProxyResponseEvent().withStatusCode(200); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /samples/custom-serialization/fastJson/HelloWorldFunction/src/main/java/helloworld/Vehicle.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package helloworld; 7 | 8 | import com.alibaba.fastjson2.annotation.JSONField; 9 | 10 | public class Vehicle { 11 | 12 | @JSONField(name = "vehicle-type") 13 | private String vehicleType; 14 | 15 | @JSONField(name = "vehicleID") 16 | private String vehicleId; 17 | 18 | public Vehicle() { 19 | } 20 | 21 | public Vehicle(String vehicleType, String vehicleId) { 22 | this.vehicleType = vehicleType; 23 | this.vehicleId = vehicleId; 24 | } 25 | 26 | public String getVehicleType() { 27 | return vehicleType; 28 | } 29 | 30 | public void setVehicleType(String vehicleType) { 31 | this.vehicleType = vehicleType; 32 | } 33 | 34 | public String getVehicleId() { 35 | return vehicleId; 36 | } 37 | 38 | public void setVehicleId(String vehicleId) { 39 | this.vehicleId = vehicleId; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "Vehicle{" + 45 | "vehicleType='" + vehicleType + '\'' + 46 | ", vehicleId='" + vehicleId + '\'' + 47 | '}'; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /samples/custom-serialization/fastJson/HelloWorldFunction/src/main/resources/META-INF/services/com.amazonaws.services.lambda.runtime.CustomPojoSerializer: -------------------------------------------------------------------------------- 1 | com.example.vehicles.serialization.FastJsonSerializer -------------------------------------------------------------------------------- /samples/custom-serialization/fastJson/README.md: -------------------------------------------------------------------------------- 1 | Build and test commands 2 | 3 | ```bash 4 | sam build 5 | sam local invoke -e events/event.json 6 | ``` 7 | 8 | -------------------------------------------------------------------------------- /samples/custom-serialization/fastJson/events/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "vehicle-type": "car", 3 | "vehicleID": 123 4 | } -------------------------------------------------------------------------------- /samples/custom-serialization/gson/HelloWorldFunction/src/main/java/helloworld/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package helloworld; 7 | 8 | import com.amazonaws.services.lambda.runtime.Context; 9 | import com.amazonaws.services.lambda.runtime.RequestHandler; 10 | import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; 11 | 12 | /** 13 | * Handler for requests to Lambda function. 14 | */ 15 | public class App implements RequestHandler { 16 | 17 | public APIGatewayProxyResponseEvent handleRequest(Vehicle vehicle, Context context) { 18 | System.out.println("input: " + vehicle); 19 | 20 | return new APIGatewayProxyResponseEvent().withStatusCode(200); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /samples/custom-serialization/gson/HelloWorldFunction/src/main/java/helloworld/Vehicle.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package helloworld; 7 | 8 | import com.google.gson.annotations.SerializedName; 9 | 10 | public class Vehicle { 11 | 12 | @SerializedName("vehicle-type") 13 | private String vehicleType; 14 | 15 | @SerializedName("vehicleID") 16 | private String vehicleId; 17 | 18 | public Vehicle() { 19 | } 20 | 21 | public Vehicle(String vehicleType, String vehicleId) { 22 | this.vehicleType = vehicleType; 23 | this.vehicleId = vehicleId; 24 | } 25 | 26 | public String getVehicleType() { 27 | return vehicleType; 28 | } 29 | 30 | public void setVehicleType(String vehicleType) { 31 | this.vehicleType = vehicleType; 32 | } 33 | 34 | public String getVehicleId() { 35 | return vehicleId; 36 | } 37 | 38 | public void setVehicleId(String vehicleId) { 39 | this.vehicleId = vehicleId; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "Vehicle{" + 45 | "vehicleType='" + vehicleType + '\'' + 46 | ", vehicleId='" + vehicleId + '\'' + 47 | '}'; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /samples/custom-serialization/gson/HelloWorldFunction/src/main/resources/META-INF/services/com.amazonaws.services.lambda.runtime.CustomPojoSerializer: -------------------------------------------------------------------------------- 1 | com.example.vehicles.serialization.GsonSerializer -------------------------------------------------------------------------------- /samples/custom-serialization/gson/README.md: -------------------------------------------------------------------------------- 1 | Build and test commands 2 | 3 | ```bash 4 | sam build 5 | sam local invoke -e events/event.json 6 | ``` -------------------------------------------------------------------------------- /samples/custom-serialization/gson/events/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "vehicle-type": "car", 3 | "vehicleID": 123 4 | } -------------------------------------------------------------------------------- /samples/custom-serialization/jackson-jr/HelloWorldFunction/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | } 8 | 9 | dependencies { 10 | implementation 'com.amazonaws:aws-lambda-java-core:1.2.3' 11 | implementation 'com.amazonaws:aws-lambda-java-events:3.14.0' 12 | implementation 'com.fasterxml.jackson.jr:jackson-jr-objects:2.15.2' 13 | implementation 'com.fasterxml.jackson.jr:jackson-jr-annotation-support:2.15.2' 14 | implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.2' 15 | } 16 | 17 | sourceCompatibility = 21 18 | targetCompatibility = 21 19 | -------------------------------------------------------------------------------- /samples/custom-serialization/jackson-jr/HelloWorldFunction/src/main/java/helloworld/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package helloworld; 7 | 8 | import com.amazonaws.services.lambda.runtime.Context; 9 | import com.amazonaws.services.lambda.runtime.RequestHandler; 10 | import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; 11 | 12 | /** 13 | * Handler for requests to Lambda function. 14 | */ 15 | public class App implements RequestHandler { 16 | 17 | public APIGatewayProxyResponseEvent handleRequest(Vehicle vehicle, Context context) { 18 | System.out.println("input: " + vehicle); 19 | 20 | return new APIGatewayProxyResponseEvent().withStatusCode(200); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /samples/custom-serialization/jackson-jr/HelloWorldFunction/src/main/java/helloworld/Vehicle.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package helloworld; 7 | 8 | import com.fasterxml.jackson.annotation.JsonProperty; 9 | 10 | public class Vehicle { 11 | 12 | @JsonProperty("vehicle-type") 13 | private String vehicleType; 14 | 15 | @JsonProperty("vehicleID") 16 | private String vehicleId; 17 | 18 | public Vehicle() { 19 | } 20 | 21 | public Vehicle(String vehicleType, String vehicleId) { 22 | this.vehicleType = vehicleType; 23 | this.vehicleId = vehicleId; 24 | } 25 | 26 | public String getVehicleType() { 27 | return vehicleType; 28 | } 29 | 30 | public void setVehicleType(String vehicleType) { 31 | this.vehicleType = vehicleType; 32 | } 33 | 34 | public String getVehicleId() { 35 | return vehicleId; 36 | } 37 | 38 | public void setVehicleId(String vehicleId) { 39 | this.vehicleId = vehicleId; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "Vehicle{" + 45 | "vehicleType='" + vehicleType + '\'' + 46 | ", vehicleId='" + vehicleId + '\'' + 47 | '}'; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /samples/custom-serialization/jackson-jr/HelloWorldFunction/src/main/resources/META-INF/services/com.amazonaws.services.lambda.runtime.CustomPojoSerializer: -------------------------------------------------------------------------------- 1 | com.example.vehicles.serialization.JacksonJRSerializer -------------------------------------------------------------------------------- /samples/custom-serialization/jackson-jr/README.md: -------------------------------------------------------------------------------- 1 | Build and test commands 2 | 3 | ```bash 4 | sam build 5 | sam local invoke -e events/event.json 6 | ``` 7 | 8 | -------------------------------------------------------------------------------- /samples/custom-serialization/jackson-jr/events/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "vehicle-type": "car", 3 | "vehicleID": 123 4 | } -------------------------------------------------------------------------------- /samples/custom-serialization/moshi/HelloWorldFunction/src/main/java/helloworld/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package helloworld; 7 | 8 | import com.amazonaws.services.lambda.runtime.Context; 9 | import com.amazonaws.services.lambda.runtime.RequestHandler; 10 | import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; 11 | 12 | /** 13 | * Handler for requests to Lambda function. 14 | */ 15 | public class App implements RequestHandler { 16 | 17 | public APIGatewayProxyResponseEvent handleRequest(Vehicle vehicle, Context context) { 18 | System.out.println("input: " + vehicle); 19 | 20 | return new APIGatewayProxyResponseEvent().withStatusCode(200); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /samples/custom-serialization/moshi/HelloWorldFunction/src/main/java/helloworld/Vehicle.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package helloworld; 7 | 8 | import com.squareup.moshi.Json; 9 | 10 | public class Vehicle { 11 | 12 | @Json(name = "vehicle-type") 13 | private String vehicleType; 14 | 15 | @Json(name = "vehicleID") 16 | private String vehicleId; 17 | 18 | public Vehicle() { 19 | } 20 | 21 | public Vehicle(String vehicleType, String vehicleId) { 22 | this.vehicleType = vehicleType; 23 | this.vehicleId = vehicleId; 24 | } 25 | 26 | public String getVehicleType() { 27 | return vehicleType; 28 | } 29 | 30 | public void setVehicleType(String vehicleType) { 31 | this.vehicleType = vehicleType; 32 | } 33 | 34 | public String getVehicleId() { 35 | return vehicleId; 36 | } 37 | 38 | public void setVehicleId(String vehicleId) { 39 | this.vehicleId = vehicleId; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "Vehicle{" + 45 | "vehicleType='" + vehicleType + '\'' + 46 | ", vehicleId='" + vehicleId + '\'' + 47 | '}'; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /samples/custom-serialization/moshi/HelloWorldFunction/src/main/resources/META-INF/services/com.amazonaws.services.lambda.runtime.CustomPojoSerializer: -------------------------------------------------------------------------------- 1 | com.example.vehicles.serialization.MoshiSerializer -------------------------------------------------------------------------------- /samples/custom-serialization/moshi/README.md: -------------------------------------------------------------------------------- 1 | Build and test commands 2 | 3 | ```bash 4 | sam build 5 | sam local invoke -e events/event.json 6 | ``` 7 | 8 | -------------------------------------------------------------------------------- /samples/custom-serialization/moshi/events/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "vehicle-type": "car", 3 | "vehicleID": 123 4 | } -------------------------------------------------------------------------------- /samples/custom-serialization/request-stream-handler/HelloWorldFunction/src/main/java/helloworld/Vehicle.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package helloworld; 7 | 8 | import com.google.gson.annotations.SerializedName; 9 | 10 | public class Vehicle { 11 | 12 | @SerializedName("vehicle-type") 13 | private String vehicleType; 14 | 15 | @SerializedName("vehicleID") 16 | private String vehicleId; 17 | 18 | public Vehicle() { 19 | } 20 | 21 | public Vehicle(String vehicleType, String vehicleId) { 22 | this.vehicleType = vehicleType; 23 | this.vehicleId = vehicleId; 24 | } 25 | 26 | public String getVehicleType() { 27 | return vehicleType; 28 | } 29 | 30 | public void setVehicleType(String vehicleType) { 31 | this.vehicleType = vehicleType; 32 | } 33 | 34 | public String getVehicleId() { 35 | return vehicleId; 36 | } 37 | 38 | public void setVehicleId(String vehicleId) { 39 | this.vehicleId = vehicleId; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "Vehicle{" + 45 | "vehicleType='" + vehicleType + '\'' + 46 | ", vehicleId='" + vehicleId + '\'' + 47 | '}'; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /samples/custom-serialization/request-stream-handler/README.md: -------------------------------------------------------------------------------- 1 | Build and test commands 2 | 3 | ```bash 4 | sam build 5 | sam local invoke -e events/event.json 6 | ``` -------------------------------------------------------------------------------- /samples/custom-serialization/request-stream-handler/events/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "vehicle-type": "car", 3 | "vehicleID": 123 4 | } -------------------------------------------------------------------------------- /samples/kinesis-firehose-event-handler/src/test/java/example/KinesisFirehoseEventHandlerTest.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import com.amazonaws.services.lambda.runtime.Context; 4 | import com.amazonaws.services.lambda.runtime.events.KinesisAnalyticsInputPreprocessingResponse; 5 | import com.amazonaws.services.lambda.runtime.events.KinesisFirehoseEvent; 6 | import com.amazonaws.services.lambda.runtime.tests.annotations.Event; 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.params.ParameterizedTest; 9 | 10 | import static java.nio.charset.StandardCharsets.UTF_8; 11 | 12 | public class KinesisFirehoseEventHandlerTest { 13 | 14 | private Context context; // intentionally null as it's not used in the test 15 | 16 | @ParameterizedTest 17 | @Event(value = "event.json", type = KinesisFirehoseEvent.class) 18 | public void testEventHandler(KinesisFirehoseEvent event) { 19 | KinesisFirehoseEventHandler kinesisFirehoseEventHandler = new KinesisFirehoseEventHandler(); 20 | KinesisAnalyticsInputPreprocessingResponse response = kinesisFirehoseEventHandler.handleRequest(event, context); 21 | 22 | String expectedString = "\n!dlroW olleH"; 23 | KinesisAnalyticsInputPreprocessingResponse.Record firstRecord = response.getRecords().get(0); 24 | Assertions.assertEquals(expectedString, UTF_8.decode(firstRecord.getData()).toString()); 25 | Assertions.assertEquals(KinesisAnalyticsInputPreprocessingResponse.Result.Ok, firstRecord.getResult()); 26 | } 27 | } -------------------------------------------------------------------------------- /samples/kinesis-firehose-event-handler/src/test/resources/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "invocationId": "invoked123", 3 | "deliveryStreamArn": "aws:lambda:events", 4 | "region": "us-west-2", 5 | "records": [ 6 | { 7 | "data": "SGVsbG8gV29ybGQhCg==", 8 | "recordId": "record2", 9 | "approximateArrivalTimestamp": 1510772160000, 10 | "kinesisRecordMetadata": { 11 | "shardId": "shardId-000000000000", 12 | "partitionKey": "4d1ad2b9-24f8-4b9d-a088-76e9947c317a", 13 | "approximateArrivalTimestamp": "2012-04-23T18:25:43.511Z", 14 | "sequenceNumber": "49546986683135544286507457936321625675700192471156785154", 15 | "subsequenceNumber": "" 16 | } 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /samples/msk-firehose-event-handler/src/test/java/example/MSKFirehoseEventHandlerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package example; 7 | 8 | import com.amazonaws.services.lambda.runtime.Context; 9 | import com.amazonaws.services.lambda.runtime.tests.annotations.Event; 10 | import com.amazonaws.services.lambda.runtime.events.MSKFirehoseEvent; 11 | import com.amazonaws.services.lambda.runtime.events.MSKFirehoseResponse; 12 | import org.junit.jupiter.api.Assertions; 13 | import org.junit.jupiter.params.ParameterizedTest; 14 | 15 | import static java.nio.charset.StandardCharsets.UTF_8; 16 | 17 | public class MSKFirehoseEventHandlerTest { 18 | 19 | private Context context; // intentionally null as it's not used in the test 20 | 21 | @ParameterizedTest 22 | @Event(value = "event.json", type = MSKFirehoseEvent.class) 23 | public void testEventHandler(MSKFirehoseEvent event) { 24 | MSKFirehoseEventHandler Sample = new MSKFirehoseEventHandler(); 25 | MSKFirehoseResponse response = Sample.handleRequest(event, context); 26 | 27 | String expectedString = "{\"Name\":\"Hello World\"}"; 28 | MSKFirehoseResponse.Record firstRecord = response.getRecords().get(0); 29 | Assertions.assertEquals(expectedString, UTF_8.decode(firstRecord.getKafkaRecordValue()).toString()); 30 | Assertions.assertEquals(MSKFirehoseResponse.Result.Ok, firstRecord.getResult()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /samples/msk-firehose-event-handler/src/test/resources/event.json: -------------------------------------------------------------------------------- 1 | { 2 | "invocationId": "12345621-4787-0000-a418-36e56Example", 3 | "sourceMSKArn": "", 4 | "deliveryStreamArn": "", 5 | "region": "us-east-1", 6 | "records": [ 7 | { 8 | "recordId": "00000000000000000000000000000000000000000000000000000000000000", 9 | "approximateArrivalTimestamp": 1716369573887, 10 | "mskRecordMetadata": { 11 | "offset": "0", 12 | "partitionId": "1", 13 | "approximateArrivalTimestamp": 1716369573887 14 | }, 15 | "kafkaRecordValue": "eyJOYW1lIjoiSGVsbG8gV29ybGQifQ==" 16 | } 17 | ] 18 | } 19 | --------------------------------------------------------------------------------