Skip to content

Request for information regarding ConfigSource and SsmClient #1889

@argenstijn

Description

@argenstijn

The idea is to build an extension (ConfigSource) to read configuration from SSM parameter store.

My question is, what is the best way to create the SSM client. As we are in the configuration phase of an application i cannot (should not) inject the ssm client.

For example. I could create the ssm client myself reusing the AwsConfig aws() like below

@ConfigMapping(prefix = "test.amazon-ssm-config")
@ConfigRoot(phase = ConfigPhase.RUN_TIME)
public interface AmazonSSMConfig {
     
    AwsConfig aws();
    ......
    

and then create the ssmClient.

` private SsmClient createSsmClient() {
var awsConfig = this.config.aws();
var builder = SsmClient.builder();

if (awsConfig.credentials().isPresent()) {
  var providerCfg = awsConfig.credentials().get();
  builder.credentialsProvider(
      providerCfg.type().create(providerCfg, "iapi.amazon-ssm-config.aws"));

}
awsConfig.region().ifPresent(builder::region);
return builder.build();
}`

But maybe you have suggestions on how to do this a better way and i would really like to hear them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions