Skip to content

Different behavior while using SSMProvider #758

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

Closed
dmahapatro opened this issue Feb 17, 2022 · 3 comments
Closed

Different behavior while using SSMProvider #758

dmahapatro opened this issue Feb 17, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@dmahapatro
Copy link
Contributor

dmahapatro commented Feb 17, 2022

I have stored /DEV/APP/CLIENT/KEYSTORE/PASSWORD and /DEV/APP/CLIENT/TRUSTSTORE/PASSWORD in SSM Param Store, with secure strings as value.

I am retrieving them in Lambda function as:

Map<String, String> values = ssmProvider.recursive().withDecryption().getMultiple("/DEV/APP/CLIENT/");
String keyStorePassword = values.get("KEYSTORE/PASSWORD");
String trustStorePassword = values.get("TRUSTSTORE/PASSWORD");

Expected Behavior

The expected behavior is that the keys as shown above KEYSTORE/PASSWORD and TRUSTSTORE/PASSWORD should be present

Current Behavior

While debugging, I found the keys to be as KEYSTOREPASSWORD and TRUSTSTOREPASSWORD.
However, if I remove the appending / from the path and use /DEV/APP/CLIENT :

ssmProvider.recursive().withDecryption().getMultiple("/DEV/APP/CLIENT")

I get the expected results

Steps to Reproduce (for bugs)

Just ran a Test class with a main method inside a Maven project:

import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.ssm.SsmClient;
import software.amazon.lambda.powertools.parameters.ParamManager;
import software.amazon.lambda.powertools.parameters.SSMProvider;

import java.util.Map;

public class Test {
  private static final SsmClient ssmClient = SsmClient.builder()
    .region(Region.US_EAST_2)
    .build();
  private static final SSMProvider ssmProvider = ParamManager.getSsmProvider(ssmClient);

  public static void main(String[] args) {
    Map<String, String> values = ssmProvider.recursive().withDecryption().getMultiple("/DEV/APP/CLIENT/");
    String keyStorePassword = values.get("KEYSTORE/PASSWORD");
    String trustStorePassword = values.get("TRUSTSTORE/PASSWORD");

    System.out.println(keyStorePassword);
    System.out.println(trustStorePassword);
  }
}

Environment

  • Powertools version used: 1.11.0
  • Packaging format (Layers, Maven/Gradle): Maven
  • AWS Lambda function runtime: Java 11
  • Debugging logs : Received NPE because of null value after get() operation on Map
@dmahapatro dmahapatro added the bug Something isn't working label Feb 17, 2022
@pankajagrawal16
Copy link
Contributor

@jeromevdl Would you have some bandwidth to look into this issue ? Look like a bug to me.

@jeromevdl
Copy link
Contributor

Thanks @dmahapatro for this issue.

I think it's an issue in the Java SDK because we're just using the standard builder:

GetParametersByPathRequest request = GetParametersByPathRequest.builder().path(path)...

Using the AWS CLI, both with and without trailing slash work, but not with the Java SDK. We can probably remove the trailing slash if there is one.

jeromevdl added a commit to jeromevdl/aws-lambda-powertools-java that referenced this issue Feb 17, 2022
remove trailing slash for multiple params
@jeromevdl jeromevdl mentioned this issue Feb 17, 2022
6 tasks
jeromevdl added a commit to jeromevdl/aws-lambda-powertools-java that referenced this issue Feb 18, 2022
remove trailing slash for multiple params
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2022

This is now released under 1.12.0 version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants