Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v17] Add dynamic Windows desktops to terraform provider #49077

Merged
merged 8 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The Teleport Terraform provider supports the following data-sources:
- [`teleport_cluster_maintenance_config`](./cluster_maintenance_config.mdx)
- [`teleport_cluster_networking_config`](./cluster_networking_config.mdx)
- [`teleport_database`](./database.mdx)
- [`teleport_dynamic_windows_desktop`](./dynamic_windows_desktop.mdx)
- [`teleport_github_connector`](./github_connector.mdx)
- [`teleport_installer`](./installer.mdx)
- [`teleport_login_rule`](./login_rule.mdx)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: Reference for the teleport_dynamic_windows_desktop Terraform data-source
description: This page describes the supported values of the teleport_dynamic_windows_desktop data-source of the Teleport Terraform provider.
---

{/*Auto-generated file. Do not edit.*/}
{/*To regenerate, navigate to integrations/terraform and run `make docs`.*/}





{/* schema generated by tfplugindocs */}
## Schema

### Required

- `spec` (Attributes) Spec is the DynamicWindows host spec. (see [below for nested schema](#nested-schema-for-spec))
- `version` (String) Version is the API version used to create the resource. It must be specified. Based on this version, Teleport will apply different defaults on resource creation or deletion. It must be an integer prefixed by "v". For example: `v1`

### Optional

- `metadata` (Attributes) Metadata is resource metadata (see [below for nested schema](#nested-schema-for-metadata))
- `sub_kind` (String) SubKind is an optional resource sub kind, used in some resources

### Nested Schema for `spec`

Required:

- `addr` (String) Addr is the address that this host can be reached at.

Optional:

- `domain` (String) Domain is the ActiveDirectory domain that this host belongs to.
- `non_ad` (Boolean) NonAD marks this desktop as a standalone host that is not joined to an Active Directory domain.
- `screen_size` (Attributes) ScreenSize specifies the size of the screen to use for sessions on this host. In most cases this should be unspecified, in which case Teleport will fill the browser window. (see [below for nested schema](#nested-schema-for-specscreen_size))

### Nested Schema for `spec.screen_size`

Optional:

- `height` (Number)
- `width` (Number)



### Nested Schema for `metadata`

Required:

- `name` (String) Name is an object name

Optional:

- `description` (String) Description is object description
- `expires` (String) Expires is a global expiry time header can be set on any resource in the system.
- `labels` (Map of String) Labels is a set of labels

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: Reference for the teleport_dynamic_windows_desktop Terraform resource
description: This page describes the supported values of the teleport_dynamic_windows_desktop resource of the Teleport Terraform provider.
---

{/*Auto-generated file. Do not edit.*/}
{/*To regenerate, navigate to integrations/terraform and run `make docs`.*/}



## Example Usage

```hcl
resource "teleport_dynamic_windows_desktop" "example" {
version = "v1"
metadata = {
name = "example"
description = "Test Windows desktop"
labels = {
"teleport.dev/origin" = "dynamic" // This label is added on Teleport side by default
}
}

spec = {
addr = "some.host.com"
non_ad = true
domain = "my.domain"
screen_size = {
width = 800
height = 600
}
}
}
```

{/* schema generated by tfplugindocs */}
## Schema

### Required

- `spec` (Attributes) Spec is the DynamicWindows host spec. (see [below for nested schema](#nested-schema-for-spec))
- `version` (String) Version is the API version used to create the resource. It must be specified. Based on this version, Teleport will apply different defaults on resource creation or deletion. It must be an integer prefixed by "v". For example: `v1`

### Optional

- `metadata` (Attributes) Metadata is resource metadata (see [below for nested schema](#nested-schema-for-metadata))
- `sub_kind` (String) SubKind is an optional resource sub kind, used in some resources

### Nested Schema for `spec`

Required:

- `addr` (String) Addr is the address that this host can be reached at.

Optional:

- `domain` (String) Domain is the ActiveDirectory domain that this host belongs to.
- `non_ad` (Boolean) NonAD marks this desktop as a standalone host that is not joined to an Active Directory domain.
- `screen_size` (Attributes) ScreenSize specifies the size of the screen to use for sessions on this host. In most cases this should be unspecified, in which case Teleport will fill the browser window. (see [below for nested schema](#nested-schema-for-specscreen_size))

### Nested Schema for `spec.screen_size`

Optional:

- `height` (Number)
- `width` (Number)



### Nested Schema for `metadata`

Required:

- `name` (String) Name is an object name

Optional:

- `description` (String) Description is object description
- `expires` (String) Expires is a global expiry time header can be set on any resource in the system.
- `labels` (Map of String) Labels is a set of labels

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The Teleport Terraform provider supports the following resources:
- [`teleport_cluster_maintenance_config`](./cluster_maintenance_config.mdx)
- [`teleport_cluster_networking_config`](./cluster_networking_config.mdx)
- [`teleport_database`](./database.mdx)
- [`teleport_dynamic_windows_desktop`](./dynamic_windows_desktop.mdx)
- [`teleport_github_connector`](./github_connector.mdx)
- [`teleport_installer`](./installer.mdx)
- [`teleport_login_rule`](./login_rule.mdx)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "teleport_dynamic_windows_desktop" "example" {
version = "v1"
metadata = {
name = "example"
description = "Test Windows desktop"
labels = {
"teleport.dev/origin" = "dynamic" // This label is added on Teleport side by default
}
}

spec = {
addr = "some.host.com"
non_ad = true
domain = "my.domain"
screen_size = {
width = 800
height = 600
}
}
}
19 changes: 19 additions & 0 deletions integrations/terraform/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,23 @@ var (
HasCheckAndSetDefaults: true,
}

dynamicWindowsDesktop = payload{
Name: "DynamicWindowsDesktop",
TypeName: "DynamicWindowsDesktopV1",
VarName: "desktop",
IfaceName: "DynamicWindowsDesktop",
GetMethod: "DynamicDesktopClient().GetDynamicWindowsDesktop",
CreateMethod: "DynamicDesktopClient().CreateDynamicWindowsDesktop",
UpdateMethod: "DynamicDesktopClient().UpdateDynamicWindowsDesktop",
DeleteMethod: "DynamicDesktopClient().DeleteDynamicWindowsDesktop",
UpsertMethodArity: 2,
ID: `desktop.Metadata.Name`,
Kind: "dynamic_windows_desktop",
HasStaticID: false,
TerraformResourceType: "teleport_dynamic_windows_desktop",
HasCheckAndSetDefaults: true,
}

githubConnector = payload{
Name: "GithubConnector",
TypeName: "GithubConnectorV3",
Expand Down Expand Up @@ -519,6 +536,8 @@ func genTFSchema() {
generateDataSource(clusterNetworking, singularDataSource)
generateResource(database, pluralResource)
generateDataSource(database, pluralDataSource)
generateResource(dynamicWindowsDesktop, pluralResource)
generateDataSource(dynamicWindowsDesktop, pluralDataSource)
generateResource(githubConnector, pluralResource)
generateDataSource(githubConnector, pluralDataSource)
generateResource(oidcConnector, pluralResource)
Expand Down
27 changes: 23 additions & 4 deletions integrations/terraform/protoc-gen-terraform-teleport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ types:
- "TrustedClusterV2"
- "UserV2"
- "InstallerV1"
- "DynamicWindowsDesktopV1"

# id field is required for integration tests. It is not used by provider.
# We have to add it manually (might be removed in the future versions).
Expand Down Expand Up @@ -130,6 +131,13 @@ injected_fields:
computed: true
plan_modifiers:
- "github.com/hashicorp/terraform-plugin-framework/tfsdk.UseStateForUnknown()"
DynamicWindowsDesktopV1:
-
name: id
type: github.com/hashicorp/terraform-plugin-framework/types.StringType
computed: true
plan_modifiers:
- "github.com/hashicorp/terraform-plugin-framework/tfsdk.UseStateForUnknown()"

# These fields will be excluded
exclude_fields:
Expand Down Expand Up @@ -173,7 +181,7 @@ computed_fields:

# App
- "AppV3.Metadata.Labels"
- "AppV3.Kind"
- "AppV3.Kind"

# Auth preference
- "AuthPreferenceV2.Spec.SecondFactor"
Expand Down Expand Up @@ -214,15 +222,15 @@ computed_fields:
# Computed is often used to represent values that are not user configurable or can not be known at time of terraform plan or apply,
#------------------------------------
# role_test.go:244: Step 1/8 error: Error running apply: exit status 1
#
#
# Error: Provider produced inconsistent result after apply
#
#
# When applying changes to teleport_role.upgrade, provider
# "provider[\"registry.terraform.io/hashicorp/teleport\"]" produced an
# unexpected new value: .spec.allow.kubernetes_resources: was null, but now
# cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"kind":cty.StringVal("pod"),
# "name":cty.StringVal("*"), "namespace":cty.StringVal("*")})}).
#
#
# This is a bug in the provider, which should be reported in the provider's own
# issue tracker.
#------------------------------------
Expand Down Expand Up @@ -276,6 +284,9 @@ computed_fields:
# Installer
- "InstallerV1.Kind"

# DynamicWindowsDesktop
- "DynamicWindowsDesktopV1.Kind"

# These fields will be marked as Required: true
required_fields:
# App
Expand Down Expand Up @@ -343,6 +354,12 @@ required_fields:
- "InstallerV1.Metadata.Name"
- "InstallerV1.Version"

# DynamicWindowsDesktop
- "DynamicWindowsDesktopV1.Spec"
- "DynamicWindowsDesktopV1.Spec.Addr"
- "DynamicWindowsDesktopV1.Metadata.Name"
- "DynamicWindowsDesktopV1.Version"

# These fields must be marked as sensitive
sensitive_fields:
- "SAMLConnectorV2.Spec.Cert"
Expand Down Expand Up @@ -413,6 +430,8 @@ validators:
- UseVersionBetween(1,1)
InstallerV1.Version:
- UseVersionBetween(1,1)
DynamicWindowsDesktopV1.Version:
- UseVersionBetween(1,1)

time_type:
type: "TimeType"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions integrations/terraform/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ func (p *Provider) GetResources(_ context.Context) (map[string]tfsdk.ResourceTyp
"teleport_cluster_maintenance_config": resourceTeleportClusterMaintenanceConfigType{},
"teleport_cluster_networking_config": resourceTeleportClusterNetworkingConfigType{},
"teleport_database": resourceTeleportDatabaseType{},
"teleport_dynamic_windows_desktop": resourceTeleportDynamicWindowsDesktopType{},
"teleport_github_connector": resourceTeleportGithubConnectorType{},
"teleport_provision_token": resourceTeleportProvisionTokenType{},
"teleport_oidc_connector": resourceTeleportOIDCConnectorType{},
Expand Down Expand Up @@ -514,6 +515,7 @@ func (p *Provider) GetDataSources(_ context.Context) (map[string]tfsdk.DataSourc
"teleport_cluster_maintenance_config": dataSourceTeleportClusterMaintenanceConfigType{},
"teleport_cluster_networking_config": dataSourceTeleportClusterNetworkingConfigType{},
"teleport_database": dataSourceTeleportDatabaseType{},
"teleport_dynamic_windows_desktop": dataSourceTeleportDynamicWindowsDesktopType{},
"teleport_github_connector": dataSourceTeleportGithubConnectorType{},
"teleport_provision_token": dataSourceTeleportProvisionTokenType{},
"teleport_oidc_connector": dataSourceTeleportOIDCConnectorType{},
Expand Down
Loading
Loading