ec2_elb_lb: allow elb scheme to be updated by restarting the resource - fixes #19116 (#22916)

* allow elb scheme to be updated by restarting the resource

use ensure_gone and require wait option

* fix pep8

* fix yaml

* requested changes

* fix fail_json
pull/19436/merge
Sloane Hertel 8 years ago committed by Ryan Brown
parent e1d896052d
commit 2618e6d516

@ -108,6 +108,9 @@ options:
scheme:
description:
- The scheme to use when creating the ELB. For a private VPC-visible ELB use 'internal'.
If you choose to update your scheme with a different value the ELB will be destroyed and
recreated. To update scheme you must use the option wait.
choices: ["internal", "internet-facing"]
required: false
default: 'internet-facing'
version_added: "1.7"
@ -493,6 +496,11 @@ class ElbManager(object):
if not self.elb:
# Zones and listeners will be added at creation
self._create_elb()
else:
if self._get_scheme():
# the only way to change the scheme is by recreating the resource
self.ensure_gone()
self._create_elb()
else:
self._set_zones()
self._set_security_groups()
@ -873,6 +881,15 @@ class ElbManager(object):
if subnets_to_detach:
self._detach_subnets(subnets_to_detach)
def _get_scheme(self):
"""Determine if the current scheme is different than the scheme of the ELB"""
if self.scheme:
if self.elb.scheme != self.scheme:
if not self.wait:
self.module.fail_json(msg="Unable to modify scheme without using the wait option")
return True
return False
def _set_zones(self):
"""Determine which zones need to be enabled or disabled on the ELB"""
if self.zones:
@ -1246,7 +1263,7 @@ def main():
health_check={'default': None, 'required': False, 'type': 'dict'},
subnets={'default': None, 'required': False, 'type': 'list'},
purge_subnets={'default': False, 'required': False, 'type': 'bool'},
scheme={'default': 'internet-facing', 'required': False},
scheme={'default': 'internet-facing', 'required': False, 'choices': ['internal', 'internet-facing']},
connection_draining_timeout={'default': None, 'required': False, 'type': 'int'},
idle_timeout={'default': None, 'type': 'int', 'required': False},
cross_az_load_balancing={'default': None, 'type': 'bool', 'required': False},

Loading…
Cancel
Save