Hi All,
I am trying to retrieve the Instance ID of the newly created EC2 instance.
But I get below error:
`
ok: [localhost] => {
“stack_details.stackoutputs.InstanceId”: “VARIABLE IS NOT DEFINED!”
}
`
Below is the playbook:
`
Hi All,
I am trying to retrieve the Instance ID of the newly created EC2 instance.
But I get below error:
`
ok: [localhost] => {
“stack_details.stackoutputs.InstanceId”: “VARIABLE IS NOT DEFINED!”
}
`
Below is the playbook:
`
Without the output of
- debug: var=stack_details
there isn't mush we can do.
Hi Kai,
Below is the output of
`
ok: [localhost] => {
“stack_details”: {
“changed”: true,
“events”: [
“StackEvent AWS::CloudFormation::Stack mywindowsec2 CREATE_COMPLETE”,
“StackEvent AWS::EC2::Instance Windows2016EC2 CREATE_COMPLETE”,
“StackEvent AWS::EC2::Instance Windows2016EC2 CREATE_IN_PROGRESS”,
“StackEvent AWS::EC2::Instance Windows2016EC2 CREATE_IN_PROGRESS”,
“StackEvent AWS::CloudFormation::Stack mywindowsec2 CREATE_IN_PROGRESS”
],
“failed”: false,
“log”: ,
“output”: “Stack CREATE complete”,
“stack_outputs”: {
“InstanceId”: “i-0a913dd7c9eb45bbe”
},
“stack_resources”: [
{
“last_updated_time”: “2018-12-08T08:58:44.185000+00:00”,
“logical_resource_id”: “Windows2016EC2”,
“physical_resource_id”: “i-0a913dd7c9eb45bbe”,
“resource_type”: “AWS::EC2::Instance”,
“status”: “CREATE_COMPLETE”,
“status_reason”: null
}
]
}
}
`
I need only InstanceId from the above.
Regards,
Pawan Sawalani
Hi Kai,
Below is the output of
- debug: var=stack_detailsok: [localhost] => {
"stack_details": {
"changed": true,
"events": [
"StackEvent AWS::CloudFormation::Stack mywindowsec2
CREATE_COMPLETE",
"StackEvent AWS::EC2::Instance Windows2016EC2 CREATE_COMPLETE",
"StackEvent AWS::EC2::Instance Windows2016EC2
CREATE_IN_PROGRESS",
"StackEvent AWS::EC2::Instance Windows2016EC2
CREATE_IN_PROGRESS",
"StackEvent AWS::CloudFormation::Stack mywindowsec2
CREATE_IN_PROGRESS"
],
"failed": false,
"log": ,
"output": "Stack CREATE complete",
"stack_outputs": {
"InstanceId": "i-0a913dd7c9eb45bbe"
},
It's stack_outputs, but as you see below you used stackoutputs
> > But I get below error:
> >
> > ok: [localhost] => {
> > "stack_details.stackoutputs.InstanceId": "VARIABLE IS NOT DEFINED!"
So the correct variable should be
stack_details.stack_outputs.InstanceId
Thanks Kai…!!
Its working now.
Regards,
Pawan Sawalani