Skip to content
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

Errors while compiling the Java examples of the latest version of the libraray #1475

Open
franckouam opened this issue Nov 15, 2024 · 3 comments

Comments

@franckouam
Copy link

franckouam commented Nov 15, 2024

Issue: Running Basic Example (BasicPutGetExample) in AWS Database Encryption SDK for DynamoDB

Description

I am trying to run the Java basic example BasicPutGetExample in the AWS Database Encryption SDK for DynamoDB to understand its initial functionality. My goal is to run the main without modifying or adding any existing operations.

Environment

  • Operating System: Kubuntu 22.04.5
  • Java: Oracle JDK 8
  • Gradle: Using the integrated Gradle wrapper (./gradlew)

Steps Followed

  1. Configured the project as indicated in this README

  2. Added the recommended dependencies. After that, the dependencies section in the file build.gradle.kts looks like this:

    dependencies {
        implementation("software.amazon.cryptography:aws-database-encryption-sdk-dynamodb:3.7.0")
        implementation("software.amazon.cryptography:aws-cryptographic-material-providers:1.7.0")

        implementation(platform("software.amazon.awssdk:bom:2.19.1"))
        implementation("software.amazon.awssdk:arns")
        implementation("software.amazon.awssdk:auth")
        implementation("software.amazon.awssdk:dynamodb")
        implementation("software.amazon.awssdk:dynamodb-enhanced")
        implementation("software.amazon.awssdk:kms")
        implementation("software.amazon.awssdk:sts")

        implementation("org.bouncycastle:bcprov-jdk18on:1.72")

        // https://mvnrepository.com/artifact/org.testng/testng
        testImplementation("org.testng:testng:7.5")


        implementation(platform("software.amazon.awssdk:bom:2.19.1"))
        implementation("software.amazon.awssdk:dynamodb")
        // The following are optional:
        implementation("software.amazon.awssdk:dynamodb-enhanced")
        implementation("software.amazon.awssdk:kms")
    }
  1. Installed the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files.
  2. Compiled using ./gradlew build.

Problem Encountered

After compilation, I have the errors below:

    > Task :compileJava FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':compileJava'.
    > Could not resolve all files for configuration ':compileClasspath'.
    > Could not find software.amazon.cryptography:aws-cryptographic-material-providers:1.7.2-SNAPSHOT.
        Searched in the following locations:
        - file:/home/ubuntu/.m2/repository/software/amazon/cryptography/aws-cryptographic-material-providers/1.7.2-SNAPSHOT/maven-metadata.xml
        - file:/home/ubuntu/.m2/repository/software/amazon/cryptography/aws-cryptographic-material-providers/1.7.2-SNAPSHOT/aws-cryptographic-material-providers-1.7.2-SNAPSHOT.pom
        - https://s3-us-west-2.amazonaws.com/dynamodb-local/release/software/amazon/cryptography/aws-cryptographic-material-providers/1.7.2-SNAPSHOT/maven-metadata.xml
        - https://s3-us-west-2.amazonaws.com/dynamodb-local/release/software/amazon/cryptography/aws-cryptographic-material-providers/1.7.2-SNAPSHOT/aws-cryptographic-material-providers-1.7.2-SNAPSHOT.pom
        - https://repo.maven.apache.org/maven2/software/amazon/cryptography/aws-cryptographic-material-providers/1.7.2-SNAPSHOT/maven-metadata.xml
        - https://repo.maven.apache.org/maven2/software/amazon/cryptography/aws-cryptographic-material-providers/1.7.2-SNAPSHOT/aws-cryptographic-material-providers-1.7.2-SNAPSHOT.pom
        Required by:
            project :
    > Could not find software.amazon.cryptography:aws-cryptographic-material-providers:1.7.2-SNAPSHOT.
        Searched in the following locations:
        - file:/home/ubuntu/.m2/repository/software/amazon/cryptography/aws-cryptographic-material-providers/1.7.2-SNAPSHOT/maven-metadata.xml
        - file:/home/ubuntu/.m2/repository/software/amazon/cryptography/aws-cryptographic-material-providers/1.7.2-SNAPSHOT/aws-cryptographic-material-providers-1.7.2-SNAPSHOT.pom
        - https://s3-us-west-2.amazonaws.com/dynamodb-local/release/software/amazon/cryptography/aws-cryptographic-material-providers/1.7.2-SNAPSHOT/maven-metadata.xml
        - https://s3-us-west-2.amazonaws.com/dynamodb-local/release/software/amazon/cryptography/aws-cryptographic-material-providers/1.7.2-SNAPSHOT/aws-cryptographic-material-providers-1.7.2-SNAPSHOT.pom
        - https://repo.maven.apache.org/maven2/software/amazon/cryptography/aws-cryptographic-material-providers/1.7.2-SNAPSHOT/maven-metadata.xml
        - https://repo.maven.apache.org/maven2/software/amazon/cryptography/aws-cryptographic-material-providers/1.7.2-SNAPSHOT/aws-cryptographic-material-providers-1.7.2-SNAPSHOT.pom
        Required by:
            project :

    * Try:
    > Run with --stacktrace option to get the stack trace.
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.

    * Get more help at https://help.gradle.org

    BUILD FAILED in 3s
    2 actionable tasks: 1 executed, 1 up-to-date

Question

Do you have any suggestions or specific steps to resolve this issue and successfully run the example? Any assistance or guidance on the required configurations would be greatly appreciated.

@josecorella
Copy link
Contributor

Hey @franckouam!

The build.gradle.kts is defined to work with our development cycle to ensure our examples remain up to date.

Are you trying to build the examples from source? Or are you trying to replicate an example in a sample project?
From your build.gradle.kts you have both

implementation("software.amazon.cryptography:aws-database-encryption-sdk-dynamodb:${ddbecVersion}")
implementation("software.amazon.cryptography:aws-cryptographic-material-providers:${mplVersion}")

and

implementation("software.amazon.cryptography:aws-database-encryption-sdk-dynamodb:3.1.2")
implementation("software.amazon.cryptography:aws-cryptographic-material-providers:1.0.0")

You should consolidate these duplicates to one. Ideally, you would depend on the latest publish versions.

For the AWS Database Encryption SDK for DynamoDB that is 3.7.0 and for the AWS Material Providers Library that is 1.7.0

@franckouam
Copy link
Author

franckouam commented Nov 18, 2024

Hey @josecorella!

Thanks for your answer. For the context i'm trying to build the examples from source. I updated the build.gradle.kts as you suggested.

implementation("software.amazon.cryptography:aws-database-encryption-sdk-dynamodb:3.7.0")
implementation("software.amazon.cryptography:aws-cryptographic-material-providers:1.7.0")

I still have errors while running ./gradlew build. It might be a problem with the execution of the test cases. I put the logs of the compilation down below.

I also saw that there are some AWS configuration string in the file TestUtils.java

package software.amazon.cryptography.examples;

public class TestUtils {

  public static final String TEST_KEYSTORE_NAME = "KeyStoreDdbTable";
  public static final String TEST_LOGICAL_KEYSTORE_NAME = "KeyStoreDdbTable";
  public static final String TEST_KEYSTORE_KMS_KEY_ID =
    "arn:aws:kms:us-west-2:370957321024:key/9d989aa2-2f9c-438c-a745-cc57d3ad0126";

  public static final String TEST_AWS_ACCOUNT_ID = "658956600833";
  public static final String TEST_AWS_REGION = "us-west-2";
  // These are public KMS Keys that MUST only be used for testing, and MUST NOT be used for any production data
  public static final String TEST_KMS_KEY_ID =
    "arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f";
  public static final String TEST_MRK_KEY_ID =
    "arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7";
  public static final String TEST_KMS_RSA_KEY_ID =
    "arn:aws:kms:us-west-2:658956600833:key/8b432da4-dde4-4bc3-a794-c7d68cbab5a6";
  public static final String TEST_MRK_REPLICA_KEY_ID_US_EAST_1 =
    "arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7";
  public static final String TEST_MRK_REPLICA_KEY_ID_EU_WEST_1 =
    "arn:aws:kms:eu-west-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7";

  // Our tests require access to DDB Table with this name
  public static final String TEST_DDB_TABLE_NAME =
    "DynamoDbEncryptionInterceptorTestTable";

Should I edit these configuration ?

Thanks again
build_log.txt

@josecorella
Copy link
Contributor

Hey @franckouam!

The errors you are getting are due to your assumed role while executing the tests not having access to our example resources. In this case the KMS Keys. You should be able to replace the TestUtils.java file with your own KMS keys and the examples should work,

Let us know if you run into any more issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants