diff --git a/roles/aws/aws_ec2_with_eip/tasks/main.yml b/roles/aws/aws_ec2_with_eip/tasks/main.yml index 09be043cc..37ef61a20 100644 --- a/roles/aws/aws_ec2_with_eip/tasks/main.yml +++ b/roles/aws/aws_ec2_with_eip/tasks/main.yml @@ -100,6 +100,11 @@ virtualization-type: "{{ aws_ec2_with_eip.ami_virtualization_type }}" register: _aws_ec2_with_eip_ami_images +- name: Quit if no AMI found. + ansible.builtin.fail: + msg: "No AMI found using the provided filters, exiting!" + when: _aws_ec2_with_eip_ami_images.images | length == 0 + # Do not create an instance if _aws_hostname is not an EC2 generated address unless `force: true` - name: Create new EC2 instance. amazon.aws.ec2_instance: