Skip to content

Commit

Permalink
Merge branch 'main' into PLT-1443
Browse files Browse the repository at this point in the history
  • Loading branch information
SivaanandM committed Nov 18, 2024
2 parents af7aee6 + d6c8c37 commit 562f443
Show file tree
Hide file tree
Showing 50 changed files with 2,320 additions and 29 deletions.
1 change: 1 addition & 0 deletions docs/data-sources/cloudaccount_aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ data "spectrocloud_cloudaccount_aws" "aws_account" {

### Optional

- `context` (String) The context of the cluster. Allowed values are `project` or `tenant` or ``.
- `depends` (String)
- `id` (String) ID of the AWS cloud account registered in Palette.
- `name` (String) Name of the AWS cloud account registered in Palette.
1 change: 1 addition & 0 deletions docs/data-sources/cloudaccount_azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ data "spectrocloud_cloudaccount_azure" "azure_account" {

### Optional

- `context` (String) The context of the cluster. Allowed values are `project` or `tenant` or ``.
- `id` (String) ID of the Azure cloud account registered in Palette.
- `name` (String) Name of the Azure cloud account registered in Palette.

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/cloudaccount_custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ description: |-

### Optional

- `context` (String) The context of the cluster. Allowed values are `project` or `tenant` or ``.
- `id` (String) The unique identifier of the cloud account. Either `id` or `name` must be provided.
- `name` (String) The name of the cloud account. Either `id` or `name` must be provided.
1 change: 1 addition & 0 deletions docs/data-sources/cloudaccount_gcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ data "spectrocloud_cloudaccount_gcp" "gcp_account" {

### Optional

- `context` (String) The context of the cluster. Allowed values are `project` or `tenant` or ``.
- `id` (String) ID of the GCP cloud account registered in Palette.
- `name` (String) Name of the GCP cloud account registered in Palette.
1 change: 1 addition & 0 deletions docs/data-sources/cloudaccount_maas.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ description: |-

### Optional

- `context` (String) The context of the cluster. Allowed values are `project` or `tenant` or ``.
- `id` (String) The unique ID of the cloud account. Either `id` or `name` must be provided, but not both.
- `name` (String) The name of the cloud account. This can be used instead of `id` to retrieve the account details. Only one of `id` or `name` can be specified.

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/cloudaccount_openstack.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ description: |-

### Optional

- `context` (String) The context of the cluster. Allowed values are `project` or `tenant` or ``.
- `id` (String) The unique ID of the OpenStack cloud account. Either `id` or `name` must be provided, but not both.
- `name` (String) The name of the OpenStack cloud account. Either `id` or `name` must be provided, but not both.
1 change: 1 addition & 0 deletions docs/data-sources/cloudaccount_tencent.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ description: |-

### Optional

- `context` (String) The context of the cluster. Allowed values are `project` or `tenant` or ``.
- `id` (String) The unique ID of the Tencent cloud account. Either `id` or `name` must be provided, but not both.
- `name` (String) The name of the Tencent cloud account. Either `id` or `name` must be provided, but not both.

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/cloudaccount_vsphere.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ description: |-

### Optional

- `context` (String) The context of the cluster. Allowed values are `project` or `tenant` or ``.
- `id` (String) The unique ID of the vSphere cloud account. Either `id` or `name` must be provided, but not both.
- `name` (String) The name of the vSphere cloud account. Either `id` or `name` must be provided, but not both.
15 changes: 12 additions & 3 deletions docs/data-sources/role.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ description: |-
## Example Usage

```terraform
data "spectrocloud_role" "role1" {
name = "Project Editor"
data "spectrocloud_role" "role" {
name = "Resource Cluster Admin"
# (alternatively)
# id = "5fd0ca727c411c71b55a359c"
# id = "66fbea622947f81fb62294ac"
}
output "role_id" {
value = data.spectrocloud_role.role.id
}
output "role_permissions" {
value = data.spectrocloud_role.role.permissions
}
```

Expand All @@ -31,3 +39,4 @@ data "spectrocloud_role" "role1" {
### Read-Only

- `id` (String) The ID of this resource.
- `permissions` (Set of String) List of permissions associated with the role.
42 changes: 42 additions & 0 deletions docs/data-sources/team.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "spectrocloud_team Data Source - terraform-provider-spectrocloud"
subcategory: ""
description: |-
---

# spectrocloud_team (Data Source)



## Example Usage

```terraform
data "spectrocloud_team" "team1" {
name = "team2"
# (alternatively)
# id = "5fd0ca727c411c71b55a359c"
}
output "team-id" {
value = data.spectrocloud_team.team1.id
}
output "team-role-ids" {
value = data.spectrocloud_team.team1.role_ids
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `id` (String) The unique ID of the team. If provided, `name` cannot be used.
- `name` (String) The name of the team. If provided, `id` cannot be used.

### Read-Only

- `role_ids` (List of String) The roles id's assigned to the team.
76 changes: 76 additions & 0 deletions docs/resources/role.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
page_title: "spectrocloud_role Resource - terraform-provider-spectrocloud"
subcategory: ""
description: |-
The role resource allows you to manage roles in Palette.
---

# spectrocloud_role (Resource)

The role resource allows you to manage roles in Palette.

You can learn more about managing roles in Palette by reviewing the [Roles](https://docs.spectrocloud.com/glossary-all/#role) guide.

## Example Usage

```terraform
variable "roles" {
type = list(string)
default = ["Cluster Admin", "Cluster Profile Editor"]
}
# Data source loop to retrieve multiple roles
data "spectrocloud_role" "roles" {
for_each = toset(var.roles)
name = each.key
}
resource "spectrocloud_role" "custom_role" {
name = "Test Cluster Role"
type = "project"
permissions = flatten([for role in data.spectrocloud_role.roles : role.permissions])
}
```

```
### Importing existing role state & config
```hcl
# import existing user example
import {
to = spectrocloud_role.test_role
id = "{roleUID}"
}
# To generate TF configuration.
terraform plan -generate-config-out=test_role.tf
# To import State file
terraform import spectrocloud_role.test_role {roleUID}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name of the role.
- `permissions` (Set of String) The permission's assigned to the role.

### Optional

- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `type` (String) The role type. Allowed values are `project` or `tenant` or `project`

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String)
- `delete` (String)
- `update` (String)
157 changes: 157 additions & 0 deletions docs/resources/user.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
---
page_title: "spectrocloud_user Resource - terraform-provider-spectrocloud"
subcategory: ""
description: |-
Create and manage projects in Palette.
---

# spectrocloud_user (Resource)

Create and manage projects in Palette.

You can learn more about managing users in Palette by reviewing the [Users](https://docs.spectrocloud.com/user-management/) guide.

## Example Usage

An example of creating a user resource with assigned teams and custom roles in Palette.

```hcl
resource "spectrocloud_user" "user-test"{
first_name = "tf"
last_name = "test"
email = "[email protected]"
team_ids = [data.spectrocloud_team.team2.id]
project_role {
project_id = data.spectrocloud_project.default.id
role_ids = [for r in data.spectrocloud_role.app_roles : r.id]
}
project_role {
project_id = data.spectrocloud_project.ranjith.id
role_ids = [for r in data.spectrocloud_role.app_roles : r.id]
}
tenant_role = [for t in data.spectrocloud_role.tenant_roles : t.id]
workspace_role {
project_id = data.spectrocloud_project.default.id
workspace {
id = data.spectrocloud_workspace.workspace.id
role_ids = [for w in data.spectrocloud_role.workspace_roles : w.id]
}
workspace {
id = data.spectrocloud_workspace.workspace2.id
role_ids = ["66fbea622947f81fc26983e6"]
}
}
resource_role {
project_ids = [data.spectrocloud_project.default.id, data.spectrocloud_project.ranjith.id]
filter_ids = [data.spectrocloud_filter.filter.id]
role_ids = [for r in data.spectrocloud_role.resource_roles : r.id]
}
resource_role {
project_ids = [data.spectrocloud_project.ranjith.id]
filter_ids = [data.spectrocloud_filter.filter.id]
role_ids = [for re in data.spectrocloud_role.resource_roles_editor : re.id]
}
}
```

The example below demonstrates how to create an user with only assigned teams.

```hcl
resource "spectrocloud_user" "user-test"{
first_name = "tf"
last_name = "test"
email = "[email protected]"
team_ids = [data.spectrocloud_team.team2.id]
}
```

### Importing existing user states

```hcl
# import existing user example
import {
to = spectrocloud_user.test_user
id = "{userUID}"
}
# To generate TF configuration.
terraform plan -generate-config-out=test_user.tf
# To import State file
terraform import spectrocloud_user.test_user {userUID}
```


<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `email` (String) The email of the user.
- `first_name` (String) The first name of the user.
- `last_name` (String) The last name of the user.

### Optional

- `project_role` (Block Set) List of project roles to be associated with the user. (see [below for nested schema](#nestedblock--project_role))
- `resource_role` (Block Set) (see [below for nested schema](#nestedblock--resource_role))
- `team_ids` (List of String) The team id's assigned to the user.
- `tenant_role` (Set of String) List of tenant role ids to be associated with the user.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `workspace_role` (Block Set) List of workspace roles to be associated with the user. (see [below for nested schema](#nestedblock--workspace_role))

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--project_role"></a>
### Nested Schema for `project_role`

Required:

- `project_id` (String) Project id to be associated with the user.
- `role_ids` (Set of String) List of project role ids to be associated with the user.


<a id="nestedblock--resource_role"></a>
### Nested Schema for `resource_role`

Required:

- `filter_ids` (Set of String) List of filter ids.
- `project_ids` (Set of String) Project id's to be associated with the user.
- `role_ids` (Set of String) List of resource role ids to be associated with the user.


<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String)
- `delete` (String)
- `update` (String)


<a id="nestedblock--workspace_role"></a>
### Nested Schema for `workspace_role`

Required:

- `project_id` (String) Project id to be associated with the user.
- `workspace` (Block Set, Min: 1) List of workspace roles to be associated with the user. (see [below for nested schema](#nestedblock--workspace_role--workspace))

<a id="nestedblock--workspace_role--workspace"></a>
### Nested Schema for `workspace_role.workspace`

Required:

- `id` (String) Workspace id to be associated with the user.
- `role_ids` (Set of String) List of workspace role ids to be associated with the user.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
data "spectrocloud_cloudaccount_aws" "aws_account" {
# id = <uid>
name = "ran-tf"
# context = "tenant"
}

output "aws_account" {
value = data.spectrocloud_cloudaccount_aws.aws_account
}
18 changes: 18 additions & 0 deletions examples/data-sources/spectrocloud_cloud_account/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
terraform {
required_providers {
spectrocloud = {
version = ">= 0.13.2"
source = "spectrocloud/spectrocloud"
}
}
}

variable "sc_host" {}
variable "sc_api_key" {}
variable "sc_project_name" {}

provider "spectrocloud" {
host = var.sc_host
api_key = var.sc_api_key
project_name = var.sc_project_name
}
Loading

0 comments on commit 562f443

Please sign in to comment.