Skip to content

Instantly share code, notes, and snippets.

@markuman
Created January 6, 2020 06:31
Show Gist options
  • Save markuman/b5d77b01484e1cdccef9154aab5b2664 to your computer and use it in GitHub Desktop.
Save markuman/b5d77b01484e1cdccef9154aab5b2664 to your computer and use it in GitHub Desktop.
---
- hosts: localhost
connection: local
gather_facts: False
vars:
duration: 7200
vars_prompt:
- name: TOTP
prompt: TOTP needed only for iam operations
private: no
default: ""
tasks:
- name: fetch MFA device info
iam_mfa_device_info:
profile: "{{ YOUR_AWS_PROFILE }}"
register: mfa_devices
- name: sts credentials with MFA
sts_session_token:
duration_seconds: "{{ duration }}"
profile: "{{ YOUR_AWS_PROFILE }}"
region: eu-central-1
mfa_serial_number: "{{ mfa_devices.mfa_devices[0].serial_number }}"
mfa_token: "{{ TOTP }}"
register: mfa_assumed_role
- debug: msg="{{mfa_assumed_role}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment