This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

Migrating script to actions

I have a script that has multiple functions and does multiple different tasks.
When migrating to a pack with st2 actions, am I correct that each task/function in the original script migrates to a single action in a single py file and yaml file within the pack?

Short answer: not necessarily.

Long answer: this is completely up to you. You can either make a single ST2 action that simply translates action inputs to the inputs of your task, or you can create multiple ST2 actions that define immutable inputs that get passed to your script. If you create multiple ST2 actions for your script, you can specify that some of the action inputs are immutable (such as which part of the script to run), and some action inputs can be mutable (the default), which would allow ST2 users to specify their own values for those inputs that would then get passed to your script.

StackStorm is very flexible in what it supports.

If you are looking for advice on how to implement it, I would go with the second option, where you have multiple ST2 actions all calling the same script with different inputs. Implementing it that way immediately gives your users an explicit list of actions they can run, instead of having to dig through your script or read any documentation to figure it out for themselves. How exactly it is implemented (eg: with a single script or a collection of scripts) is an implementation detail that they should not have to know or care about to use your pack/script.

And that’s actually how a lot of packs on StackStorm Exchange are implemented, such as the AWS pack.

Thanks for the explanation, that’s helps a lot.
I’ll check out the AWS pack.

Ahh I get it. Just looked at the AWS.
Single script that does the heavy lifting and then just individual yaml files defining the action.
That looks like an easy way to go for me. This will be my first pack so don’t want to over complicate it.

Yep, exactly. And it’s a good idea to keep things as simple as possible when you’re learning how to put a pack together!

We do respond (mostly) to questions in these forums, but you will receive more timely and detailed answers from StackStorm contributors, other users, and seasoned pack developers in our Slack Community.

1 Like