Skip to content

Commit

Permalink
IAC-1124: add iacm workspaces (#726)
Browse files Browse the repository at this point in the history
* IAC-1124: iac resources

* IAC-1124: update go sdk version

* IAC-1124: add resources to provider.go

* IAC-1124: changelog

* IAC-1124: add docs sub category

* IAC-1124: fix docs and changelog

* IAC-1124: fix change log

* IAC-1124: better error handling
  • Loading branch information
dwarren-dev committed Nov 8, 2023
1 parent dc2bfc2 commit 4f99a30
Show file tree
Hide file tree
Showing 17 changed files with 1,462 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changelog/726.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```release-note:new-resource
harness_platform_workspace - added a new resource for iacm workspaces
harness_platform_workspace - added a new data source for iacm workspaces
harness_platform_workspace_output - added a new data source for iacm workspace outputs
```
82 changes: 82 additions & 0 deletions docs/data-sources/platform_workspace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "harness_platform_workspace Data Source - terraform-provider-harness"
subcategory: "Next Gen"
description: |-
Data source for retrieving workspaces.
---

# harness_platform_workspace (Data Source)

Data source for retrieving workspaces.

## Example Usage

```terraform
data "harness_platform_workspace" "test" {
identifier = "identifier"
org_id = "org_id"
project_id = "project_id"
}
```

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

### Required

- `identifier` (String) Identifier of the Workspace
- `org_id` (String) Organization Identifier
- `project_id` (String) Project Identifier

### Optional

- `description` (String) Description of the Workspace
- `repository_branch` (String) Repository Branch in which the code should be accessed
- `repository_commit` (String) Repository Commit/Tag in which the code should be accessed

### Read-Only

- `cost_estimation_enabled` (Boolean) If enabled cost estimation operations will be performed in this workspace
- `environment_variable` (Block Set) Environment variables configured on the workspace (see [below for nested schema](#nestedblock--environment_variable))
- `id` (String) The ID of this resource.
- `name` (String) Name of the Workspace
- `provider_connector` (String) Provider Connector is the reference to the connector for the infrastructure provider
- `provisioner_type` (String) Provisioner type defines the provisioning tool to use.
- `provisioner_version` (String) Provisioner Version defines the tool version to use
- `repository` (String) Repository is the name of the repository to use
- `repository_connector` (String) Repository Connector is the reference to the connector to use for this code
- `repository_path` (String) Repository Path is the path in which the infra code resides
- `terraform_variable` (Block Set) Terraform variables configured on the workspace (see [below for nested schema](#nestedblock--terraform_variable))
- `terraform_variable_file` (Block Set) Terraform variables files configured on the workspace (see [below for nested schema](#nestedblock--terraform_variable_file))

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

Read-Only:

- `key` (String) Key is the identifier for the variable`
- `value` (String) value is the value of the variable
- `value_type` (String) Value type indicates the value type of the variable, text or secret


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

Read-Only:

- `key` (String) Key is the identifier for the variable`
- `value` (String) value is the value of the variable
- `value_type` (String) Value type indicates the value type of the variable, text or secret


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

Read-Only:

- `repository` (String) Repository is the name of the repository to use
- `repository_branch` (String) Repository Branch in which the code should be accessed
- `repository_commit` (String) Repository Commit/Tag in which the code should be accessed
- `repository_connector` (String) Repository Connector is the reference to the connector to use for this code
- `repository_path` (String) Repository Commit/Tag in which the code should be accessed
44 changes: 44 additions & 0 deletions docs/data-sources/platform_workspace_output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "harness_platform_workspace_output Data Source - terraform-provider-harness"
subcategory: "Next Gen"
description: |-
Data source for retrieving workspace outputs.
---

# harness_platform_workspace_output (Data Source)

Data source for retrieving workspace outputs.

## Example Usage

```terraform
data "harness_platform_workspace_output" "test" {
identifier = "identifier"
org_id = "org_id"
project_id = "project_id"
}
```

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

### Required

- `identifier` (String) Identifier of the Workspace.
- `org_id` (String) Organization identifier of the organization the workspace resides in.
- `project_id` (String) Project identifier of the project the workspace resides in.

### Read-Only

- `id` (String) The ID of this resource.
- `outputs` (List of Object) (see [below for nested schema](#nestedatt--outputs))

<a id="nestedatt--outputs"></a>
### Nested Schema for `outputs`

Read-Only:

- `name` (String)
- `sensitive` (Boolean)
- `value` (String)
139 changes: 139 additions & 0 deletions docs/resources/platform_workspace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "harness_platform_workspace Resource - terraform-provider-harness"
subcategory: "Next Gen"
description: |-
Resource for managing Workspaces
---

# harness_platform_workspace (Resource)

Resource for managing Workspaces

## Example Usage

```terraform
resource "harness_platform_workspace" "example" {
name = "example"
identifier = "example"
org_id = "org_id"
project_id = "project_id"
provisioner = "terraform"
provisioner_version = "1.5.6"
repository = "https://github.com/org/repo"
repository_branch = "main"
repository_commit = "349d90bb9c90f4a3482981c259080de31609e6f6"
repository_path = "tf/aws/basic"
cost_estimation_enabled = true
provider_connector = "account.connector"
repository_connector = "account.connector"
terraform_variable {
key = "key1"
value = "val1"
value_type = "string"
}
terraform_variable {
key = "key2"
value = "val2"
value_type = "string"
}
environment_variable {
key = "key1"
value = "val1"
value_type = "string"
}
environment_variable {
key = "key2"
value = "val2"
value_type = "string"
}
terraform_variable_file {
repository = "https://github.com/org/repo"
repository_branch = "main"
repository_path = "tf/gcp/basic"
repository_connector = "account.connector"
}
terraform_variable_file {
repository = "https://github.com/org/repo"
repository_branch = "main"
repository_path = "tf/aws/basic"
repository_connector = "account.connector"
}
}
```

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

### Required

- `cost_estimation_enabled` (Boolean) Cost estimation enabled determines if cost estimation operations are performed.
- `identifier` (String) Unique identifier of the resource.
- `name` (String) Name of the resource.
- `org_id` (String) Unique identifier of the organization.
- `project_id` (String) Unique identifier of the project.
- `provider_connector` (String) Provider connector is the reference to the connector for the infrastructure provider
- `provisioner_type` (String) Provisioner type defines the provisioning tool to use. Currently only terraform is supported.
- `provisioner_version` (String) Provisioner version defines the tool version to use. Currently we support versions of terraform less than or equal 1.5.6
- `repository` (String) Repository is the name of the repository to fetch the code from.
- `repository_connector` (String) Repository connector is the reference to the connector used to fetch the code.
- `repository_path` (String) Repository path is the path in which the code resides.

### Optional

- `description` (String) Description of the resource.
- `environment_variable` (Block Set) Environment variables configured on the workspace (see [below for nested schema](#nestedblock--environment_variable))
- `repository_branch` (String) Repository branch is the name of the branch to fetch the code from. This cannot be set if repository commit is set.
- `repository_commit` (String) Repository commit is commit or tag to fetch the code from. This cannot be set if repository branch is set.
- `tags` (Set of String) Tags to associate with the resource.
- `terraform_variable` (Block Set) Terraform variables configured on the workspace. Terraform variable keys must be unique within the workspace. (see [below for nested schema](#nestedblock--terraform_variable))
- `terraform_variable_file` (Block Set) Terraform variables files configured on the workspace (see [below for nested schema](#nestedblock--terraform_variable_file))

### Read-Only

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

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

Required:

- `key` (String) Key is the identifier for the variable. Must be unique within the workspace.
- `value` (String) Value is the value of the variable. For string value types this field should contain the value of the variable. For secret value types this should contain a reference to a valid harness secret.
- `value_type` (String) Value type indicates the value type of the variable. Currently we support string and secret.


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

Required:

- `key` (String) Key is the identifier for the variable. Must be unique within the workspace.
- `value` (String) Value is the value of the variable. For string value types this field should contain the value of the variable. For secret value types this should contain a reference to a valid harness secret.
- `value_type` (String) Value type indicates the value type of the variable. Currently we support string and secret.


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

Required:

- `repository` (String) Repository is the name of the repository to fetch the code from.
- `repository_connector` (String) Repository connector is the reference to the connector used to fetch the variables.

Optional:

- `repository_branch` (String) Repository branch is the name of the branch to fetch the variables from. This cannot be set if repository commit is set
- `repository_commit` (String) Repository commit is commit or tag to fetch the variables from. This cannot be set if repository branch is set.
- `repository_path` (String) Repository path is the path in which the variables reside.

## Import

Import is supported using the following syntax:

```shell
terraform import harness_platform_workspace.example <org_id>/<project_id>/<workspace_id>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data "harness_platform_workspace" "test" {
identifier = "identifier"
org_id = "org_id"
project_id = "project_id"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data "harness_platform_workspace_output" "test" {
identifier = "identifier"
org_id = "org_id"
project_id = "project_id"
}
1 change: 1 addition & 0 deletions examples/resources/harness_platform_workspace/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import harness_platform_workspace.example <org_id>/<project_id>/<slo_id>
50 changes: 50 additions & 0 deletions examples/resources/harness_platform_workspace/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
resource "harness_platform_workspace" "example" {
name = "example"
identifier = "example"
org_id = harness_platform_organization.test.id
project_id = harness_platform_project.test.id
provisioner = "terraform"
provisioner_version = "1.5.6"
repository = "https://github.com/org/repo"
repository_branch = "main"
repository_commit = "349d90bb9c90f4a3482981c259080de31609e6f6"
repository_path = "tf/aws/basic"
cost_estimation_enabled = true
provider_connector = harness_platform_connector_github.test.id
repository_connector = harness_platform_connector_github.test.id

terraform_variable {
key = "key1"
value = "val1"
value_type = "string"
}
terraform_variable {
key = "key2"
value = "val2"
value_type = "string"
}

environment_variable {
key = "key1"
value = "val1"
value_type = "string"
}
environment_variable {
key = "key2"
value = "val2"
value_type = "string"
}

terraform_variable_file {
repository = "https://github.com/org/repo"
repository_branch = "main"
repository_path = "tf/gcp/basic"
repository_connector = harness_platform_connector_github.test.id
}
terraform_variable_file {
repository = "https://github.com/org/repo"
repository_branch = "main"
repository_path = "tf/aws/basic"
repository_connector = harness_platform_connector_github.test.id
}
}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ go 1.18

require (
github.com/antihax/optional v1.0.0
github.com/aws/aws-sdk-go v1.45.12
github.com/docker/docker v24.0.6+incompatible
github.com/harness/harness-go-sdk v0.3.57
github.com/aws/aws-sdk-go v1.46.4
github.com/docker/docker v24.0.5+incompatible
github.com/harness/harness-go-sdk v0.3.58
github.com/harness/harness-openapi-go-client v0.0.19
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/aws/aws-sdk-go v1.45.12 h1:+bKbbesGNPp+TeGrcqfrWuZoqcIEhjwKyBMHQPp80Jo=
github.com/aws/aws-sdk-go v1.45.12/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.46.4 h1:48tKgtm9VMPkb6y7HuYlsfhQmoIRAsTEXTsWLVlty4M=
github.com/aws/aws-sdk-go v1.46.4/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
Expand All @@ -23,8 +23,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v24.0.6+incompatible h1:hceabKCtUgDqPu+qm0NgsaXf28Ljf4/pWFL7xjWWDgE=
github.com/docker/docker v24.0.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY=
github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
Expand All @@ -49,8 +49,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/harness/harness-go-sdk v0.3.57 h1:W7cIA8pZ2g/os+YaBYw2goEynUrX060Fmy30FD3LQF0=
github.com/harness/harness-go-sdk v0.3.57/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-go-sdk v0.3.58 h1:urTdoLM3zmsC8o7TgoZ47aU2rlSpRhO/mW+qDalRKe4=
github.com/harness/harness-go-sdk v0.3.58/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-openapi-go-client v0.0.19 h1:8XuZvSPZrNqKRLh7Qksdz78WvRMRzRf88LgzxoT5u7k=
github.com/harness/harness-openapi-go-client v0.0.19/go.mod h1:u0vqYb994BJGotmEwJevF4L3BNAdU9i8ui2d22gmLPA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down
Loading

0 comments on commit 4f99a30

Please sign in to comment.