---

- name: Install vehicle 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: "zooxChum", option: "aws_access_key_id", vault_path: "ingest_chum", vault_field: "access_key"  }
    - { section: "zooxChum", option: "aws_secret_access_key", vault_path: "ingest_chum", vault_field: "secret_access_key"  }
    - { section: "z3ChumHot", option: "aws_access_key_id", vault_path: "z3_chum_hot_ingest", vault_field: "access_key"  }
    - { section: "z3ChumHot", option: "aws_secret_access_key", vault_path: "z3_chum_hot_ingest", vault_field: "secret_access_key"  }
    - { section: "s3DataIncoming", option: "aws_access_key_id", vault_path: "s3_chum_ingest", vault_field: "access_key"  }
    - { section: "s3DataIncoming", option: "aws_secret_access_key", vault_path: "s3_chum_ingest", vault_field: "secret_access_key"  }
  tags: kiosk_account
