Skip to content

Commit

Permalink
Fix deprecation warning on instance_type (#983)
Browse files Browse the repository at this point in the history
Fix deprecation warning on instance_type

SUMMARY
Specifying instance_type should not be required unless count or exact_count are specified.
If the user is just trying to start/stop instances then we don't need to ask for size.
Fixes #980
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ec2_instance
ADDITIONAL INFORMATION

Reviewed-by: Gonéri Le Bouder <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Brian Scholer <None>
  • Loading branch information
rbobrowicz authored Sep 6, 2022
1 parent 08746a1 commit d80ab5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- ec2_instance - Only show the deprecation warning for the default value of ``instance_type`` when ``count`` or ``exact_count`` are specified (https://github.com//issues/980).
8 changes: 5 additions & 3 deletions plugins/modules/ec2_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2050,9 +2050,11 @@ def main():
supports_check_mode=True
)

if not module.params.get('instance_type') and not module.params.get('launch_template') and module.params.get('state') != 'absent':
module.deprecate("Default value instance_type has been deprecated, in the future you must set an instance_type or a launch_template",
date='2023-01-01', collection_name='amazon.aws')
if not module.params.get('instance_type') and not module.params.get('launch_template'):
if module.params.get('state') not in ('absent', 'stopped'):
if module.params.get('count') or module.params.get('exact_count'):
module.deprecate("Default value instance_type has been deprecated, in the future you must set an instance_type or a launch_template",
date='2023-01-01', collection_name='amazon.aws')
result = dict()

if module.params.get('network'):
Expand Down

0 comments on commit d80ab5b

Please sign in to comment.