diff --git a/docs/pages/reference/terraform-provider/data-sources/static_host_user.mdx b/docs/pages/reference/terraform-provider/data-sources/static_host_user.mdx index b3bf7d24c2a3b..99219be614718 100644 --- a/docs/pages/reference/terraform-provider/data-sources/static_host_user.mdx +++ b/docs/pages/reference/terraform-provider/data-sources/static_host_user.mdx @@ -52,6 +52,7 @@ Optional: - `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` diff --git a/docs/pages/reference/terraform-provider/resources/static_host_user.mdx b/docs/pages/reference/terraform-provider/resources/static_host_user.mdx index 5135e050ee35d..00cebadd20e08 100644 --- a/docs/pages/reference/terraform-provider/resources/static_host_user.mdx +++ b/docs/pages/reference/terraform-provider/resources/static_host_user.mdx @@ -79,6 +79,7 @@ Optional: - `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` diff --git a/integrations/terraform/tfschema/userprovisioning/v2/statichostuser_terraform.go b/integrations/terraform/tfschema/userprovisioning/v2/statichostuser_terraform.go index 5260578c3986b..e327611eb1849 100644 --- a/integrations/terraform/tfschema/userprovisioning/v2/statichostuser_terraform.go +++ b/integrations/terraform/tfschema/userprovisioning/v2/statichostuser_terraform.go @@ -137,6 +137,11 @@ func GenSchemaStaticHostUser(ctx context.Context) (github_com_hashicorp_terrafor Optional: true, Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, }, + "take_ownership_if_user_exists": { + Description: "take_ownership_if_user_exists will take ownership of existing, unmanaged users", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.BoolType, + }, "uid": { Description: "uid is the new user's uid.", Optional: true, @@ -566,6 +571,23 @@ func CopyStaticHostUserFromTerraform(_ context.Context, tf github_com_hashicorp_ } } } + { + a, ok := tf.Attrs["take_ownership_if_user_exists"] + if !ok { + diags.Append(attrReadMissingDiag{"StaticHostUser.spec.matchers.take_ownership_if_user_exists"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Bool) + if !ok { + diags.Append(attrReadConversionFailureDiag{"StaticHostUser.spec.matchers.take_ownership_if_user_exists", "github.com/hashicorp/terraform-plugin-framework/types.Bool"}) + } else { + var t bool + if !v.Null && !v.Unknown { + t = bool(v.Value) + } + obj.TakeOwnershipIfUserExists = t + } + } + } } obj.Matchers[k] = t } @@ -1232,6 +1254,28 @@ func CopyStaticHostUserToTerraform(ctx context.Context, obj *github_com_gravitat tf.Attrs["default_shell"] = v } } + { + t, ok := tf.AttrTypes["take_ownership_if_user_exists"] + if !ok { + diags.Append(attrWriteMissingDiag{"StaticHostUser.spec.matchers.take_ownership_if_user_exists"}) + } else { + v, ok := tf.Attrs["take_ownership_if_user_exists"].(github_com_hashicorp_terraform_plugin_framework_types.Bool) + if !ok { + i, err := t.ValueFromTerraform(ctx, github_com_hashicorp_terraform_plugin_go_tftypes.NewValue(t.TerraformType(ctx), nil)) + if err != nil { + diags.Append(attrWriteGeneralError{"StaticHostUser.spec.matchers.take_ownership_if_user_exists", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.Bool) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"StaticHostUser.spec.matchers.take_ownership_if_user_exists", "github.com/hashicorp/terraform-plugin-framework/types.Bool"}) + } + v.Null = bool(obj.TakeOwnershipIfUserExists) == false + } + v.Value = bool(obj.TakeOwnershipIfUserExists) + v.Unknown = false + tf.Attrs["take_ownership_if_user_exists"] = v + } + } } v.Unknown = false c.Elems[k] = v