I’m making a package that creates an EC2 instance.
(Of course I understand that there are AWS packs, but for studying)
Get the information after EC2 instance creation, and print it as standard output.
It worked fine so far, but if you try to get the instance information in the next workflow, you get an error for some reason.
However, if you create another workflow and follow the steps below, you can retrieve the values without problems.
- Save the same JSON data (*) to a file
- Echo the file to task 1 for standard output
- In Task 2, retrieve the JSON value of 2.
(*) I don’t know if it is the same because it is saved after standard output …
What is the cause?
[yaml]
tasks:
task1:
action: hmpack.aws_ec2_create
input:
AMI_ID: "<% $ .AMI_ID%>"
Instance_Type: "<% $ .Instance_Type%>"
Key_Name: "<% $ .Key_Name%>"
Tag_Name: "<% $ .Tag_Name%>"
publish:
json_result: "<% task (task1) .result.stdout%>"
on-success:
-task2
task2:
action: core.local
input:
cmd: "echo <% $ .json_result.Reservations [0] .Instances [0] .PublicDnsName%> >> /data/ec2.log"
[ERROR]
"state_info": "Failed to run task [error=Can not evaluate YAQL expression [expression=$.json_result.Reservations[0].Instances[0].PublicDnsName, error=Unknown function \"#property#Reservations\", data={}], wf=hmpack.deploy_machine.main, task=task2]:
Traceback (most recent call last):
File \"/opt/stackstorm/mistral/lib/python2.7/site-packages/mistral/engine/task_handler.py\", line 63, in run_task
task.run()
: