Reputation: 103
I have a Lambda function that would like to read the value of the LATEST version of the parameter and the value of the version preceding it from the AWS Systems Manager Parameter Store.
Example: If parameter version 99 is the LATEST version, the Lambda wants to retrieve the value of the 99th version and 98th version of the same parameter.
This document suggests that AWS Systems Manager Parameter Store stores the 100 latest versions that can access the LATEST version of the parameter or a specified version of the parameter. Is there a way for the Lambda to know the version number of the LATEST parameter so the parameter version preceding it can be accessed?
Thanks!
Upvotes: 1
Views: 1173
Reputation: 2295
You can get the latest version number simply using describe_parameters
.
This would return Parameters with the version.
import boto3
client = boto3.client('ssm')
response = client.describe_parameters(
Filters=[
{
'Key': 'Name',
'Values': [
'<name_of_ssm_param>',
]
},
],
)
print(response)
Just put version number like <name_of_ssm_param>:version
.
To get parameters, get_parameters
works.
response = client.get_parameters(
Names=[
'<name_of_ssm_param>:version',
],
)
print(response)
Upvotes: 2