Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wait Condition Heat/CloudFormation and instance startup order

I have a OpenStack Heat template which borrows heavily from the CloudFormation parameters, which is why I added the CF tag.

My template contains two instances which should be started (or at least configured through user-data) in a specific order. I thought I would use WaitCondition to make that happen but it looks like he doesn't fully work, or at least doesn't do what I expect.

Here's a snippet:

resources:
  first:
    type: OS::Nova::Server
    properties:
      key_name: { get_param: key_name }
      image: fedora19
      flavor: { get_param: instance_type }
      user_data:
        str_replace:
          template: |
              #!/bin/bash
              [configuration code here]
              curl -X PUT -H 'Content-Type:application/json' -d '{"Status" : "SUCCES", "Data" : "Application has completed configuration."}' "$wait_handle$"
          params:
            $wait_handle$: {get_resource: my_wait_handle}

  first_wait_handle:
    type: AWS::CloudFormation::WaitConditionHandle

  first_wait:
    type: AWS::CloudFormation::WaitCondition
    depends_on: first
    properties:
      Handle:
    get_resource: first_wait_handle
      Timeout: 1000

second:
    type: OS::Nova::Server
    depends_on: first_wait
    properties:
      key_name: { get_param: key_name }
      image: fedora19
      flavor: { get_param: instance_type }
      user_data: |
        #!/bin/bash
        [configuration code 2]

Currently the stack is correctly stuck on "create in progress" state while Heat hasn't received the curl signal back, which is correct. Problem is that the 'second' instance is created as soon as the stack is launched and configuration runs automatically.

I added a depends_on in the second instance but it looks like it has no effect (or, again, not the effect I thought).

Is it possible to do this instance startup order configuration with Heat/Cloud Formation? What am I missing?

Thanks!

like image 411
fdhex Avatar asked Dec 02 '25 10:12

fdhex


1 Answers

Read this blog given here and he has given a correct explanation to your question. Because this functionality doesn't actually works. There is a work-around which you can make use of.

like image 134
Dushyant Gupta Avatar answered Dec 04 '25 00:12

Dushyant Gupta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!