Skip to content

Commit

Permalink
chore(deps): Update Java, Kotlin and AWS dependencies (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
elevesque-nexapp authored Nov 8, 2024
1 parent 4021403 commit 8efe88a
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 67 deletions.
34 changes: 20 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ on:
pull_request:
branches: [ master ]

env:
JAVA_VERSION: 11

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 1.8
- uses: actions/cache@v1
java-version: ${{ env.JAVA_VERSION }}
distribution: "corretto"
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
Expand All @@ -28,11 +32,12 @@ jobs:
needs: [build]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 1.8
- uses: actions/cache@v1
java-version: ${{ env.JAVA_VERSION }}
distribution: "corretto"
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
Expand All @@ -46,18 +51,19 @@ jobs:
needs: [build]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 1.8
- uses: actions/cache@v1
java-version: ${{ env.JAVA_VERSION }}
distribution: "corretto"
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -68,7 +74,7 @@ jobs:
- name: Tests
run: make test coverage

- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: target/site/jacoco-aggregate/jacoco.xml
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Nexapp Libraries for Kotlin

## Requirements
* Java 8
* Java 11
* Maven 3.5+
* GNU Make

Expand Down
20 changes: 14 additions & 6 deletions nexapp-aws-lambda/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>nexapp-kore</artifactId>
<groupId>ca.nexapp</groupId>
<version>2.0.3</version>
<version>2.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -35,23 +35,23 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.2.1</version>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.11.0</version>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-log4j2</artifactId>
<version>1.3.0</version>
<version>1.6.0</version>
</dependency>

<!-- AWS SDK -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-ssm</artifactId>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ssm</artifactId>
</dependency>

<dependency>
Expand All @@ -77,6 +77,14 @@
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

<!-- Tests -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sso</artifactId>
<version>2.29.7</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package ca.nexapp.lambdas.contexts.env

import ca.nexapp.logging.Logging
import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement
import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagementClientBuilder
import software.amazon.awssdk.services.ssm.SsmClient

/**
* Creates the default EnvLoader which fallbacks to SSM if not found in local environment variables
*/
class LambdaEnvLoaderFactory(
private val ssmPath: String? = System.getenv("SSM_PATH"),
private val ssm: AWSSimpleSystemsManagement = AWSSimpleSystemsManagementClientBuilder.defaultClient()
private val ssm: SsmClient = SsmClient.create()
) {

companion object : Logging
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ca.nexapp.lambdas.contexts.env

import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement
import com.amazonaws.services.simplesystemsmanagement.model.AWSSimpleSystemsManagementException
import com.amazonaws.services.simplesystemsmanagement.model.GetParameterRequest
import software.amazon.awssdk.services.ssm.SsmClient
import software.amazon.awssdk.services.ssm.model.GetParameterRequest
import software.amazon.awssdk.services.ssm.model.SsmException

/**
* Loads and decrypts variables from SSM Parameter Store Path
Expand All @@ -13,22 +13,20 @@ import com.amazonaws.services.simplesystemsmanagement.model.GetParameterRequest
*/
class SsmEnvLoader(
private val ssmPath: String,
private val ssm: AWSSimpleSystemsManagement
private val ssm: SsmClient
) : LambdaEnvLoader {

override fun load(env: String): String {
with(GetParameterRequest()) {
name = "$ssmPath/$env"
withDecryption = true

return load(env, this)
}
}
override fun load(env: String) = GetParameterRequest
.builder()
.name("$ssmPath/$env")
.withDecryption(true)
.build()
.let { load(env, it) }

private fun load(env: String, request: GetParameterRequest): String {
return try {
ssm.getParameter(request).parameter.value
} catch (error: AWSSimpleSystemsManagementException) {
ssm.getParameter(request).parameter().value()
} catch (error: SsmException) {
throw CouldNotLoadEnvException(env, error)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
package ca.nexapp.lambdas.contexts.env

import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagementClientBuilder
import com.amazonaws.services.simplesystemsmanagement.model.DeleteParametersRequest
import com.amazonaws.services.simplesystemsmanagement.model.GetParametersByPathRequest
import com.amazonaws.services.simplesystemsmanagement.model.ParameterType
import com.amazonaws.services.simplesystemsmanagement.model.PutParameterRequest
import org.junit.jupiter.api.extension.AfterAllCallback
import org.junit.jupiter.api.extension.ExtensionContext
import software.amazon.awssdk.services.ssm.SsmClient
import software.amazon.awssdk.services.ssm.model.DeleteParametersRequest
import software.amazon.awssdk.services.ssm.model.GetParametersByPathRequest
import software.amazon.awssdk.services.ssm.model.ParameterType
import software.amazon.awssdk.services.ssm.model.PutParameterRequest
import java.util.UUID

class SsmPathExtension : AfterAllCallback {

val ssm = AWSSimpleSystemsManagementClientBuilder.defaultClient()!!
val ssm: SsmClient = SsmClient.create()
val ssmPath by lazy { "/lambda4j-test-${UUID.randomUUID()}" }

fun add(name: String, value: String, encrypted: Boolean = false) {
with(PutParameterRequest().withName("$ssmPath/$name").withValue(value)) {
type = when (encrypted) {
true -> ParameterType.SecureString.toString()
false -> ParameterType.String.toString()
}

ssm.putParameter(this)
}
PutParameterRequest
.builder()
.name("$ssmPath/$name")
.value(value)
.type(if (encrypted) ParameterType.SECURE_STRING else ParameterType.STRING)
.build()
.also { ssm.putParameter(it) }
}

override fun afterAll(ctx: ExtensionContext?) {
val parameters = ssm.getParametersByPath(GetParametersByPathRequest().withPath(ssmPath))
.parameters.map { p -> p.name }
val parameters = GetParametersByPathRequest
.builder()
.path(ssmPath)
.build()
.let { ssm.getParametersByPath(it) }
.parameters()
.map { p -> p.name() }

if (parameters.isEmpty()) {
return
}

ssm.deleteParameters(DeleteParametersRequest().withNames(parameters))
ssm.deleteParameters(DeleteParametersRequest.builder().names(parameters).build())
}
}
2 changes: 1 addition & 1 deletion nexapp-kore-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>nexapp-kore</artifactId>
<groupId>ca.nexapp</groupId>
<version>2.0.3</version>
<version>2.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion nexapp-kore-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>nexapp-kore</artifactId>
<groupId>ca.nexapp</groupId>
<version>2.0.3</version>
<version>2.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions nexapp-tracing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<parent>
<artifactId>nexapp-kore</artifactId>
<groupId>ca.nexapp</groupId>
<version>2.0.3</version>
<version>2.1.0</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>nexapp-tracing</artifactId>
<packaging>jar</packaging>

<properties>
<aws.xray.version>2.4.0</aws.xray.version>
<aws.xray.version>2.18.2</aws.xray.version>
</properties>

<dependencyManagement>
Expand Down
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ca.nexapp</groupId>
<artifactId>nexapp-kore</artifactId>
<version>2.0.3</version>
<version>2.1.0</version>
<packaging>pom</packaging>

<name>Nexapp Kore</name>
Expand Down Expand Up @@ -43,18 +43,18 @@
</modules>

<properties>
<java.version>1.8</java.version>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.release.version>2.5.3</maven.release.version>

<kotlin.version>1.7.0</kotlin.version>
<kotlin.version>2.0.21</kotlin.version>
<kotlin.code.style>official</kotlin.code.style>
<junit.version>5.9.1</junit.version>

<jackson.version>2.13.4</jackson.version>
<aws.sdk.version>1.12.315</aws.sdk.version>
<jackson.version>2.18.1</jackson.version>
<aws.sdk.version>2.29.7</aws.sdk.version>
<sentry.version>6.4.2</sentry.version>
<slf4j.version>1.7.32</slf4j.version>
<log4j2.version>2.19.0</log4j2.version>
Expand All @@ -63,16 +63,16 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>${aws.sdk.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>2.10.1</version>
<version>${jackson.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down

0 comments on commit 8efe88a

Please sign in to comment.