Skip to content

Commit a64418e

Browse files
committed
chore: update v2 (#1409)
1 parent 85d79e5 commit a64418e

File tree

14 files changed

+729
-1
lines changed

14 files changed

+729
-1
lines changed

examples/powertools-examples-core-utilities/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ We also provide an example showing the integration of SAM, Powertools, and Gradl
1515

1616
* [AWS SAM with a Gradle build](gradle/)
1717

18+
We also provide an example showing the integration of SAM, Powertools, and Gradle:
19+
20+
* [AWS SAM with a Gradle build](../powertools-examples-core-utilities/gradle/)
21+
1822
For each of the tools, the example application is the same, and consists of the following files:
1923

2024
- [App.java](sam/src/main/java/helloworld/App.java) - Code for the application's Lambda function.

examples/powertools-examples-core-utilities/cdk/infra/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>software.amazon.lambda.examples</groupId>
66
<artifactId>cdk</artifactId>
7-
<version>1.18.0-SNAPSHOT</version>
7+
<version>2.0.0-SNAPSHOT</version>
88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1010
<cdk.version>2.100.0</cdk.version>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Powertools for AWS Lambda (Java) - Core Utilities Example with Gradle
2+
3+
This project demonstrates the Lambda for Powertools Java module deployed using [Serverless Application Model](https://aws.amazon.com/serverless/sam/) with
4+
[Gradle](https://gradle.org/) running the build. This example is configured for Java 1.8 only; in order to use a newer version, check out the Gradle
5+
configuration guide [in the main project README](../../../README.md).
6+
7+
You can also use `sam init` to create a new Gradle-powered Powertools application - choose to use the **AWS Quick Start Templates**,
8+
and then **Hello World Example with Powertools for AWS Lambda**, **Java 17** runtime, and finally **gradle**.
9+
10+
11+
For general information on the deployed example itself, you can refer to the parent [README](../../powertools-examples-core/README.md)
12+
13+
## Configuration
14+
SAM uses [template.yaml](template.yaml) to define the application's AWS resources.
15+
This file defines the Lambda function to be deployed as well as API Gateway for it.
16+
17+
The build of the project is managed by Gradle, and configured in [build.gradle](build.gradle).
18+
19+
## Deploy the sample application
20+
To get started, you can use the Gradle wrapper to bootstrap Gradle and run the build:
21+
22+
```bash
23+
./gradlew build
24+
```
25+
26+
Once this is done to deploy the example, check out the instructions for getting started with SAM in
27+
[the examples directory](../../README.md)
28+
29+
## Additional notes
30+
31+
You can watch the trace information or log information using the SAM CLI:
32+
```bash
33+
# Tail the logs
34+
sam logs --tail $MY_STACK
35+
36+
# Tail the traces
37+
sam traces --tail
38+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
plugins {
3+
id 'java'
4+
id "io.freefair.aspectj.post-compile-weaving" version "6.6.3"
5+
}
6+
7+
wrapper {
8+
gradleVersion = "7.6.1"
9+
}
10+
11+
compileJava {
12+
sourceCompatibility = "1.8"
13+
targetCompatibility = "1.8"
14+
15+
ajc {
16+
enabled = true
17+
}
18+
}
19+
20+
repositories {
21+
mavenCentral()
22+
}
23+
24+
dependencies {
25+
implementation 'com.amazonaws:aws-lambda-java-core:1.2.2'
26+
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.2'
27+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.2.2'
28+
implementation 'com.amazonaws:aws-lambda-java-events:3.11.0'
29+
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.2'
30+
aspect 'software.amazon.lambda:powertools-tracing:1.17.0'
31+
aspect 'software.amazon.lambda:powertools-logging:1.17.0'
32+
aspect 'software.amazon.lambda:powertools-metrics:1.17.0'
33+
testImplementation 'junit:junit:4.13.2'
34+
}
35+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"body": "{\"message\": \"hello world\"}",
3+
"resource": "/{proxy+}",
4+
"path": "/path/to/resource",
5+
"httpMethod": "POST",
6+
"isBase64Encoded": false,
7+
"queryStringParameters": {
8+
"foo": "bar"
9+
},
10+
"pathParameters": {
11+
"proxy": "/path/to/resource"
12+
},
13+
"stageVariables": {
14+
"baz": "qux"
15+
},
16+
"headers": {
17+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
18+
"Accept-Encoding": "gzip, deflate, sdch",
19+
"Accept-Language": "en-US,en;q=0.8",
20+
"Cache-Control": "max-age=0",
21+
"CloudFront-Forwarded-Proto": "https",
22+
"CloudFront-Is-Desktop-Viewer": "true",
23+
"CloudFront-Is-Mobile-Viewer": "false",
24+
"CloudFront-Is-SmartTV-Viewer": "false",
25+
"CloudFront-Is-Tablet-Viewer": "false",
26+
"CloudFront-Viewer-Country": "US",
27+
"Host": "1234567890.execute-api.us-east-1.amazonaws.com",
28+
"Upgrade-Insecure-Requests": "1",
29+
"User-Agent": "Custom User Agent String",
30+
"Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)",
31+
"X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==",
32+
"X-Forwarded-For": "127.0.0.1, 127.0.0.2",
33+
"X-Forwarded-Port": "443",
34+
"X-Forwarded-Proto": "https"
35+
},
36+
"requestContext": {
37+
"accountId": "123456789012",
38+
"resourceId": "123456",
39+
"stage": "prod",
40+
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
41+
"requestTime": "09/Apr/2015:12:34:56 +0000",
42+
"requestTimeEpoch": 1428582896000,
43+
"identity": {
44+
"cognitoIdentityPoolId": null,
45+
"accountId": null,
46+
"cognitoIdentityId": null,
47+
"caller": null,
48+
"accessKey": null,
49+
"sourceIp": "127.0.0.1",
50+
"cognitoAuthenticationType": null,
51+
"cognitoAuthenticationProvider": null,
52+
"userArn": null,
53+
"userAgent": "Custom User Agent String",
54+
"user": null
55+
},
56+
"path": "/prod/path/to/resource",
57+
"resourcePath": "/{proxy+}",
58+
"httpMethod": "POST",
59+
"apiId": "1234567890",
60+
"protocol": "HTTP/1.1"
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!gradle-wrapper.jar
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)