---

- name: Install AWS config
  copy:
    dest:  "{{ asset_root_directory }}/home/zoox/.aws/"
    src: "config"
    follow: yes
    force: yes
    owner: "{{ zoox_uid }}"
    group: "{{ zoox_gid }}"

- name: Install AWS credentials
  ini_file:
    dest: "{{ asset_root_directory }}/home/zoox/.aws/credentials"
    section: "{{ item.section }}"
    option: "{{ item.option }}"
    value: "{{ lookup('hashi_vault_cache', 'secret=secret/aws/' + item.vault_path )[item.vault_field] }}"
  with_items:
    - { section: "default", option: "aws_access_key_id", vault_path: "s3_sync", vault_field: "AWS_ACCESS_KEY_ID" }
    - { section: "default", option: "aws_secret_access_key", vault_path: "s3_sync", vault_field: "AWS_SECRET_ACCESS_KEY" }
