Skip to content

Different behavior while using SSMProvider #758

Closed
@dmahapatro

Description

@dmahapatro

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions