From f131bd7432b7f61dcc3b5217eb79311b9c417af6 Mon Sep 17 00:00:00 2001 From: Sarvesh Anand Date: Tue, 7 Jan 2025 16:59:09 +0530 Subject: [PATCH] Update docs examples --- docs/resources/role_bindings.md | 56 ++++++++++++++++++- docs/resources/service_account.md | 12 ---- docs/resources/service_account_key.md | 16 +++++- .../castai_role_bindings/resource.tf | 51 +++++++++++++++++ .../castai_service_account/resource.tf | 12 ---- .../castai_service_account_key/resource.tf | 11 ++++ 6 files changed, 132 insertions(+), 26 deletions(-) create mode 100644 examples/resources/castai_role_bindings/resource.tf create mode 100644 examples/resources/castai_service_account_key/resource.tf diff --git a/docs/resources/role_bindings.md b/docs/resources/role_bindings.md index 1c820e26..4d9afa39 100644 --- a/docs/resources/role_bindings.md +++ b/docs/resources/role_bindings.md @@ -10,7 +10,61 @@ description: |- CAST AI organization group resource to manage organization groups - +## Example Usage + +```terraform +data "castai_organization" "test" { + name = "My test organization name" +} + +resource "castai_role_bindings" "owner_test" { + organization_id = data.castai_organization.test.id + name = "Role binding owner" + description = "Owner access for whole organization." + + role_id = "3e1050c7-6593-4298-94bb-154637911d78" # Role "Owner" + scope { + kind = "organization" + resource_id = data.castai_organization.test.id + } + subjects { + subject { + kind = "user" + user_id = "21c133e2-a899-4f51-b297-830bc62e51d6" # user x + } + subject { + kind = "user" + user_id = "0d1efe35-7ecb-4821-a52d-fd56c9710a64" # user y + } + subject { + kind = "group" + group_id = "651734a7-0d0c-49f3-9654-dd92175febaa" + } + subject { + kind = "service_account" + service_account_id = "3bf49513-3e9c-4a12-962c-af3bb1a85074" + } + } +} + +resource "castai_role_bindings" "viewer_test" { + organization_id = data.castai_organization.test.id + name = "Role binding viewer for cluster 7063d31c-897e-48ef-a322-bdfda6fdbcfb" + description = "Viewer access for on of the clusters." + + role_id = "6fc95bd7-6049-4735-80b0-ce5ccde71cb1" # Role "Viewer" + scope { + kind = "cluster" + resource_id = "7063d31c-897e-48ef-a322-bdfda6fdbcfb" + } + subjects { + subject { + kind = "user" + user_id = "21c133e2-a899-4f51-b297-830bc62e51d6" # user z + } + } +} +``` ## Schema diff --git a/docs/resources/service_account.md b/docs/resources/service_account.md index 81f7c160..5e82a8c1 100644 --- a/docs/resources/service_account.md +++ b/docs/resources/service_account.md @@ -18,18 +18,6 @@ resource "castai_service_account" "service_account" { name = "example-service-account" description = "service account description" } - -resource "castai_service_account_key" "service_account_key" { - organization_id = data.castai_organization.test.id - service_account_id = castai_service_account.service_account.id - name = "example-key" - active = true - expires_at = "2025-01-01T00:00:00Z" -} - -output "service_account_key" { - value = castai_service_account_key.service_account_key.token -} ``` diff --git a/docs/resources/service_account_key.md b/docs/resources/service_account_key.md index d9b3ae37..ebef99f2 100644 --- a/docs/resources/service_account_key.md +++ b/docs/resources/service_account_key.md @@ -10,7 +10,21 @@ description: |- Service account key resource allows managing CAST AI service account keys. - +## Example Usage + +```terraform +resource "castai_service_account_key" "service_account_key" { + organization_id = data.castai_organization.test.id + service_account_id = castai_service_account.service_account.id + name = "example-key" + active = true + expires_at = "2025-01-01T00:00:00Z" +} + +output "service_account_key" { + value = castai_service_account_key.service_account_key.token +} +``` ## Schema diff --git a/examples/resources/castai_role_bindings/resource.tf b/examples/resources/castai_role_bindings/resource.tf new file mode 100644 index 00000000..8a4394cc --- /dev/null +++ b/examples/resources/castai_role_bindings/resource.tf @@ -0,0 +1,51 @@ +data "castai_organization" "test" { + name = "My test organization name" +} + +resource "castai_role_bindings" "owner_test" { + organization_id = data.castai_organization.test.id + name = "Role binding owner" + description = "Owner access for whole organization." + + role_id = "3e1050c7-6593-4298-94bb-154637911d78" # Role "Owner" + scope { + kind = "organization" + resource_id = data.castai_organization.test.id + } + subjects { + subject { + kind = "user" + user_id = "21c133e2-a899-4f51-b297-830bc62e51d6" # user x + } + subject { + kind = "user" + user_id = "0d1efe35-7ecb-4821-a52d-fd56c9710a64" # user y + } + subject { + kind = "group" + group_id = "651734a7-0d0c-49f3-9654-dd92175febaa" + } + subject { + kind = "service_account" + service_account_id = "3bf49513-3e9c-4a12-962c-af3bb1a85074" + } + } +} + +resource "castai_role_bindings" "viewer_test" { + organization_id = data.castai_organization.test.id + name = "Role binding viewer for cluster 7063d31c-897e-48ef-a322-bdfda6fdbcfb" + description = "Viewer access for on of the clusters." + + role_id = "6fc95bd7-6049-4735-80b0-ce5ccde71cb1" # Role "Viewer" + scope { + kind = "cluster" + resource_id = "7063d31c-897e-48ef-a322-bdfda6fdbcfb" + } + subjects { + subject { + kind = "user" + user_id = "21c133e2-a899-4f51-b297-830bc62e51d6" # user z + } + } +} diff --git a/examples/resources/castai_service_account/resource.tf b/examples/resources/castai_service_account/resource.tf index 97c72248..aed90a31 100644 --- a/examples/resources/castai_service_account/resource.tf +++ b/examples/resources/castai_service_account/resource.tf @@ -3,15 +3,3 @@ resource "castai_service_account" "service_account" { name = "example-service-account" description = "service account description" } - -resource "castai_service_account_key" "service_account_key" { - organization_id = data.castai_organization.test.id - service_account_id = castai_service_account.service_account.id - name = "example-key" - active = true - expires_at = "2025-01-01T00:00:00Z" -} - -output "service_account_key" { - value = castai_service_account_key.service_account_key.token -} diff --git a/examples/resources/castai_service_account_key/resource.tf b/examples/resources/castai_service_account_key/resource.tf new file mode 100644 index 00000000..3e1cc5cf --- /dev/null +++ b/examples/resources/castai_service_account_key/resource.tf @@ -0,0 +1,11 @@ +resource "castai_service_account_key" "service_account_key" { + organization_id = data.castai_organization.test.id + service_account_id = castai_service_account.service_account.id + name = "example-key" + active = true + expires_at = "2025-01-01T00:00:00Z" +} + +output "service_account_key" { + value = castai_service_account_key.service_account_key.token +}