updating parameter value in aws parameter store using Java

Viewed 251

I have a key stored as value in aws system manager(ssm). Is it possible to update the value using aws APIs?

For storing the key I am using the following API:

SsmClient ssmClientEUWest1 = SsmClient.builder().region(Region.EU_WEST_1).build();
ssmClientEUWest1.putParameter(PutParameterRequest.builder().value(key).name(<some constant name>).type("String").build());

As I store the key the first time it does create successfully. However as I call it again, it fails as <some constant name> is constant and hence it can't create duplicate names.

What I need is to update the key. I get this key as an input to my method and I just need to update the key in the store under the given constant name store.

I tried going through aws docs but couldn't find a solution. Docs suggest to use tier but that didn't prove useful either.

1 Answers

Explored more and found out this can be done by setting overwrite(true)

So

PutParameterRequest.builder().value(key).name(<some constant name>).type("String").overwrite(true).build()

will do the job

Related