-
-
Save gowatana/86d87787b755228b9e7be5c14bb3e809 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Get VMC on AWS cost | |
hosts: localhost | |
gather_facts: false | |
vars_files: | |
- id_and_key.yml | |
tasks: | |
- name: get access token | |
ansible.builtin.uri: | |
url: "https://console.cloud.vmware.com/csp/gateway/am/api/auth/api-tokens/authorize" | |
method: POST | |
headers: | |
Accept: "application/json" | |
Content-Type: "application/x-www-form-urlencoded" | |
body: "refresh_token={{ api_key }}" | |
body_format: json | |
status_code: 200 | |
register: token | |
- name: get cost info | |
ansible.builtin.uri: | |
url: "https://console.cloud.vmware.com/csp/gateway/commerce/api/v1/orgs/{{ org_id }}/estimated-charges" | |
method: GET | |
headers: | |
Accept: "application/json" | |
csp-auth-token: "{{ token.json.access_token }}" | |
status_code: 200 | |
register: cost_info | |
- name: output cost info | |
debug: | |
msg: "{{ lookup('pipe', 'date +\"%Y-%m-%d %H:%M:%S\"') }} {{ cost_info.json.totalPayments }} {{ cost_info.json.currency }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
下記の投稿むけ。
VMware Cloud on AWS のコストを情報を REST API で見てみる。(curl / Ansible)
https://vm.gowatana.jp/entry/2023/07/13/084828