diff --git a/lib/ansible/module_utils/aws/elbv2.py b/lib/ansible/module_utils/aws/elbv2.py index 1be3728077..74632ed455 100644 --- a/lib/ansible/module_utils/aws/elbv2.py +++ b/lib/ansible/module_utils/aws/elbv2.py @@ -229,6 +229,9 @@ class ApplicationLoadBalancer(ElasticLoadBalancerV2): self.access_logs_s3_prefix = module.params.get("access_logs_s3_prefix") self.idle_timeout = module.params.get("idle_timeout") + if self.elb is not None and self.elb['Type'] != 'application': + self.module.fail_json(msg="The load balancer type you are trying to manage is not application. Try elb_network_lb module instead.") + def create_elb(self): """ Create a load balancer @@ -340,6 +343,9 @@ class NetworkLoadBalancer(ElasticLoadBalancerV2): self.type = 'network' self.cross_zone_load_balancing = module.params.get('cross_zone_load_balancing') + if self.elb is not None and self.elb['Type'] != 'network': + self.module.fail_json(msg="The load balancer type you are trying to manage is not network. Try elb_application_lb module instead.") + def create_elb(self): """ Create a load balancer diff --git a/lib/ansible/modules/cloud/amazon/elb_application_lb.py b/lib/ansible/modules/cloud/amazon/elb_application_lb.py index 9675dacd59..42f31d7051 100644 --- a/lib/ansible/modules/cloud/amazon/elb_application_lb.py +++ b/lib/ansible/modules/cloud/amazon/elb_application_lb.py @@ -509,7 +509,7 @@ def main(): security_groups=dict(type='list'), scheme=dict(default='internet-facing', choices=['internet-facing', 'internal']), state=dict(choices=['present', 'absent'], type='str'), - tags=dict(default={}, type='dict'), + tags=dict(type='dict'), wait_timeout=dict(type='int'), wait=dict(default=False, type='bool') )