0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

HCP Terraform の Workspace ごとの RUM 数を取得する

0
Posted at

HCP Terraform(Terraform Cloud)の Workspace ごとの RUM(Resources Under Management)数は、Explorer API で取得できます。

取得方法(Explorer API)

/api/v2/organizations/:organization/explorer に対して、type=workspaces を指定して取得し、レスポンス内の current-rum-count を参照します。

公式ドキュメント(Explorer API):

実行例

$ curl -s \
  --header "Authorization: Bearer $TOKEN" \
  "https://app.terraform.io/api/v2/organizations/$ORGANIZATION/explorer?type=workspaces" \
| jq -r '.data[] | "\(.attributes["workspace-name"]) \(.attributes["current-rum-count"])"'
workspace_1 10
workspace_2 20
workspace_3 30

ページングに注意

Explorer API にはページングがあり、page[size] は 1〜100 の範囲で指定します(最大 100 件)

$ curl \
  --header "Authorization: Bearer $TOKEN" \
  "https://app.terraform.io/api/v2/organizations/$ORGANIZATION/explorer?type=workspaces&page\[size\]=101"
{"errors":[{"status":"422","title":"invalid attribute","detail":"page[size] must be between 1 and 100"}]}

Workspace 数が 100 を超える場合は、page[number] を使って複数ページを取得してください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?