How do I use Systems Manager Automation to retrieve parameters from the Parameter Store?

2 minute read
0

I want to know how I can use Automation, a capability of AWS Systems Manager, to retrieve parameters.

Resolution

Use the automation action aws:executeAwsApi with the GetParameter API to retrieve a parameter value from the Parameter Store, a capability of AWS Systems Manager.

Example:

{
  "description": "Automation Document Example JSON Template",
  "schemaVersion": "0.3",
  "assumeRole": "{{ AutomationAssumeRole }}",
  "parameters": {
    "ParameterName": {
      "type": "String",
      "description": "Enter the Name of the String Parameter to retrieve its value"
    },
    "AutomationAssumeRole": {
      "type": "String",
      "description": "(Optional) The ARN of the role that allows Automation to perform the actions on your behalf.",
      "default": ""
    }
  },
  "mainSteps": [
    {
      "name": "getparameter",
      "action": "aws:executeAwsApi",
      "inputs": {
        "Service": "ssm",
        "Api": "GetParameter",
        "Name": "{{ ParameterName }}"
      },
      "outputs": [
        {
          "Name": "Parameters",
          "Selector": "$.Parameter.Value",
          "Type": "String"
        }
      ]
    }
  ],
  "outputs": [
    "getparameter.Parameters"
  ]
}

To retrieve a SecureString parameter, use WithDecryption, and set the value to true.

Example:

"mainSteps": [
    {
      "name": "getparameter",
      "action": "aws:executeAwsApi",
      "inputs": {
        "Service": "ssm",
        "Api": "GetParameter",
        "Name": "{{ ParameterName }}",
        "WithDecryption": true
      },

For more information, see Working with parameters using Run Command commands.

Related information

AWS Systems Manager Parameter Store

Data elements and parameters

AWS::SSM::Parameter

AWS OFFICIAL
AWS OFFICIALUpdated 9 months ago