John clarkson
John clarkson

Reputation: 33

Is it possible to update a parameter in AWS SSM parameter store from an SSM Command?

As per a requirement, we want to store a parameter in SSM parameter store, and one should be able to update the parameter value through an SSM command.

From the initial research it is understood that we can run the SSM commands on Target EC2 instances. However not able to find a way to run the command with target as Parameter store. Please help.

Upvotes: 3

Views: 13572

Answers (2)

valdeci
valdeci

Reputation: 15237

To update a parameter simply use the put-parameter method again with the --overwrite option. You do not need other options or set the type.

aws ssm put-parameter --name "my-param" --value "NewValue" --overwrite

The result will be something like this:

{
  "Version": 2,
  "Tier": "Standard"
}

Upvotes: 1

Adam Malik
Adam Malik

Reputation: 413

To read values to or from ssm parameter store you can use the aws cli. For that to work you need to set it up:

https://docs.aws.amazon.com/de_de/cli/latest/userguide/install-cliv2.html

You will need to create an aws access key and an aws secret key, if you not already have that.

After you have configured your aws cli like that:

$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: eu-central-1
Default output format [None]: json

You should be able to execute this command to check if it works:

$ aws sts get-caller-identity

To store a value in ssm this command will work:

$ aws ssm put-parameter --name "test123" --type "String" --value "MyValue"
{
  "Version": 1,
  "Tier": "Standard"
}

To overwrite a value in ssm this command will work:

$ aws ssm put-parameter --name "test123" --type "String" --value "MyValue" --overwrite
{
  "Version": 2,
  "Tier": "Standard"
}

To read that parameter from ssm use this:

$ aws ssm get-parameter --name "test123" --query Parameter.Value
"MyValue"

Upvotes: 7

Related Questions