Currently, when using the EC2 Molecule plugin, issuing a molecule test command will cause all other EC2 instances in the subnet to be deleted. This is because the "destroy" phase gets run before the "create" phase, plus the fact that when the amazon.aws.ec2_instance Ansible module is called with no instance_id attribute (as is the case or a fresh molecule test command), the operation applies to all EC2 instance.
I've added in a block that checks that the instance_config is not empty before attempting to destroy EC2 instance.
This PR seeks to fix the issue described in https://github.com/ansible-community/molecule-plugins/issues/136 and https://github.com/ansible-community/molecule-plugins/issues/121.
Currently, when using the EC2 Molecule plugin, issuing a
molecule test
command will cause all other EC2 instances in the subnet to be deleted. This is because the "destroy" phase gets run before the "create" phase, plus the fact that when theamazon.aws.ec2_instance
Ansible module is called with noinstance_id
attribute (as is the case or a freshmolecule test
command), the operation applies to all EC2 instance.I've added in a block that checks that the
instance_config
is not empty before attempting to destroy EC2 instance.