-
Notifications
You must be signed in to change notification settings - Fork 90
docs: Adding CDK example #1321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
docs: Adding CDK example #1321
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
27ad36a
Move the current example, which is for SAM, under /sam directory
AlexeySoshin 1b4982c
Create a new directory for CDK
AlexeySoshin 537124a
Add CDK Example as a Maven module
AlexeySoshin b01f105
Merge branch 'main' into cdk-example
AlexeySoshin c915992
CDK Stack stub
AlexeySoshin 74c9f35
Restructure CDK application info Infra and App projects
AlexeySoshin 9bf23ea
Merge branch 'main' into cdk-example
scottgerring db09638
Define the build of the project inside the CDK stack
AlexeySoshin 2d12656
Merge remote-tracking branch 'origin/cdk-example' into cdk-example
AlexeySoshin 3e7091b
Use default account and region
AlexeySoshin c283f78
Merge branch 'main' into cdk-example
AlexeySoshin 7b7aef7
Add example of setting environment variables in CDK
AlexeySoshin 5fae08d
Remove threads from the examples, as this should be covered by docume…
AlexeySoshin 3ef58f7
Add general README for the project
AlexeySoshin 7c0278f
Add specific README for SAM
AlexeySoshin ff16cb5
Add specific README for CDK
AlexeySoshin eeeaa6d
Use Java11 syntax for CDK
AlexeySoshin 866a50d
Refactor the code for clarity
AlexeySoshin 20cd148
Fix imports
AlexeySoshin de3513a
Add outputs example
AlexeySoshin 781ecf5
Merge branch 'main' into cdk-example
AlexeySoshin 5218b86
Add test for the stack
AlexeySoshin 68da97c
Update examples/powertools-examples-core/README.md
AlexeySoshin 2dbb190
Update examples/powertools-examples-core/cdk/README.md
AlexeySoshin 3f76c04
Remove unnecessary .gitignore
AlexeySoshin 103e1ba
Merge branch 'cdk-example' of https://github.com/AlexeySoshin/powerto…
AlexeySoshin 64f3671
Mixed log level and sample rate
AlexeySoshin a9a3509
Combine .gitignore files
AlexeySoshin 9a40117
Remove `cdk ls`, since there's just a single stack
AlexeySoshin 65fb19c
Remove SAM mentions from the CDK readme
AlexeySoshin f9215a4
Replace "architecture" with "tool" while talking about SAM/CDK
AlexeySoshin a4f6043
Update examples/powertools-examples-core/README.md
AlexeySoshin 0405ce5
Update examples/powertools-examples-core/README.md
AlexeySoshin 24a96fc
Merge branch 'main' of https://github.com/aws-powertools/powertools-l…
AlexeySoshin 686448a
Reformat imports
AlexeySoshin 89c21ee
Don't include version number in the HelloWorld jar
AlexeySoshin 06f8c51
Update examples/powertools-examples-core/cdk/infra/src/main/java/cdk/…
AlexeySoshin 97755b8
Add Streaming example as well
AlexeySoshin 6872c9f
Merge remote-tracking branch 'origin/cdk-example' into cdk-example
AlexeySoshin 3fb78d7
Update examples/powertools-examples-core/README.md
AlexeySoshin 8f9e7fe
Update examples/.gitignore
AlexeySoshin 1fd7c4e
Update examples/.gitignore
AlexeySoshin f44db14
Update examples/powertools-examples-core/README.md
AlexeySoshin da4558c
Update examples/powertools-examples-core/cdk/README.md
AlexeySoshin 8c93da8
Update examples/powertools-examples-core/sam/README.md
AlexeySoshin e33536e
Exclude examples from duplicate code scan
AlexeySoshin b580931
Fix broken link to the events file
AlexeySoshin 10ad54d
Trim cdk.json
AlexeySoshin 8c50227
Trim cdk.json
AlexeySoshin d6ecd32
Merge
AlexeySoshin fd3e345
Merge
AlexeySoshin 7a5cbc7
Merge branch 'main' of https://github.com/aws-powertools/powertools-l…
AlexeySoshin fdfb168
Downgrade code to Java 8
AlexeySoshin 578c800
Merge branch 'main' into cdk-example
scottgerring 6e0b9fe
Correct README to point to powertools-core-idempotency for a quick start
AlexeySoshin 71a47dc
Add the missing license to the new Java files
AlexeySoshin f078eea
Reformat code
AlexeySoshin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
dependency-reduced-pom.xml | ||
.aws-sam | ||
cdk.out | ||
.m2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Powertools for AWS Lambda (Java) - Core Utilities Example with CDK | ||
|
||
This project demonstrates the Lambda for Powertools Java module deployed using [Cloud Development Kit](https://aws.amazon.com/cdk/). | ||
|
||
For general information on the deployed example itself, you can refer to the parent [README](../README.md) | ||
|
||
## Configuration | ||
CDK uses the following project structure: | ||
- [app](./app) - stores the source code of your application, which is similar between all examples | ||
- [infra](./infra) - stores the definition of your infrastructure | ||
- [cdk.json](./infra/cdk.json) - tells the CDK Toolkit how to execute your app | ||
- [CdkApp](./infra/src/main/java/cdk/CdkApp.java) - bootstraps your stack, taking AWS `account` and `region` as input | ||
- [CdkStack](./infra/src/main/java/cdk/CdkStack.java) - defines the Lambda function to be deployed as well as API Gateway for it. | ||
|
||
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. | ||
AlexeySoshin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
## Deploy the sample application | ||
|
||
The minimum to deploy the app should be | ||
```bash | ||
cdk deploy | ||
``` | ||
|
||
If you're running CDK for the first time, you'll need to first run the bootstrap command: | ||
```bash | ||
cdk bootstrap | ||
``` | ||
|
||
## Useful commands | ||
|
||
* `mvn package` compile and run tests | ||
* `cdk synth` emits the synthesized CloudFormation template | ||
* `cdk deploy` deploy this stack to your default AWS account/region | ||
* `cdk diff` compare deployed stack with current state | ||
* `cdk docs` open CDK documentation |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
AlexeySoshin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<groupId>software.amazon.lambda.examples</groupId> | ||
<version>1.16.1</version> | ||
<artifactId>powertools-examples-core-cdk</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Powertools for AWS Lambda (Java) library Examples - Core</name> | ||
|
||
<properties> | ||
<log4j.version>2.20.0</log4j.version> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.deploy.skip>true</maven.deploy.skip> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>software.amazon.lambda</groupId> | ||
<artifactId>powertools-tracing</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>software.amazon.lambda</groupId> | ||
<artifactId>powertools-logging</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>software.amazon.lambda</groupId> | ||
<artifactId>powertools-metrics</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-lambda-java-core</artifactId> | ||
<version>1.2.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-lambda-java-events</artifactId> | ||
<version>3.11.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
<version>${log4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-api</artifactId> | ||
<version>${log4j.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>helloworld-lambda</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>dev.aspectj</groupId> | ||
<artifactId>aspectj-maven-plugin</artifactId> | ||
<version>1.13.1</version> | ||
<configuration> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
<complianceLevel>${maven.compiler.target}</complianceLevel> | ||
<aspectLibraries> | ||
<aspectLibrary> | ||
<groupId>software.amazon.lambda</groupId> | ||
<artifactId>powertools-tracing</artifactId> | ||
</aspectLibrary> | ||
<aspectLibrary> | ||
<groupId>software.amazon.lambda</groupId> | ||
<artifactId>powertools-logging</artifactId> | ||
</aspectLibrary> | ||
<aspectLibrary> | ||
<groupId>software.amazon.lambda</groupId> | ||
<artifactId>powertools-metrics</artifactId> | ||
</aspectLibrary> | ||
</aspectLibraries> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.5.0</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<transformers> | ||
<transformer | ||
implementation="com.github.edwgiz.maven_shade_plugin.log4j2_cache_transformer.PluginsCacheFileTransformer"> | ||
</transformer> | ||
</transformers> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.github.edwgiz</groupId> | ||
<artifactId>maven-shade-plugin.log4j2-cachefile-transformer</artifactId> | ||
<version>2.15</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<profiles> | ||
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class | ||
version mismatch issues. All subsequent Java releases build with the default AspectJ configuration | ||
on the project. | ||
|
||
Note: | ||
- if you are running Java > 1.8, you can remove this profile altogether | ||
- If you are running on Java 1.8, you should apply the aspectJ version here to the project, and remove | ||
the profile. | ||
--> | ||
<profile> | ||
<id>jdk8</id> | ||
<activation> | ||
<jdk>(,11)</jdk> <!-- 8 --> | ||
</activation> | ||
<properties> | ||
<aspectj.version>1.9.7</aspectj.version> | ||
</properties> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.aspectj</groupId> | ||
<artifactId>aspectjtools</artifactId> | ||
<version>${aspectj.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>dev.aspectj</groupId> | ||
<artifactId>aspectj-maven-plugin</artifactId> | ||
<version>${aspectj.plugin.version}</version> | ||
<configuration> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
<complianceLevel>${maven.compiler.target}</complianceLevel> | ||
<aspectLibraries> | ||
<aspectLibrary> | ||
<groupId>software.amazon.lambda</groupId> | ||
<artifactId>powertools-tracing</artifactId> | ||
</aspectLibrary> | ||
<aspectLibrary> | ||
<groupId>software.amazon.lambda</groupId> | ||
<artifactId>powertools-logging</artifactId> | ||
</aspectLibrary> | ||
<aspectLibrary> | ||
<groupId>software.amazon.lambda</groupId> | ||
<artifactId>powertools-metrics</artifactId> | ||
</aspectLibrary> | ||
</aspectLibraries> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>compile</goal> | ||
<goal>test-compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<!-- Enforce aspectJ 1.9.7 --> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.aspectj</groupId> | ||
<artifactId>aspectjtools</artifactId> | ||
<version>${aspectj.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.