Skip to content

Instantly share code, notes, and snippets.

@nleiva
Last active July 7, 2021 21:26
Show Gist options
  • Save nleiva/d5d01342a72773fdaf416aa16569b025 to your computer and use it in GitHub Desktop.
Save nleiva/d5d01342a72773fdaf416aa16569b025 to your computer and use it in GitHub Desktop.
- name: Create SSH Key Pair for instance
amazon.aws.ec2_key:
name: "{{ ec2_resource_prefix }}-key"
region: "{{ ec2_region }}"
register: create_key
- name: Save Private Key
ansible.builtin.copy:
content: "{{ create_key.key.private_key }}"
dest: "{{ playbook_dir }}/{{ ec2_resource_prefix }}-private.pem"
mode: '0400'
when: create_key.changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment