Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read and modify the SSM parameter with python boto3

Tags:

boto3

ssm

i am trying to develop a code where i can access and then modify and update the SSM parameter value .

Anyone , could you let me know how can this be achieved with boto3

like image 995
Sumanth Shetty Avatar asked Apr 19 '26 20:04

Sumanth Shetty


2 Answers

we can achieve modification by the following:

response = ssm.put_parameter(
    Name='field_name',
    Value='new_value',
    Type='Type',
    Overwrite=True,
)

we can achieve read by the following

response = ssm.get_parameters(
    Names=[
       'feild_name',
    ],
)
print(response['Parameters'][0]['Value'])
like image 100
Sumanth Shetty Avatar answered Apr 24 '26 05:04

Sumanth Shetty


You can read and write an already created parameter with this code:

import boto3

ssm_client = boto3.client("ssm")

def get_parameter(name):
    parameter = ssm_client.get_parameter(Name=name)
    return parameter["Parameter"]["Value"]

def update_parameter(name, value):
    ssm_client.put_parameter(
        Name=name,
        Overwrite=True,
        Value=value,
    )

You can read the full documentation here

like image 30
Martin Forte Avatar answered Apr 24 '26 05:04

Martin Forte