Search code examples
amazon-ec2ansibleansible-2.xamazon-ec2-spot-market

instance_initiated_shutdown_behavior=stop is not supported for spot instances


I am trying to provision spot instance using Ansible 2.8. When i run my playbook, i encountered the following error. "instance_initiated_shutdown_behavior=stop is not supported for spot instances."

However, the strange thing is that in my playbook, i did not specify anything to stop the spot instances.

Does anyone have any idea what might have caused the error?

$ ansible-playbook test.yml

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [Create an ec2 instance] ************************************************** TASK [Create an ec2 instance] ************************************************** fatal: [localhost]: FAILED! => {"changed": false, "msg": "instance_initiated_shutdown_behavior=stop is not supported for spot instances."} PLAY RECAP ********************************************************************* localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

Below is a portion of the yaml file that I executed.

tasks:
  - name: Create an ec2 instance
      ec2:
        spot_price: '0.24'
        spot_wait_timeout: 600
        aws_access_key: "{{ access_key }}"
        aws_secret_key: "{{ secret_key }}"
        region: "{{ region }}"
        keypair: "{{ keypair }}"
        group_id: "{{ group_id}}"
        instance_type: "{{ instance_type }}"
        image: "{{ ami }}"
        wait: yes
        vpc_subnet_id: "{{ subnet_id }}"
        assign_public_ip: yes
        spot_launch_group: report_generators

Solution

  • According to the fine manual, instance_initiated_shutdown_behavior defaults to stop, which is why you must override it with instance_initiated_shutdown_behavior: terminate in your case