Use DescribeParameters
with an Amazon SDK or CLI
The following code examples show how to use DescribeParameters
.
- CLI
-
- Amazon CLI
-
Example 1: To list all parameters
The following
describe-parameters
example lists all parameters in the current Amazon account and Region.aws ssm describe-parameters
Output:
{ "Parameters": [ { "Name": "MySecureStringParameter", "Type": "SecureString", "KeyId": "alias/aws/ssm", "LastModifiedDate": 1582155479.205, "LastModifiedUser": "arn:aws:sts::111222333444:assumed-role/Admin/Richard-Roe-Managed", "Description": "This is a SecureString parameter", "Version": 2, "Tier": "Advanced", "Policies": [ { "PolicyText": "{\"Type\":\"Expiration\",\"Version\":\"1.0\",\"Attributes\":{\"Timestamp\":\"2020-07-07T22:30:00Z\"}}", "PolicyType": "Expiration", "PolicyStatus": "Pending" }, { "PolicyText": "{\"Type\":\"ExpirationNotification\",\"Version\":\"1.0\",\"Attributes\":{\"Before\":\"12\",\"Unit\":\"Hours\"}}", "PolicyType": "ExpirationNotification", "PolicyStatus": "Pending" } ] }, { "Name": "MyStringListParameter", "Type": "StringList", "LastModifiedDate": 1582154764.222, "LastModifiedUser": "arn:aws:iam::111222333444:user/Mary-Major", "Description": "This is a StringList parameter", "Version": 1, "Tier": "Standard", "Policies": [] }, { "Name": "MyStringParameter", "Type": "String", "LastModifiedDate": 1582154711.976, "LastModifiedUser": "arn:aws:iam::111222333444:user/Alejandro-Rosalez", "Description": "This is a String parameter", "Version": 1, "Tier": "Standard", "Policies": [] }, { "Name": "latestAmi", "Type": "String", "LastModifiedDate": 1580862415.521, "LastModifiedUser": "arn:aws:sts::111222333444:assumed-role/lambda-ssm-role/Automation-UpdateSSM-Param", "Version": 3, "Tier": "Standard", "Policies": [] } ] }
Example 2: To list all parameters matching specific metadata
This
describe-parameters
example lists all parameters matching a filter.aws ssm describe-parameters --filters "Key=Type,Values=StringList"
Output:
{ "Parameters": [ { "Name": "MyStringListParameter", "Type": "StringList", "LastModifiedDate": 1582154764.222, "LastModifiedUser": "arn:aws:iam::111222333444:user/Mary-Major", "Description": "This is a StringList parameter", "Version": 1, "Tier": "Standard", "Policies": [] } ] }
For more information, see Searching for Systems Manager Parameters
in the Amazon Systems Manager User Guide. -
For API details, see DescribeParameters
in Amazon CLI Command Reference.
-
- Java
-
- SDK for Java 2.x
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository
. import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.ssm.SsmClient; import software.amazon.awssdk.services.ssm.model.GetParameterRequest; import software.amazon.awssdk.services.ssm.model.GetParameterResponse; import software.amazon.awssdk.services.ssm.model.SsmException; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class GetParameter { public static void main(String[] args) { final String usage = """ Usage: <paraName> Where: paraName - The name of the parameter. """; if (args.length != 1) { System.out.println(usage); System.exit(1); } String paraName = args[0]; Region region = Region.US_EAST_1; SsmClient ssmClient = SsmClient.builder() .region(region) .build(); getParaValue(ssmClient, paraName); ssmClient.close(); } public static void getParaValue(SsmClient ssmClient, String paraName) { try { GetParameterRequest parameterRequest = GetParameterRequest.builder() .name(paraName) .build(); GetParameterResponse parameterResponse = ssmClient.getParameter(parameterRequest); System.out.println("The parameter value is " + parameterResponse.parameter().value()); } catch (SsmException e) { System.err.println(e.getMessage()); System.exit(1); } } }
-
For API details, see DescribeParameters in Amazon SDK for Java 2.x API Reference.
-
- PowerShell
-
- Tools for PowerShell
-
Example 1: This example lists all parameters.
Get-SSMParameterList
Output:
Description : KeyId : LastModifiedDate : 3/3/2017 6:58:23 PM LastModifiedUser : arn:aws:iam::123456789012:user/admin Name : Welcome Type : String
-
For API details, see DescribeParameters
in Amazon Tools for PowerShell Cmdlet Reference.
-
- Rust
-
- SDK for Rust
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository
. async fn show_parameters(client: &Client) -> Result<(), Error> { let resp = client.describe_parameters().send().await?; for param in resp.parameters() { println!(" {}", param.name().unwrap_or_default()); } Ok(()) }
-
For API details, see DescribeParameters
in Amazon SDK for Rust API reference.
-
For a complete list of Amazon SDK developer guides and code examples, see Using Systems Manager with an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.