-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add static host users to Terraform provider #46826
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not related but we should update expires description with the correct format |
||
| - `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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.