'Can we retrieve the values from SSM parameter store and pass it as an input to AWS step function?
I have a step function that requires ARN's of lambda function. These Lambda functions are created using terraform scripts and ARN's of this are stored in the SSM parameter store. I want to retrieve these ARN's from the parameter store and pass it as input to my state machine. how do I include this in my state machine??
Solution 1:[1]
AWS Step Functions integrates with AWS services like parameter store, letting you call each service's API actions from your workflow.
ref: https://docs.aws.amazon.com/step-functions/latest/dg/supported-services-awssdk.html
Here is the example of step function definition in ASL:
{
"Comment": "This is your state machine",
"StartAt": "GetParameter",
"States": {
"GetParameter": {
"Type": "Task",
"Parameters": {
"Names": ["<paramter_name>"]
},
"Resource": "arn:aws:states:::aws-sdk:ssm:getParameters",
"ResultSelector": {
"ssm-parameters.$": "$.Parameters"
},
"End": true
}
}
}
Note: replace <paramter_name> with your parameter name
Solution 2:[2]
I've had luck with resolving ssm params as template parameters.
In your cloudformation template.
Parameters:
SomeTemplateVar:
Type: String
Default: "{{resolve:ssm:YourSSMParameter:1}}"
Then you can reference that variable in your workflow JSON.
"Lambda Invoke": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": "$",
"FunctionName": "${SomeTemplateVar}"
},
Solution 3:[3]
There is no Step function direct service integration with Parameter Store at this moment. What you can do is to use a lambda integration which calls parameter store to fetch the data and use the result into the results path.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Evan Lalo |
| Solution 3 | Pubudu Jayawardana |
