Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ec2_instance: Allow auto selection of ebs optimized #61222

wants to merge 10 commits into
base: devel

Check for ebs_optimized type and fail if not bool/auto

  • Loading branch information...
Shaps committed Sep 16, 2019
commit 59e76a112cdbaec73ed1ed68c12bc3f14073fec3
@@ -718,7 +718,7 @@
from ansible.module_utils.six import text_type, string_types
from ansible.module_utils.six.moves.urllib import parse as urlparse
from ansible.module_utils._text import to_bytes, to_native
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.module_utils.common.validation import check_type_bool
import ansible.module_utils.ec2 as ec2_utils
from ansible.module_utils.ec2 import (boto3_conn,
@@ -1142,7 +1142,7 @@ def build_top_level_options(params):
if params.get('ebs_optimized') == 'auto':
ebs_optimized = _supports_ebs_optimized(params.get('instance_type'))
ebs_optimized = boolean(params.get('ebs_optimized'))
ebs_optimized = params.get('ebs_optimized')
spec['EbsOptimized'] = ebs_optimized
if params.get('instance_initiated_shutdown_behavior'):
spec['InstanceInitiatedShutdownBehavior'] = params.get('instance_initiated_shutdown_behavior')
@@ -1646,6 +1646,15 @@ def main():
if module.params.get('security_groups'):
module.fail_json(msg="Parameter network.interfaces can't be used with security_groups")

if module.params.get('ebs_optimized'):
if module.params.get('ebs_optimized') != 'auto':
module.params['ebs_optimized'] = check_type_bool(module.params.get('ebs_optimized'))
except TypeError as e:
module.fail_json(msg="Parameter ebs_optimized must be a boolean or 'auto'")

state = module.params.get('state')
ec2 = module.client('ec2')
if module.params.get('filters') is None:
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.