-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change adds Terraform support for static host users.
- Loading branch information
Showing
17 changed files
with
2,310 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
docs/pages/reference/terraform-provider/data-sources/static_host_user.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: Reference for the teleport_static_host_user Terraform data-source | ||
description: This page describes the supported values of the teleport_static_host_user 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 | ||
|
||
- `metadata` (Attributes) metadata is resource metadata. (see [below for nested schema](#nested-schema-for-metadata)) | ||
- `spec` (Attributes) spec is the static host user spec. (see [below for nested schema](#nested-schema-for-spec)) | ||
- `version` (String) version is the resource version. It must be specified. Supported values are: `v2`. | ||
|
||
### Optional | ||
|
||
- `sub_kind` (String) sub_kind is an optional resource sub kind, used in some resources. | ||
|
||
### Nested Schema for `metadata` | ||
|
||
Required: | ||
|
||
- `name` (String) name is an object name. | ||
|
||
Optional: | ||
|
||
- `description` (String) description is object description. | ||
- `expires` (String) | ||
- `labels` (Map of String) labels is a set of labels. | ||
|
||
|
||
### Nested Schema for `spec` | ||
|
||
Required: | ||
|
||
- `matchers` (Attributes List) (see [below for nested schema](#nested-schema-for-specmatchers)) | ||
|
||
### Nested Schema for `spec.matchers` | ||
|
||
Optional: | ||
|
||
- `default_shell` (String) default_shell is the new user's default shell | ||
- `gid` (Number) gid is the new user's gid. | ||
- `groups` (List of String) groups is a list of additional groups to add the user to. | ||
- `node_labels` (Attributes List) node_labels is a map of node labels that will create a user from this resource. (see [below for nested schema](#nested-schema-for-specmatchersnode_labels)) | ||
- `node_labels_expression` (String) node_labels_expression is a predicate expression to create a user from this resource. | ||
- `sudoers` (List of String) sudoers is a list of sudoer entries to add. | ||
- `take_ownership_if_user_exists` (Boolean) take_ownership_if_user_exists will take ownership of existing, unmanaged users | ||
- `uid` (Number) uid is the new user's uid. | ||
|
||
### Nested Schema for `spec.matchers.node_labels` | ||
|
||
Required: | ||
|
||
- `name` (String) The name of the label. | ||
- `values` (List of String) The values associated with the label. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
docs/pages/reference/terraform-provider/resources/static_host_user.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
title: Reference for the teleport_static_host_user Terraform resource | ||
description: This page describes the supported values of the teleport_static_host_user 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_static_host_user" "test" { | ||
version = "v2" | ||
metadata = { | ||
name = "test" | ||
} | ||
spec = { | ||
matchers = [ | ||
{ | ||
node_labels = [ | ||
{ | ||
name = "foo" | ||
values = ["bar"] | ||
} | ||
] | ||
node_labels_expression = "labels.foo == \"bar\"" | ||
groups = ["foo", "bar"] | ||
sudoers = ["abcd1234"] | ||
uid = 1234 | ||
gid = 1234 | ||
default_shell = "/bin/bash" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
{/* schema generated by tfplugindocs */} | ||
## Schema | ||
|
||
### Required | ||
|
||
- `metadata` (Attributes) metadata is resource metadata. (see [below for nested schema](#nested-schema-for-metadata)) | ||
- `spec` (Attributes) spec is the static host user spec. (see [below for nested schema](#nested-schema-for-spec)) | ||
- `version` (String) version is the resource version. It must be specified. Supported values are: `v2`. | ||
|
||
### Optional | ||
|
||
- `sub_kind` (String) sub_kind is an optional resource sub kind, used in some resources. | ||
|
||
### Nested Schema for `metadata` | ||
|
||
Required: | ||
|
||
- `name` (String) name is an object name. | ||
|
||
Optional: | ||
|
||
- `description` (String) description is object description. | ||
- `expires` (String) | ||
- `labels` (Map of String) labels is a set of labels. | ||
|
||
|
||
### Nested Schema for `spec` | ||
|
||
Required: | ||
|
||
- `matchers` (Attributes List) (see [below for nested schema](#nested-schema-for-specmatchers)) | ||
|
||
### Nested Schema for `spec.matchers` | ||
|
||
Optional: | ||
|
||
- `default_shell` (String) default_shell is the new user's default shell | ||
- `gid` (Number) gid is the new user's gid. | ||
- `groups` (List of String) groups is a list of additional groups to add the user to. | ||
- `node_labels` (Attributes List) node_labels is a map of node labels that will create a user from this resource. (see [below for nested schema](#nested-schema-for-specmatchersnode_labels)) | ||
- `node_labels_expression` (String) node_labels_expression is a predicate expression to create a user from this resource. | ||
- `sudoers` (List of String) sudoers is a list of sudoer entries to add. | ||
- `take_ownership_if_user_exists` (Boolean) take_ownership_if_user_exists will take ownership of existing, unmanaged users | ||
- `uid` (Number) uid is the new user's uid. | ||
|
||
### Nested Schema for `spec.matchers.node_labels` | ||
|
||
Required: | ||
|
||
- `name` (String) The name of the label. | ||
- `values` (List of String) The values associated with the label. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
integrations/terraform/examples/resources/teleport_static_host_user/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
resource "teleport_static_host_user" "test" { | ||
version = "v2" | ||
metadata = { | ||
name = "test" | ||
} | ||
spec = { | ||
matchers = [ | ||
{ | ||
node_labels = [ | ||
{ | ||
name = "foo" | ||
values = ["bar"] | ||
} | ||
] | ||
node_labels_expression = "labels.foo == \"bar\"" | ||
groups = ["foo", "bar"] | ||
sudoers = ["abcd1234"] | ||
uid = 1234 | ||
gid = 1234 | ||
default_shell = "/bin/bash" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
integrations/terraform/protoc-gen-terraform-statichostuser.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
target_package_name: "v2" | ||
default_package_name: "github.com/gravitational/teleport/api/gen/proto/go/teleport/userprovisioning/v2" | ||
duration_custom_type: Duration | ||
use_state_for_unknown_by_default: true | ||
|
||
# Top-level type names to export | ||
types: | ||
- "StaticHostUser" | ||
|
||
# These import paths were not being automatically picked up by | ||
# protoc-gen-terraform without these overrides | ||
import_path_overrides: | ||
"types": "github.com/gravitational/teleport/api/types" | ||
"wrappers": "github.com/gravitational/teleport/api/types/wrappers" | ||
"durationpb": "google.golang.org/protobuf/types/known/durationpb" | ||
"timestamppb": "google.golang.org/protobuf/types/known/timestamppb" | ||
"v1": "github.com/gravitational/teleport/api/gen/proto/go/teleport/header/v1" | ||
"v11": "github.com/gravitational/teleport/api/gen/proto/go/teleport/label/v1" | ||
|
||
|
||
# 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). | ||
injected_fields: | ||
StaticHostUser: | ||
- 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: | ||
# Metadata (we id resources by name on our side) | ||
- "StaticHostUser.metadata.id" | ||
|
||
# These fields will be marked as Computed: true | ||
computed_fields: | ||
# Metadata | ||
- "StaticHostUser.metadata.namespace" | ||
- "StaticHostUser.kind" | ||
|
||
# These fields will be marked as Required: true | ||
required_fields: | ||
- "StaticHostUser.version" | ||
- "StaticHostUser.metadata" | ||
- "StaticHostUser.metadata.name" | ||
- "StaticHostUser.spec" | ||
- "StaticHostUser.spec.matchers" | ||
- "StaticHostUser.spec.matchers.node_labels.name" | ||
- "StaticHostUser.spec.matchers.node_labels.values" | ||
|
||
plan_modifiers: | ||
# Force to recreate resource if it's name changes | ||
Metadata.name: | ||
- "github.com/hashicorp/terraform-plugin-framework/tfsdk.RequiresReplace()" | ||
|
||
# This must be defined for the generator to be happy, but in reality all time | ||
# fields are overridden (because the protobuf timestamps contain locks and the | ||
# linter gets mad if we use raw structs instead of pointers). | ||
time_type: | ||
type: "PlaceholderType" | ||
duration_type: | ||
type: "PlaceholderType" | ||
|
||
validators: | ||
# Expires must be in the future | ||
Metadata.expires: | ||
- github_com_gravitational_teleport_integrations_terraform_tfschema.MustTimeBeInFuture() | ||
|
||
custom_types: | ||
"StaticHostUser.metadata.expires": Timestamp |
Oops, something went wrong.