summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/cloud
diff options
context:
space:
mode:
authorRyan Brown <sb@ryansb.com>2018-02-08 09:27:02 -0500
committerGitHub <noreply@github.com>2018-02-08 09:27:02 -0500
commit0036cff493b45b14f875d9e17625ba9ed3e8ad94 (patch)
tree88b1486134a4dee15793a67851e2aa41e94233a4 /lib/ansible/modules/cloud
parentcef1a666f31abff1b1792a53adf1eb0bc4579642 (diff)
downloadansible-0036cff493b45b14f875d9e17625ba9ed3e8ad94.tar.gz
[cloud] Add key_name parameter to ec2_instance (#35901)
Diffstat (limited to 'lib/ansible/modules/cloud')
-rw-r--r--lib/ansible/modules/cloud/amazon/ec2_instance.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/ansible/modules/cloud/amazon/ec2_instance.py b/lib/ansible/modules/cloud/amazon/ec2_instance.py
index 2320ed7a37..d9cbdcfdd3 100644
--- a/lib/ansible/modules/cloud/amazon/ec2_instance.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_instance.py
@@ -108,6 +108,9 @@ options:
- I(launch_template.id) the ID or the launch template (optional if name is specified)
- I(launch_template.name) the pretty name of the launch template (optional if id is specified)
- I(launch_template.version) the specific version of the launch template to use. If unspecified, the template default is chosen.
+ key_name:
+ description:
+ - Name of the SSH access key to assign to the instance - must exist in the region the instance is created.
availability_zone:
description:
- Specify an availability zone to use the default subnet it. Useful if not specifying the I(vpc_subnet_id) parameter.
@@ -899,6 +902,8 @@ def build_top_level_options(params):
if not spec.get('ImageId') and not params.get('launch_template'):
module.fail_json(msg="You must include an image_id or image.id parameter to create an instance, or use a launch_template.")
+ if params.get('key_name') is not None:
+ spec['KeyName'] = params.get('key_name')
if params.get('user_data') is not None:
spec['UserData'] = to_native(params.get('user_data'))
elif params.get('tower_callback') is not None:
@@ -1341,6 +1346,7 @@ def main():
purge_tags=dict(type='bool', default=False),
filters=dict(type='dict', default=None),
launch_template=dict(type='dict'),
+ key_name=dict(type='str'),
cpu_credit_specification=dict(type='str', choices=['standard', 'unlimited']),
tenancy=dict(type='str', choices=['dedicated', 'default']),
instance_initiated_shutdown_behavior=dict(type='str', choices=['stop', 'terminate']),