diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 4f1ecc4c4e2db..182b1f4e55876 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -274,7 +274,7 @@ jobs: - name: Check if Terraform resources are up to date # We have to add the current directory as a safe directory or else git commands will not work as expected. # The protoc-gen-terraform version must match the version in integrations/terraform/Makefile - run: git config --global --add safe.directory $(realpath .) && go install github.com/gravitational/protoc-gen-terraform/v3@v3.0.2 && make terraform-resources-up-to-date + run: git config --global --add safe.directory $(realpath .) && go install github.com/gravitational/protoc-gen-terraform/v3@v3.0.3 && make terraform-resources-up-to-date - name: Check if the Access Monitoring reference is up to date # We have to add the current directory as a safe directory or else git commands will not work as expected. diff --git a/api/proto/teleport/legacy/types/types.proto b/api/proto/teleport/legacy/types/types.proto index 733a71f504942..3bf04df6a9d78 100644 --- a/api/proto/teleport/legacy/types/types.proto +++ b/api/proto/teleport/legacy/types/types.proto @@ -9042,9 +9042,9 @@ message AWSMatcher { // KubeAppDiscovery controls whether Kubernetes App Discovery will be enabled for agents running on // discovered clusters, currently only affects AWS EKS discovery in integration mode. bool KubeAppDiscovery = 8 [(gogoproto.jsontag) = "kube_app_discovery,omitempty"]; - // SetupAccessForARN is the role that the discovery service should create EKS Access Entries for. + // SetupAccessForARN is the role that the Discovery Service should create EKS Access Entries for. // This value should match the IAM identity that Teleport Kubernetes Service uses. - // If this value is empty, the discovery service will attempt to set up access for its own identity (self). + // If this value is empty, the Discovery Service will attempt to set up access for its own identity (self). string SetupAccessForARN = 9 [(gogoproto.jsontag) = "setup_access_for_arn,omitempty"]; } diff --git a/api/types/types.pb.go b/api/types/types.pb.go index cad40da580f82..7ac9d427734ee 100644 --- a/api/types/types.pb.go +++ b/api/types/types.pb.go @@ -24057,9 +24057,9 @@ type AWSMatcher struct { // KubeAppDiscovery controls whether Kubernetes App Discovery will be enabled for agents running on // discovered clusters, currently only affects AWS EKS discovery in integration mode. KubeAppDiscovery bool `protobuf:"varint,8,opt,name=KubeAppDiscovery,proto3" json:"kube_app_discovery,omitempty"` - // SetupAccessForARN is the role that the discovery service should create EKS Access Entries for. + // SetupAccessForARN is the role that the Discovery Service should create EKS Access Entries for. // This value should match the IAM identity that Teleport Kubernetes Service uses. - // If this value is empty, the discovery service will attempt to set up access for its own identity (self). + // If this value is empty, the Discovery Service will attempt to set up access for its own identity (self). SetupAccessForARN string `protobuf:"bytes,9,opt,name=SetupAccessForARN,proto3" json:"setup_access_for_arn,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` diff --git a/docs/pages/reference/infrastructure-as-code/terraform-provider/data-sources/data-sources.mdx b/docs/pages/reference/infrastructure-as-code/terraform-provider/data-sources/data-sources.mdx index 25060c45de1c6..d1ca161ef83e3 100644 --- a/docs/pages/reference/infrastructure-as-code/terraform-provider/data-sources/data-sources.mdx +++ b/docs/pages/reference/infrastructure-as-code/terraform-provider/data-sources/data-sources.mdx @@ -23,6 +23,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_discovery_config`](./discovery_config.mdx) - [`teleport_dynamic_windows_desktop`](./dynamic_windows_desktop.mdx) - [`teleport_github_connector`](./github_connector.mdx) - [`teleport_health_check_config`](./health_check_config.mdx) diff --git a/docs/pages/reference/infrastructure-as-code/terraform-provider/data-sources/discovery_config.mdx b/docs/pages/reference/infrastructure-as-code/terraform-provider/data-sources/discovery_config.mdx new file mode 100644 index 0000000000000..650d3bb5d2d80 --- /dev/null +++ b/docs/pages/reference/infrastructure-as-code/terraform-provider/data-sources/discovery_config.mdx @@ -0,0 +1,281 @@ +--- +title: Reference for the teleport_discovery_config Terraform data-source +sidebar_label: discovery_config +description: This page describes the supported values of the teleport_discovery_config data-source of the Teleport Terraform provider. +--- + +{/*Auto-generated file. Do not edit.*/} +{/*To regenerate, navigate to integrations/terraform and run `make docs`.*/} + +{/* Disable the outdated name check since data source fields occasionally need +to refer to these. */} +{/* vale 3rd-party-products.former-names = NO */} + +This page describes the supported values of the `teleport_discovery_config` data source of the +Teleport Terraform provider. + + + + + +{/* schema generated by tfplugindocs */} +## Schema + +### Required + +- `header` (Attributes) Header is the resource header. (see [below for nested schema](#nested-schema-for-header)) +- `spec` (Attributes) Spec is an DiscoveryConfig specification. (see [below for nested schema](#nested-schema-for-spec)) + +### Nested Schema for `header` + +Required: + +- `metadata` (Attributes) metadata is resource metadata. (see [below for nested schema](#nested-schema-for-headermetadata)) +- `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: + +- `kind` (String) kind is a resource kind. +- `sub_kind` (String) sub_kind is an optional resource sub kind, used in some resources. + +### Nested Schema for `header.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. +- `namespace` (String) namespace is object namespace. The field should be called "namespace" when it returns in Teleport 2.4. +- `revision` (String) revision is an opaque identifier which tracks the versions of a resource over time. Clients should ignore and not alter its value but must return the revision in any updates of a resource. + + + +### Nested Schema for `spec` + +Optional: + +- `access_graph` (Attributes) AccessGraph is the configurations for syncing Cloud accounts into Access Graph. (see [below for nested schema](#nested-schema-for-specaccess_graph)) +- `aws` (Attributes List) AWS is a list of AWS Matchers. (see [below for nested schema](#nested-schema-for-specaws)) +- `azure` (Attributes List) Azure is a list of Azure Matchers. (see [below for nested schema](#nested-schema-for-specazure)) +- `discovery_group` (String) DiscoveryGroup is used by discovery_service to add extra matchers. All the discovery_services that have the same discovery_group, will load the matchers of this resource. +- `gcp` (Attributes List) GCP is a list of GCP Matchers. (see [below for nested schema](#nested-schema-for-specgcp)) +- `kube` (Attributes List) Kube is a list of Kubernetes Matchers. (see [below for nested schema](#nested-schema-for-speckube)) + +### Nested Schema for `spec.access_graph` + +Optional: + +- `aws` (Attributes List) AWS is a configuration for AWS Access Graph service poll service. (see [below for nested schema](#nested-schema-for-specaccess_graphaws)) +- `azure` (Attributes List) Azure is a configuration for Azure Access Graph service poll service. (see [below for nested schema](#nested-schema-for-specaccess_graphazure)) +- `poll_interval` (String) PollInterval is the frequency at which to poll for resources + +### Nested Schema for `spec.access_graph.aws` + +Optional: + +- `assume_role` (Attributes) AssumeRoleARN is the AWS role to assume for database discovery. (see [below for nested schema](#nested-schema-for-specaccess_graphawsassume_role)) +- `cloud_trail_logs` (Attributes) Configuration settings for collecting AWS CloudTrail logs via an SQS queue. (see [below for nested schema](#nested-schema-for-specaccess_graphawscloud_trail_logs)) +- `eks_audit_logs` (Attributes) (see [below for nested schema](#nested-schema-for-specaccess_graphawseks_audit_logs)) +- `integration` (String) Integration is the integration name used to generate credentials to interact with AWS APIs. +- `regions` (List of String) Regions are AWS regions to import resources from. + +### Nested Schema for `spec.access_graph.aws.assume_role` + +Optional: + +- `external_id` (String) ExternalID is the external ID used to assume a role in another account. +- `role_arn` (String) RoleARN is the fully specified AWS IAM role ARN. + + +### Nested Schema for `spec.access_graph.aws.cloud_trail_logs` + +Optional: + +- `region` (String) The AWS region of the SQS queue for CloudTrail notifications, ex.: "us-east-2". +- `sqs_queue` (String) The name or URL for CloudTrail log events, ex.: "demo-cloudtrail-queue". + + +### Nested Schema for `spec.access_graph.aws.eks_audit_logs` + +Optional: + +- `tags` (Map of List of String) The tags of EKS clusters for which apiserver audit logs should be fetched. + + + +### Nested Schema for `spec.access_graph.azure` + +Optional: + +- `integration` (String) Integration is the integration name used to generate credentials to interact with AWS APIs. +- `subscription_id` (String) SubscriptionID Is the ID of the Azure subscription to sync resources from + + + +### Nested Schema for `spec.aws` + +Optional: + +- `assume_role` (Attributes) AssumeRoleARN is the AWS role to assume for database discovery. (see [below for nested schema](#nested-schema-for-specawsassume_role)) +- `install` (Attributes) Params sets the join method when installing on discovered EC2 nodes (see [below for nested schema](#nested-schema-for-specawsinstall)) +- `integration` (String) Integration is the integration name used to generate credentials to interact with AWS APIs. Environment credentials will not be used when this value is set. +- `kube_app_discovery` (Boolean) KubeAppDiscovery controls whether Kubernetes App Discovery will be enabled for agents running on discovered clusters, currently only affects AWS EKS discovery in integration mode. +- `regions` (List of String) Regions are AWS regions to query for databases. +- `setup_access_for_arn` (String) SetupAccessForARN is the role that the Discovery Service should create EKS Access Entries for. This value should match the IAM identity that Teleport Kubernetes Service uses. If this value is empty, the Discovery Service will attempt to set up access for its own identity (self). +- `ssm` (Attributes) SSM provides options to use when sending a document command to an EC2 node (see [below for nested schema](#nested-schema-for-specawsssm)) +- `tags` (Map of List of String) Tags are AWS resource Tags to match. +- `types` (List of String) Types are AWS database types to match, "ec2", "rds", "redshift", "elasticache", or "memorydb". + +### Nested Schema for `spec.aws.assume_role` + +Optional: + +- `external_id` (String) ExternalID is the external ID used to assume a role in another account. +- `role_arn` (String) RoleARN is the fully specified AWS IAM role ARN. + + +### Nested Schema for `spec.aws.install` + +Optional: + +- `azure` (Attributes) Azure is the set of Azure-specific installation parameters. (see [below for nested schema](#nested-schema-for-specawsinstallazure)) +- `enroll_mode` (Number) EnrollMode indicates the enrollment mode to be used when adding a node. Valid values: 0: uses eice for EC2 matchers which use an integration and script for all the other methods 1: uses script mode 2: uses eice mode (deprecated) +- `http_proxy_settings` (Attributes) HTTPProxySettings defines HTTP proxy settings for making HTTP requests. When set, this will set the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables before running the installation. (see [below for nested schema](#nested-schema-for-specawsinstallhttp_proxy_settings)) +- `install_teleport` (Boolean) InstallTeleport disables agentless discovery +- `join_method` (String) JoinMethod is the method to use when joining the cluster +- `join_token` (String) JoinToken is the token to use when joining the cluster +- `proxy_addr` (String) PublicProxyAddr is the address of the proxy the discovered node should use to connect to the cluster. +- `script_name` (String) ScriptName is the name of the teleport installer script resource for the cloud instance to execute +- `sshd_config` (String) SSHDConfig provides the path to write sshd configuration changes +- `suffix` (String) Suffix indicates the installation suffix for the teleport installation. Set this value if you want multiple installations of Teleport. See --install-suffix flag in teleport-update program. Note: only supported for Amazon EC2. Suffix name can only contain alphanumeric characters and hyphens. +- `update_group` (String) UpdateGroup indicates the update group for the teleport installation. This value is used to group installations in order to update them in batches. See --group flag in teleport-update program. Note: only supported for Amazon EC2. Group name can only contain alphanumeric characters and hyphens. + +### Nested Schema for `spec.aws.install.azure` + +Optional: + +- `client_id` (String) ClientID is the client ID of the managed identity discovered nodes should use to join the cluster. + + +### Nested Schema for `spec.aws.install.http_proxy_settings` + +Optional: + +- `http_proxy` (String) HTTPProxy is the URL for the HTTP proxy to use when making requests. When applied, this will set the HTTP_PROXY environment variable. +- `https_proxy` (String) HTTPSProxy is the URL for the HTTPS Proxy to use when making requests. When applied, this will set the HTTPS_PROXY environment variable. +- `no_proxy` (String) NoProxy is a comma separated list of URLs that will be excluded from proxying. When applied, this will set the NO_PROXY environment variable. + + + +### Nested Schema for `spec.aws.ssm` + +Optional: + +- `document_name` (String) DocumentName is the name of the document to use when executing an SSM command + + + +### Nested Schema for `spec.azure` + +Optional: + +- `install_params` (Attributes) Params sets the join method when installing on discovered Azure nodes. (see [below for nested schema](#nested-schema-for-specazureinstall_params)) +- `integration` (String) Integration is the integration name used to generate credentials to interact with Azure APIs. Environment credentials will not be used when this value is set. +- `regions` (List of String) Regions are Azure locations to match for databases. +- `resource_groups` (List of String) ResourceGroups are Azure resource groups to query for resources. +- `subscriptions` (List of String) Subscriptions are Azure subscriptions to query for resources. +- `tags` (Map of List of String) ResourceTags are Azure tags on resources to match. +- `types` (List of String) Types are Azure types to match: "mysql", "postgres", "aks", "vm" + +### Nested Schema for `spec.azure.install_params` + +Optional: + +- `azure` (Attributes) Azure is the set of Azure-specific installation parameters. (see [below for nested schema](#nested-schema-for-specazureinstall_paramsazure)) +- `enroll_mode` (Number) EnrollMode indicates the enrollment mode to be used when adding a node. Valid values: 0: uses eice for EC2 matchers which use an integration and script for all the other methods 1: uses script mode 2: uses eice mode (deprecated) +- `http_proxy_settings` (Attributes) HTTPProxySettings defines HTTP proxy settings for making HTTP requests. When set, this will set the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables before running the installation. (see [below for nested schema](#nested-schema-for-specazureinstall_paramshttp_proxy_settings)) +- `install_teleport` (Boolean) InstallTeleport disables agentless discovery +- `join_method` (String) JoinMethod is the method to use when joining the cluster +- `join_token` (String) JoinToken is the token to use when joining the cluster +- `proxy_addr` (String) PublicProxyAddr is the address of the proxy the discovered node should use to connect to the cluster. +- `script_name` (String) ScriptName is the name of the teleport installer script resource for the cloud instance to execute +- `sshd_config` (String) SSHDConfig provides the path to write sshd configuration changes +- `suffix` (String) Suffix indicates the installation suffix for the teleport installation. Set this value if you want multiple installations of Teleport. See --install-suffix flag in teleport-update program. Note: only supported for Amazon EC2. Suffix name can only contain alphanumeric characters and hyphens. +- `update_group` (String) UpdateGroup indicates the update group for the teleport installation. This value is used to group installations in order to update them in batches. See --group flag in teleport-update program. Note: only supported for Amazon EC2. Group name can only contain alphanumeric characters and hyphens. + +### Nested Schema for `spec.azure.install_params.azure` + +Optional: + +- `client_id` (String) ClientID is the client ID of the managed identity discovered nodes should use to join the cluster. + + +### Nested Schema for `spec.azure.install_params.http_proxy_settings` + +Optional: + +- `http_proxy` (String) HTTPProxy is the URL for the HTTP proxy to use when making requests. When applied, this will set the HTTP_PROXY environment variable. +- `https_proxy` (String) HTTPSProxy is the URL for the HTTPS Proxy to use when making requests. When applied, this will set the HTTPS_PROXY environment variable. +- `no_proxy` (String) NoProxy is a comma separated list of URLs that will be excluded from proxying. When applied, this will set the NO_PROXY environment variable. + + + + +### Nested Schema for `spec.gcp` + +Optional: + +- `install_params` (Attributes) Params sets the join method when installing on discovered GCP nodes. (see [below for nested schema](#nested-schema-for-specgcpinstall_params)) +- `labels` (Map of List of String) Labels are GCP labels to match. +- `locations` (List of String) Locations are GKE locations to search resources for. +- `project_ids` (List of String) ProjectIDs are the GCP project ID where the resources are deployed. +- `service_accounts` (List of String) ServiceAccounts are the emails of service accounts attached to VMs. +- `tags` (Map of List of String) Tags is obsolete and only exists for backwards compatibility. Use Labels instead. +- `types` (List of String) Types are GKE resource types to match: "gke", "vm". + +### Nested Schema for `spec.gcp.install_params` + +Optional: + +- `azure` (Attributes) Azure is the set of Azure-specific installation parameters. (see [below for nested schema](#nested-schema-for-specgcpinstall_paramsazure)) +- `enroll_mode` (Number) EnrollMode indicates the enrollment mode to be used when adding a node. Valid values: 0: uses eice for EC2 matchers which use an integration and script for all the other methods 1: uses script mode 2: uses eice mode (deprecated) +- `http_proxy_settings` (Attributes) HTTPProxySettings defines HTTP proxy settings for making HTTP requests. When set, this will set the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables before running the installation. (see [below for nested schema](#nested-schema-for-specgcpinstall_paramshttp_proxy_settings)) +- `install_teleport` (Boolean) InstallTeleport disables agentless discovery +- `join_method` (String) JoinMethod is the method to use when joining the cluster +- `join_token` (String) JoinToken is the token to use when joining the cluster +- `proxy_addr` (String) PublicProxyAddr is the address of the proxy the discovered node should use to connect to the cluster. +- `script_name` (String) ScriptName is the name of the teleport installer script resource for the cloud instance to execute +- `sshd_config` (String) SSHDConfig provides the path to write sshd configuration changes +- `suffix` (String) Suffix indicates the installation suffix for the teleport installation. Set this value if you want multiple installations of Teleport. See --install-suffix flag in teleport-update program. Note: only supported for Amazon EC2. Suffix name can only contain alphanumeric characters and hyphens. +- `update_group` (String) UpdateGroup indicates the update group for the teleport installation. This value is used to group installations in order to update them in batches. See --group flag in teleport-update program. Note: only supported for Amazon EC2. Group name can only contain alphanumeric characters and hyphens. + +### Nested Schema for `spec.gcp.install_params.azure` + +Optional: + +- `client_id` (String) ClientID is the client ID of the managed identity discovered nodes should use to join the cluster. + + +### Nested Schema for `spec.gcp.install_params.http_proxy_settings` + +Optional: + +- `http_proxy` (String) HTTPProxy is the URL for the HTTP proxy to use when making requests. When applied, this will set the HTTP_PROXY environment variable. +- `https_proxy` (String) HTTPSProxy is the URL for the HTTPS Proxy to use when making requests. When applied, this will set the HTTPS_PROXY environment variable. +- `no_proxy` (String) NoProxy is a comma separated list of URLs that will be excluded from proxying. When applied, this will set the NO_PROXY environment variable. + + + + +### Nested Schema for `spec.kube` + +Optional: + +- `labels` (Map of List of String) Labels are Kubernetes services labels to match. +- `namespaces` (List of String) Namespaces are Kubernetes namespaces in which to discover services +- `types` (List of String) Types are Kubernetes services types to match. Currently only 'app' is supported. + diff --git a/docs/pages/reference/infrastructure-as-code/terraform-provider/resources/discovery_config.mdx b/docs/pages/reference/infrastructure-as-code/terraform-provider/resources/discovery_config.mdx new file mode 100644 index 0000000000000..21ff84c0a6b1d --- /dev/null +++ b/docs/pages/reference/infrastructure-as-code/terraform-provider/resources/discovery_config.mdx @@ -0,0 +1,356 @@ +--- +title: Reference for the teleport_discovery_config Terraform resource +sidebar_label: discovery_config +description: This page describes the supported values of the teleport_discovery_config resource of the Teleport Terraform provider. +--- + +{/*Auto-generated file. Do not edit.*/} +{/*To regenerate, navigate to integrations/terraform and run `make docs`.*/} + +{/* Disable the outdated name check since resource fields occasionally need +to refer to these. */} +{/* vale 3rd-party-products.former-names = NO */} + +This page describes the supported values of the teleport_discovery_config resource of the Teleport Terraform provider. + + + + +## Example Usage + +```hcl +# Teleport Discovery Config +# +# Discovery Config resources define matchers for the Teleport Discovery Service. +# The Discovery Service automatically discovers and enrolls cloud resources +# (EC2 instances, RDS databases, EKS clusters, Azure VMs, etc.) into your +# Teleport cluster. +# +# Each Discovery Config is associated with a discovery_group. Discovery Services +# load matchers from Discovery Configs that share the same discovery_group. + +# Example: AWS Discovery Config for EC2 instances and RDS databases +resource "teleport_discovery_config" "aws_example" { + header = { + metadata = { + name = "aws-discovery" + description = "Discover AWS EC2 instances and RDS databases" + labels = { + env = "production" + } + } + version = "v1" + } + + spec = { + discovery_group = "aws-prod" + + aws = [{ + types = ["ec2", "rds"] + regions = ["us-west-2", "us-east-1"] + tags = { + "env" = ["prod", "production"] + } + install_params = { + join_method = "iam" + join_token = "aws-discovery-token" + script_name = "default-installer" + } + }] + } +} + +# Example: Azure Discovery Config for VMs and AKS clusters +resource "teleport_discovery_config" "azure_example" { + header = { + metadata = { + name = "azure-discovery" + description = "Discover Azure VMs and AKS clusters" + } + version = "v1" + } + + spec = { + discovery_group = "azure-prod" + + azure = [{ + types = ["vm", "aks"] + regions = ["eastus", "westus2"] + subscriptions = ["00000000-0000-0000-0000-000000000000"] + resource_groups = ["my-resource-group"] + tags = { + "*" = ["*"] + } + install_params = { + join_method = "azure" + join_token = "azure-discovery-token" + script_name = "default-installer" + azure = { + client_id = "00000000-0000-0000-0000-000000000000" + } + } + }] + } +} +``` + +{/* schema generated by tfplugindocs */} +## Schema + +### Required + +- `header` (Attributes) Header is the resource header. (see [below for nested schema](#nested-schema-for-header)) +- `spec` (Attributes) Spec is an DiscoveryConfig specification. (see [below for nested schema](#nested-schema-for-spec)) + +### Nested Schema for `header` + +Required: + +- `metadata` (Attributes) metadata is resource metadata. (see [below for nested schema](#nested-schema-for-headermetadata)) +- `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: + +- `kind` (String) kind is a resource kind. +- `sub_kind` (String) sub_kind is an optional resource sub kind, used in some resources. + +### Nested Schema for `header.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. +- `namespace` (String) namespace is object namespace. The field should be called "namespace" when it returns in Teleport 2.4. +- `revision` (String) revision is an opaque identifier which tracks the versions of a resource over time. Clients should ignore and not alter its value but must return the revision in any updates of a resource. + + + +### Nested Schema for `spec` + +Optional: + +- `access_graph` (Attributes) AccessGraph is the configurations for syncing Cloud accounts into Access Graph. (see [below for nested schema](#nested-schema-for-specaccess_graph)) +- `aws` (Attributes List) AWS is a list of AWS Matchers. (see [below for nested schema](#nested-schema-for-specaws)) +- `azure` (Attributes List) Azure is a list of Azure Matchers. (see [below for nested schema](#nested-schema-for-specazure)) +- `discovery_group` (String) DiscoveryGroup is used by discovery_service to add extra matchers. All the discovery_services that have the same discovery_group, will load the matchers of this resource. +- `gcp` (Attributes List) GCP is a list of GCP Matchers. (see [below for nested schema](#nested-schema-for-specgcp)) +- `kube` (Attributes List) Kube is a list of Kubernetes Matchers. (see [below for nested schema](#nested-schema-for-speckube)) + +### Nested Schema for `spec.access_graph` + +Optional: + +- `aws` (Attributes List) AWS is a configuration for AWS Access Graph service poll service. (see [below for nested schema](#nested-schema-for-specaccess_graphaws)) +- `azure` (Attributes List) Azure is a configuration for Azure Access Graph service poll service. (see [below for nested schema](#nested-schema-for-specaccess_graphazure)) +- `poll_interval` (String) PollInterval is the frequency at which to poll for resources + +### Nested Schema for `spec.access_graph.aws` + +Optional: + +- `assume_role` (Attributes) AssumeRoleARN is the AWS role to assume for database discovery. (see [below for nested schema](#nested-schema-for-specaccess_graphawsassume_role)) +- `cloud_trail_logs` (Attributes) Configuration settings for collecting AWS CloudTrail logs via an SQS queue. (see [below for nested schema](#nested-schema-for-specaccess_graphawscloud_trail_logs)) +- `eks_audit_logs` (Attributes) (see [below for nested schema](#nested-schema-for-specaccess_graphawseks_audit_logs)) +- `integration` (String) Integration is the integration name used to generate credentials to interact with AWS APIs. +- `regions` (List of String) Regions are AWS regions to import resources from. + +### Nested Schema for `spec.access_graph.aws.assume_role` + +Optional: + +- `external_id` (String) ExternalID is the external ID used to assume a role in another account. +- `role_arn` (String) RoleARN is the fully specified AWS IAM role ARN. + + +### Nested Schema for `spec.access_graph.aws.cloud_trail_logs` + +Optional: + +- `region` (String) The AWS region of the SQS queue for CloudTrail notifications, ex.: "us-east-2". +- `sqs_queue` (String) The name or URL for CloudTrail log events, ex.: "demo-cloudtrail-queue". + + +### Nested Schema for `spec.access_graph.aws.eks_audit_logs` + +Optional: + +- `tags` (Map of List of String) The tags of EKS clusters for which apiserver audit logs should be fetched. + + + +### Nested Schema for `spec.access_graph.azure` + +Optional: + +- `integration` (String) Integration is the integration name used to generate credentials to interact with AWS APIs. +- `subscription_id` (String) SubscriptionID Is the ID of the Azure subscription to sync resources from + + + +### Nested Schema for `spec.aws` + +Optional: + +- `assume_role` (Attributes) AssumeRoleARN is the AWS role to assume for database discovery. (see [below for nested schema](#nested-schema-for-specawsassume_role)) +- `install` (Attributes) Params sets the join method when installing on discovered EC2 nodes (see [below for nested schema](#nested-schema-for-specawsinstall)) +- `integration` (String) Integration is the integration name used to generate credentials to interact with AWS APIs. Environment credentials will not be used when this value is set. +- `kube_app_discovery` (Boolean) KubeAppDiscovery controls whether Kubernetes App Discovery will be enabled for agents running on discovered clusters, currently only affects AWS EKS discovery in integration mode. +- `regions` (List of String) Regions are AWS regions to query for databases. +- `setup_access_for_arn` (String) SetupAccessForARN is the role that the Discovery Service should create EKS Access Entries for. This value should match the IAM identity that Teleport Kubernetes Service uses. If this value is empty, the Discovery Service will attempt to set up access for its own identity (self). +- `ssm` (Attributes) SSM provides options to use when sending a document command to an EC2 node (see [below for nested schema](#nested-schema-for-specawsssm)) +- `tags` (Map of List of String) Tags are AWS resource Tags to match. +- `types` (List of String) Types are AWS database types to match, "ec2", "rds", "redshift", "elasticache", or "memorydb". + +### Nested Schema for `spec.aws.assume_role` + +Optional: + +- `external_id` (String) ExternalID is the external ID used to assume a role in another account. +- `role_arn` (String) RoleARN is the fully specified AWS IAM role ARN. + + +### Nested Schema for `spec.aws.install` + +Optional: + +- `azure` (Attributes) Azure is the set of Azure-specific installation parameters. (see [below for nested schema](#nested-schema-for-specawsinstallazure)) +- `enroll_mode` (Number) EnrollMode indicates the enrollment mode to be used when adding a node. Valid values: 0: uses eice for EC2 matchers which use an integration and script for all the other methods 1: uses script mode 2: uses eice mode (deprecated) +- `http_proxy_settings` (Attributes) HTTPProxySettings defines HTTP proxy settings for making HTTP requests. When set, this will set the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables before running the installation. (see [below for nested schema](#nested-schema-for-specawsinstallhttp_proxy_settings)) +- `install_teleport` (Boolean) InstallTeleport disables agentless discovery +- `join_method` (String) JoinMethod is the method to use when joining the cluster +- `join_token` (String) JoinToken is the token to use when joining the cluster +- `proxy_addr` (String) PublicProxyAddr is the address of the proxy the discovered node should use to connect to the cluster. +- `script_name` (String) ScriptName is the name of the teleport installer script resource for the cloud instance to execute +- `sshd_config` (String) SSHDConfig provides the path to write sshd configuration changes +- `suffix` (String) Suffix indicates the installation suffix for the teleport installation. Set this value if you want multiple installations of Teleport. See --install-suffix flag in teleport-update program. Note: only supported for Amazon EC2. Suffix name can only contain alphanumeric characters and hyphens. +- `update_group` (String) UpdateGroup indicates the update group for the teleport installation. This value is used to group installations in order to update them in batches. See --group flag in teleport-update program. Note: only supported for Amazon EC2. Group name can only contain alphanumeric characters and hyphens. + +### Nested Schema for `spec.aws.install.azure` + +Optional: + +- `client_id` (String) ClientID is the client ID of the managed identity discovered nodes should use to join the cluster. + + +### Nested Schema for `spec.aws.install.http_proxy_settings` + +Optional: + +- `http_proxy` (String) HTTPProxy is the URL for the HTTP proxy to use when making requests. When applied, this will set the HTTP_PROXY environment variable. +- `https_proxy` (String) HTTPSProxy is the URL for the HTTPS Proxy to use when making requests. When applied, this will set the HTTPS_PROXY environment variable. +- `no_proxy` (String) NoProxy is a comma separated list of URLs that will be excluded from proxying. When applied, this will set the NO_PROXY environment variable. + + + +### Nested Schema for `spec.aws.ssm` + +Optional: + +- `document_name` (String) DocumentName is the name of the document to use when executing an SSM command + + + +### Nested Schema for `spec.azure` + +Optional: + +- `install_params` (Attributes) Params sets the join method when installing on discovered Azure nodes. (see [below for nested schema](#nested-schema-for-specazureinstall_params)) +- `integration` (String) Integration is the integration name used to generate credentials to interact with Azure APIs. Environment credentials will not be used when this value is set. +- `regions` (List of String) Regions are Azure locations to match for databases. +- `resource_groups` (List of String) ResourceGroups are Azure resource groups to query for resources. +- `subscriptions` (List of String) Subscriptions are Azure subscriptions to query for resources. +- `tags` (Map of List of String) ResourceTags are Azure tags on resources to match. +- `types` (List of String) Types are Azure types to match: "mysql", "postgres", "aks", "vm" + +### Nested Schema for `spec.azure.install_params` + +Optional: + +- `azure` (Attributes) Azure is the set of Azure-specific installation parameters. (see [below for nested schema](#nested-schema-for-specazureinstall_paramsazure)) +- `enroll_mode` (Number) EnrollMode indicates the enrollment mode to be used when adding a node. Valid values: 0: uses eice for EC2 matchers which use an integration and script for all the other methods 1: uses script mode 2: uses eice mode (deprecated) +- `http_proxy_settings` (Attributes) HTTPProxySettings defines HTTP proxy settings for making HTTP requests. When set, this will set the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables before running the installation. (see [below for nested schema](#nested-schema-for-specazureinstall_paramshttp_proxy_settings)) +- `install_teleport` (Boolean) InstallTeleport disables agentless discovery +- `join_method` (String) JoinMethod is the method to use when joining the cluster +- `join_token` (String) JoinToken is the token to use when joining the cluster +- `proxy_addr` (String) PublicProxyAddr is the address of the proxy the discovered node should use to connect to the cluster. +- `script_name` (String) ScriptName is the name of the teleport installer script resource for the cloud instance to execute +- `sshd_config` (String) SSHDConfig provides the path to write sshd configuration changes +- `suffix` (String) Suffix indicates the installation suffix for the teleport installation. Set this value if you want multiple installations of Teleport. See --install-suffix flag in teleport-update program. Note: only supported for Amazon EC2. Suffix name can only contain alphanumeric characters and hyphens. +- `update_group` (String) UpdateGroup indicates the update group for the teleport installation. This value is used to group installations in order to update them in batches. See --group flag in teleport-update program. Note: only supported for Amazon EC2. Group name can only contain alphanumeric characters and hyphens. + +### Nested Schema for `spec.azure.install_params.azure` + +Optional: + +- `client_id` (String) ClientID is the client ID of the managed identity discovered nodes should use to join the cluster. + + +### Nested Schema for `spec.azure.install_params.http_proxy_settings` + +Optional: + +- `http_proxy` (String) HTTPProxy is the URL for the HTTP proxy to use when making requests. When applied, this will set the HTTP_PROXY environment variable. +- `https_proxy` (String) HTTPSProxy is the URL for the HTTPS Proxy to use when making requests. When applied, this will set the HTTPS_PROXY environment variable. +- `no_proxy` (String) NoProxy is a comma separated list of URLs that will be excluded from proxying. When applied, this will set the NO_PROXY environment variable. + + + + +### Nested Schema for `spec.gcp` + +Optional: + +- `install_params` (Attributes) Params sets the join method when installing on discovered GCP nodes. (see [below for nested schema](#nested-schema-for-specgcpinstall_params)) +- `labels` (Map of List of String) Labels are GCP labels to match. +- `locations` (List of String) Locations are GKE locations to search resources for. +- `project_ids` (List of String) ProjectIDs are the GCP project ID where the resources are deployed. +- `service_accounts` (List of String) ServiceAccounts are the emails of service accounts attached to VMs. +- `tags` (Map of List of String) Tags is obsolete and only exists for backwards compatibility. Use Labels instead. +- `types` (List of String) Types are GKE resource types to match: "gke", "vm". + +### Nested Schema for `spec.gcp.install_params` + +Optional: + +- `azure` (Attributes) Azure is the set of Azure-specific installation parameters. (see [below for nested schema](#nested-schema-for-specgcpinstall_paramsazure)) +- `enroll_mode` (Number) EnrollMode indicates the enrollment mode to be used when adding a node. Valid values: 0: uses eice for EC2 matchers which use an integration and script for all the other methods 1: uses script mode 2: uses eice mode (deprecated) +- `http_proxy_settings` (Attributes) HTTPProxySettings defines HTTP proxy settings for making HTTP requests. When set, this will set the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables before running the installation. (see [below for nested schema](#nested-schema-for-specgcpinstall_paramshttp_proxy_settings)) +- `install_teleport` (Boolean) InstallTeleport disables agentless discovery +- `join_method` (String) JoinMethod is the method to use when joining the cluster +- `join_token` (String) JoinToken is the token to use when joining the cluster +- `proxy_addr` (String) PublicProxyAddr is the address of the proxy the discovered node should use to connect to the cluster. +- `script_name` (String) ScriptName is the name of the teleport installer script resource for the cloud instance to execute +- `sshd_config` (String) SSHDConfig provides the path to write sshd configuration changes +- `suffix` (String) Suffix indicates the installation suffix for the teleport installation. Set this value if you want multiple installations of Teleport. See --install-suffix flag in teleport-update program. Note: only supported for Amazon EC2. Suffix name can only contain alphanumeric characters and hyphens. +- `update_group` (String) UpdateGroup indicates the update group for the teleport installation. This value is used to group installations in order to update them in batches. See --group flag in teleport-update program. Note: only supported for Amazon EC2. Group name can only contain alphanumeric characters and hyphens. + +### Nested Schema for `spec.gcp.install_params.azure` + +Optional: + +- `client_id` (String) ClientID is the client ID of the managed identity discovered nodes should use to join the cluster. + + +### Nested Schema for `spec.gcp.install_params.http_proxy_settings` + +Optional: + +- `http_proxy` (String) HTTPProxy is the URL for the HTTP proxy to use when making requests. When applied, this will set the HTTP_PROXY environment variable. +- `https_proxy` (String) HTTPSProxy is the URL for the HTTPS Proxy to use when making requests. When applied, this will set the HTTPS_PROXY environment variable. +- `no_proxy` (String) NoProxy is a comma separated list of URLs that will be excluded from proxying. When applied, this will set the NO_PROXY environment variable. + + + + +### Nested Schema for `spec.kube` + +Optional: + +- `labels` (Map of List of String) Labels are Kubernetes services labels to match. +- `namespaces` (List of String) Namespaces are Kubernetes namespaces in which to discover services +- `types` (List of String) Types are Kubernetes services types to match. Currently only 'app' is supported. diff --git a/docs/pages/reference/infrastructure-as-code/terraform-provider/resources/resources.mdx b/docs/pages/reference/infrastructure-as-code/terraform-provider/resources/resources.mdx index f0265e4d5e5f1..88c8520c316bd 100644 --- a/docs/pages/reference/infrastructure-as-code/terraform-provider/resources/resources.mdx +++ b/docs/pages/reference/infrastructure-as-code/terraform-provider/resources/resources.mdx @@ -24,6 +24,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_discovery_config`](./discovery_config.mdx) - [`teleport_dynamic_windows_desktop`](./dynamic_windows_desktop.mdx) - [`teleport_github_connector`](./github_connector.mdx) - [`teleport_health_check_config`](./health_check_config.mdx) diff --git a/integrations/terraform/Makefile b/integrations/terraform/Makefile index 4a0c7aed0d80c..7001c918bdaf8 100644 --- a/integrations/terraform/Makefile +++ b/integrations/terraform/Makefile @@ -63,7 +63,7 @@ $(BUILDDIR)/terraform-provider-teleport_%: terraform-provider-teleport-v$(VERSIO CUSTOM_IMPORTS_TMP_DIR ?= /tmp/protoc-gen-terraform/custom-imports # This version must match the version installed by .github/workflows/lint.yaml -PROTOC_GEN_TERRAFORM_VERSION ?= v3.0.2 +PROTOC_GEN_TERRAFORM_VERSION ?= v3.0.3 PROTOC_GEN_TERRAFORM_EXISTS := $(shell $(PROTOC_GEN_TERRAFORM) version 2>&1 >/dev/null | grep 'protoc-gen-terraform $(PROTOC_GEN_TERRAFORM_VERSION)') .PHONY: gen-tfschema @@ -142,6 +142,13 @@ endif --terraform_out=config=protoc-gen-terraform-healthcheckconfig.yaml:./tfschema \ teleport/healthcheckconfig/v1/health_check_config.proto + @protoc \ + -I=../../api/proto \ + -I=$(PROTOBUF_MOD_PATH) \ + --plugin=$(PROTOC_GEN_TERRAFORM) \ + --terraform_out=config=protoc-gen-terraform-discoveryconfig.yaml:./tfschema \ + teleport/discoveryconfig/v1/discoveryconfig.proto + mv ./tfschema/github.com/gravitational/teleport/api/gen/proto/go/teleport/loginrule/v1/loginrule_terraform.go ./tfschema/loginrule/v1/ mv ./tfschema/github.com/gravitational/teleport/api/gen/proto/go/teleport/accesslist/v1/accesslist_terraform.go ./tfschema/accesslist/v1/ mv ./tfschema/github.com/gravitational/teleport/api/gen/proto/go/teleport/accessmonitoringrules/v1/access_monitoring_rules_terraform.go ./tfschema/accessmonitoringrules/v1/ @@ -149,6 +156,7 @@ endif mv ./tfschema/github.com/gravitational/teleport/api/gen/proto/go/teleport/workloadidentity/v1/resource_terraform.go ./tfschema/workloadidentity/v1/ mv ./tfschema/github.com/gravitational/teleport/api/gen/proto/go/teleport/autoupdate/v1/autoupdate_terraform.go ./tfschema/autoupdate/v1/ mv ./tfschema/github.com/gravitational/teleport/api/gen/proto/go/teleport/healthcheckconfig/v1/health_check_config_terraform.go ./tfschema/healthcheckconfig/v1/ + mv ./tfschema/github.com/gravitational/teleport/api/gen/proto/go/teleport/discoveryconfig/v1/discoveryconfig_terraform.go ./tfschema/discoveryconfig/v1/ mv ./tfschema/github.com/gravitational/teleport/api/types/device_terraform.go ./tfschema/devicetrust/v1/ rm -r ./tfschema/github.com/ @go run ./gen/main.go @@ -192,11 +200,7 @@ ifndef TERRAFORM_EXISTS terraform -version @exit -1 endif -# NOTE: This is related to an old bug in Terraform and will be fixed in future releases (possibly, by a workaround on our side) -ifeq ($(shell expr $(CURRENT_ULIMIT) \< 1024), 1) - @echo "ulimit -n is too low ($(CURRENT_ULIMIT)), please set ulimit -n 1024" - @exit -1 -endif + gotestsum --junitfile unit-tests-terraform.xml --jsonfile unit-tests-terraform.json -- ./testlib -v $(TEST_ARGS) .PHONY: test-full diff --git a/integrations/terraform/README.md b/integrations/terraform/README.md index dde74bc7b793b..fde91ae59d0f9 100644 --- a/integrations/terraform/README.md +++ b/integrations/terraform/README.md @@ -7,9 +7,9 @@ Please, refer to [official documentation](https://goteleport.com/docs/admin-guid ## Development 1. Install [`protobuf`](https://grpc.io/docs/protoc-installation/). -2. Install [`protoc-gen-terraform`](https://github.com/gravitational/protoc-gen-terraform) @v3.0.2. +2. Install [`protoc-gen-terraform`](https://github.com/gravitational/protoc-gen-terraform) @v3.0.3. - ```go install github.com/gravitational/protoc-gen-terraform/v3@v3.0.2``` + ```go install github.com/gravitational/protoc-gen-terraform/v3@v3.0.3``` 3. Install [`Terraform`](https://learn.hashicorp.com/tutorials/terraform/install-cli) v1.1.0+. Alternatively, you can use [`tfenv`](https://github.com/tfutils/tfenv). Please note that on Mac M1 you need to specify `TFENV_ARCH` (ex: `TFENV_ARCH=arm64 tfenv install 1.1.6`). diff --git a/integrations/terraform/examples/resources/teleport_discovery_config/resource.tf b/integrations/terraform/examples/resources/teleport_discovery_config/resource.tf new file mode 100644 index 0000000000000..c44123932ae9d --- /dev/null +++ b/integrations/terraform/examples/resources/teleport_discovery_config/resource.tf @@ -0,0 +1,74 @@ +# Teleport Discovery Config +# +# Discovery Config resources define matchers for the Teleport Discovery Service. +# The Discovery Service automatically discovers and enrolls cloud resources +# (EC2 instances, RDS databases, EKS clusters, Azure VMs, etc.) into your +# Teleport cluster. +# +# Each Discovery Config is associated with a discovery_group. Discovery Services +# load matchers from Discovery Configs that share the same discovery_group. + +# Example: AWS Discovery Config for EC2 instances and RDS databases +resource "teleport_discovery_config" "aws_example" { + header = { + metadata = { + name = "aws-discovery" + description = "Discover AWS EC2 instances and RDS databases" + labels = { + env = "production" + } + } + version = "v1" + } + + spec = { + discovery_group = "aws-prod" + + aws = [{ + types = ["ec2", "rds"] + regions = ["us-west-2", "us-east-1"] + tags = { + "env" = ["prod", "production"] + } + install_params = { + join_method = "iam" + join_token = "aws-discovery-token" + script_name = "default-installer" + } + }] + } +} + +# Example: Azure Discovery Config for VMs and AKS clusters +resource "teleport_discovery_config" "azure_example" { + header = { + metadata = { + name = "azure-discovery" + description = "Discover Azure VMs and AKS clusters" + } + version = "v1" + } + + spec = { + discovery_group = "azure-prod" + + azure = [{ + types = ["vm", "aks"] + regions = ["eastus", "westus2"] + subscriptions = ["00000000-0000-0000-0000-000000000000"] + resource_groups = ["my-resource-group"] + tags = { + "*" = ["*"] + } + install_params = { + join_method = "azure" + join_token = "azure-discovery-token" + script_name = "default-installer" + azure = { + client_id = "00000000-0000-0000-0000-000000000000" + } + } + }] + } +} + diff --git a/integrations/terraform/gen/main.go b/integrations/terraform/gen/main.go index 962e2f9032ae3..816db2e2909a6 100644 --- a/integrations/terraform/gen/main.go +++ b/integrations/terraform/gen/main.go @@ -665,6 +665,28 @@ var ( ExtraImports: []string{"apitypes \"github.com/gravitational/teleport/api/types\""}, ForceSetKind: "apitypes.KindHealthCheckConfig", } + + discoveryConfig = payload{ + Name: "DiscoveryConfig", + TypeName: "DiscoveryConfig", + VarName: "discoveryConfig", + GetMethod: "DiscoveryConfigClient().GetDiscoveryConfig", + CreateMethod: "DiscoveryConfigClient().CreateDiscoveryConfig", + UpsertMethodArity: 2, + UpdateMethod: "DiscoveryConfigClient().UpsertDiscoveryConfig", + DeleteMethod: "DiscoveryConfigClient().DeleteDiscoveryConfig", + ID: "discoveryConfig.Header.Metadata.Name", + Kind: "discovery_config", + HasStaticID: false, + ProtoPackage: "discoveryconfigv1", + ProtoPackagePath: "github.com/gravitational/teleport/api/gen/proto/go/teleport/discoveryconfig/v1", + SchemaPackage: "schemav1", + SchemaPackagePath: "github.com/gravitational/teleport/integrations/terraform/tfschema/discoveryconfig/v1", + TerraformResourceType: "teleport_discovery_config", + ExtraImports: []string{"apitypes \"github.com/gravitational/teleport/api/types\""}, + ForceSetKind: "apitypes.KindDiscoveryConfig", + ConvertPackagePath: "github.com/gravitational/teleport/api/types/discoveryconfig/convert/v1", + } ) func main() { @@ -726,6 +748,8 @@ func genTFSchema() { generateDataSource(autoUpdateConfig, singularDataSource) generateResource(healthCheckConfig, pluralResource) generateDataSource(healthCheckConfig, pluralDataSource) + generateResource(discoveryConfig, pluralResource) + generateDataSource(discoveryConfig, pluralDataSource) } func generateResource(p payload, tpl string) { diff --git a/integrations/terraform/protoc-gen-terraform-discoveryconfig.yaml b/integrations/terraform/protoc-gen-terraform-discoveryconfig.yaml new file mode 100644 index 0000000000000..9113244a50488 --- /dev/null +++ b/integrations/terraform/protoc-gen-terraform-discoveryconfig.yaml @@ -0,0 +1,95 @@ +--- +target_package_name: 'v1' +default_package_name: 'github.com/gravitational/teleport/api/gen/proto/go/teleport/discoveryconfig/v1' +duration_custom_type: Duration +use_state_for_unknown_by_default: true + +# Top-level type names to export +types: + - 'DiscoveryConfig' + +# 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' + 'github_com_gravitational_teleport_integrations_terraform_tfschema': 'github.com/gravitational/teleport/integrations/terraform/tfschema' + +# 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: + DiscoveryConfig: + - 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) + - 'DiscoveryConfig.header.metadata.id' + # Read only field + - 'DiscoveryConfig.status' + +# These fields will be marked as Computed: true +computed_fields: + # Metadata + - 'DiscoveryConfig.header.metadata.expires' + - 'DiscoveryConfig.header.metadata.namespace' + - 'DiscoveryConfig.header.metadata.revision' + - 'DiscoveryConfig.header.kind' + - 'DiscoveryConfig.header.sub_kind' + +# These fields will be marked as Required: true +required_fields: + - 'DiscoveryConfig.header' + - 'DiscoveryConfig.header.metadata' + - 'DiscoveryConfig.header.metadata.name' + - 'DiscoveryConfig.header.version' + - 'DiscoveryConfig.spec' + +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: "DurationType" + value_type: "DurationValue" + cast_to_type: "time.Duration" + cast_from_type: "time.Duration" + +validators: + # Expires must be in the future + Metadata.expires: + - github_com_gravitational_teleport_integrations_terraform_tfschema.MustTimeBeInFuture() + +custom_types: + 'DiscoveryConfig.header.metadata.expires': Timestamp + +schema_types: + 'DiscoveryConfig.spec.aws.Params.JoinMethod': + type: "github.com/hashicorp/terraform-plugin-framework/types.StringType" + value_type: "github.com/hashicorp/terraform-plugin-framework/types.String" + cast_to_type: "string" + cast_from_type: "github.com/gravitational/teleport/api/types.JoinMethod" + 'DiscoveryConfig.spec.azure.Params.JoinMethod': + type: "github.com/hashicorp/terraform-plugin-framework/types.StringType" + value_type: "github.com/hashicorp/terraform-plugin-framework/types.String" + cast_to_type: "string" + cast_from_type: "github.com/gravitational/teleport/api/types.JoinMethod" + 'DiscoveryConfig.spec.gcp.Params.JoinMethod': + type: "github.com/hashicorp/terraform-plugin-framework/types.StringType" + value_type: "github.com/hashicorp/terraform-plugin-framework/types.String" + cast_to_type: "string" + cast_from_type: "github.com/gravitational/teleport/api/types.JoinMethod" diff --git a/integrations/terraform/provider/data_source_teleport_discovery_config.go b/integrations/terraform/provider/data_source_teleport_discovery_config.go new file mode 100755 index 0000000000000..c32e7c02bc8b3 --- /dev/null +++ b/integrations/terraform/provider/data_source_teleport_discovery_config.go @@ -0,0 +1,96 @@ +// Code generated by _gen/main.go DO NOT EDIT +/* +Copyright 2015-2024 Gravitational, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package provider + +import ( + "context" + + convert "github.com/gravitational/teleport/api/types/discoveryconfig/convert/v1" + "github.com/gravitational/trace" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + + schemav1 "github.com/gravitational/teleport/integrations/terraform/tfschema/discoveryconfig/v1" +) + +// dataSourceTeleportDiscoveryConfigType is the data source metadata type +type dataSourceTeleportDiscoveryConfigType struct{} + +// dataSourceTeleportDiscoveryConfig is the resource +type dataSourceTeleportDiscoveryConfig struct { + p Provider +} + +// GetSchema returns the data source schema +func (r dataSourceTeleportDiscoveryConfigType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + return schemav1.GenSchemaDiscoveryConfig(ctx) +} + +// NewDataSource creates the empty data source +func (r dataSourceTeleportDiscoveryConfigType) NewDataSource(_ context.Context, p tfsdk.Provider) (tfsdk.DataSource, diag.Diagnostics) { + return dataSourceTeleportDiscoveryConfig{ + p: *(p.(*Provider)), + }, nil +} + +// Read reads teleport DiscoveryConfig +func (r dataSourceTeleportDiscoveryConfig) Read(ctx context.Context, req tfsdk.ReadDataSourceRequest, resp *tfsdk.ReadDataSourceResponse) { + var id types.String + diags := req.Config.GetAttribute(ctx, path.Root("header").AtName("metadata").AtName("name"), &id) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + discoveryConfigI, err := r.p.Client.DiscoveryConfigClient().GetDiscoveryConfig(ctx, id.Value) + if err != nil { + resp.Diagnostics.Append(diagFromWrappedErr("Error reading DiscoveryConfig", trace.Wrap(err), "discovery_config")) + return + } + + var state types.Object + resp.Diagnostics.Append(req.Config.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + // Todo: Remove after updating terraform-plugin to >=v1.5.0. + // terraform-plugin-testing version <1.5.0 requires data resources to + // implement the 'id' attribute. + // https://developer.hashicorp.com/terraform/plugin/framework/acctests#no-id-found-in-attributes + v, ok := state.Attrs["id"] + if !ok || v.IsNull() { + state.Attrs["id"] = id + } + + discoveryConfig := convert.ToProto(discoveryConfigI) + + diags = schemav1.CopyDiscoveryConfigToTerraform(ctx, discoveryConfig, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} diff --git a/integrations/terraform/provider/provider.go b/integrations/terraform/provider/provider.go index 3cab362453fd7..aad531c2419f9 100644 --- a/integrations/terraform/provider/provider.go +++ b/integrations/terraform/provider/provider.go @@ -534,6 +534,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_discovery_config": resourceTeleportDiscoveryConfigType{}, "teleport_dynamic_windows_desktop": resourceTeleportDynamicWindowsDesktopType{}, "teleport_github_connector": resourceTeleportGithubConnectorType{}, "teleport_provision_token": resourceTeleportProvisionTokenType{}, @@ -568,6 +569,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_discovery_config": dataSourceTeleportDiscoveryConfigType{}, "teleport_dynamic_windows_desktop": dataSourceTeleportDynamicWindowsDesktopType{}, "teleport_github_connector": dataSourceTeleportGithubConnectorType{}, "teleport_provision_token": dataSourceTeleportProvisionTokenType{}, diff --git a/integrations/terraform/provider/resource_teleport_discovery_config.go b/integrations/terraform/provider/resource_teleport_discovery_config.go new file mode 100755 index 0000000000000..ff6e1f4c5b49b --- /dev/null +++ b/integrations/terraform/provider/resource_teleport_discovery_config.go @@ -0,0 +1,346 @@ +// Code generated by _gen/main.go DO NOT EDIT +/* +Copyright 2015-2024 Gravitational, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package provider + +import ( + "context" + "fmt" + apitypes "github.com/gravitational/teleport/api/types" + + discoveryconfigv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/discoveryconfig/v1" + convert "github.com/gravitational/teleport/api/types/discoveryconfig/convert/v1" + "github.com/gravitational/teleport/api/utils/retryutils" + "github.com/gravitational/trace" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + + schemav1 "github.com/gravitational/teleport/integrations/terraform/tfschema/discoveryconfig/v1" +) + +// resourceTeleportDiscoveryConfigType is the resource metadata type +type resourceTeleportDiscoveryConfigType struct{} + +// resourceTeleportDiscoveryConfig is the resource +type resourceTeleportDiscoveryConfig struct { + p Provider +} + +// GetSchema returns the resource schema +func (r resourceTeleportDiscoveryConfigType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { + return schemav1.GenSchemaDiscoveryConfig(ctx) +} + +// NewResource creates the empty resource +func (r resourceTeleportDiscoveryConfigType) NewResource(_ context.Context, p tfsdk.Provider) (tfsdk.Resource, diag.Diagnostics) { + return resourceTeleportDiscoveryConfig{ + p: *(p.(*Provider)), + }, nil +} + +// Create creates the DiscoveryConfig +func (r resourceTeleportDiscoveryConfig) Create(ctx context.Context, req tfsdk.CreateResourceRequest, resp *tfsdk.CreateResourceResponse) { + var err error + if !r.p.IsConfigured(resp.Diagnostics) { + return + } + + var plan types.Object + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + discoveryConfig := &discoveryconfigv1.DiscoveryConfig{} + diags = schemav1.CopyDiscoveryConfigFromTerraform(ctx, plan, discoveryConfig) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + + discoveryConfigResource, err := convert.FromProto(discoveryConfig) + if err != nil { + resp.Diagnostics.Append(diagFromWrappedErr("Error reading DiscoveryConfig", trace.Errorf("Can not convert %T to DiscoveryConfig: %s", discoveryConfigResource, err), "discovery_config")) + return + } + discoveryConfigResource.Kind = apitypes.KindDiscoveryConfig + + id := discoveryConfigResource.Metadata.Name + + _, err = r.p.Client.DiscoveryConfigClient().GetDiscoveryConfig(ctx, id) + if !trace.IsNotFound(err) { + if err == nil { + existErr := fmt.Sprintf("DiscoveryConfig exists in Teleport. Either remove it (tctl rm discovery_config/%v)"+ + " or import it to the existing state (terraform import teleport_discovery_config.%v %v)", id, id, id) + + resp.Diagnostics.Append(diagFromErr("DiscoveryConfig exists in Teleport", trace.Errorf(existErr))) + return + } + + resp.Diagnostics.Append(diagFromWrappedErr("Error reading DiscoveryConfig", trace.Wrap(err), "discovery_config")) + return + } + + _, err = r.p.Client.DiscoveryConfigClient().CreateDiscoveryConfig(ctx, discoveryConfigResource) + if err != nil { + resp.Diagnostics.Append(diagFromWrappedErr("Error creating DiscoveryConfig", trace.Wrap(err), "discovery_config")) + return + } + var discoveryConfigI = discoveryConfigResource + // Try getting the resource until it exists. + tries := 0 + retry, err := retryutils.NewRetryV2(retryutils.RetryV2Config{ + Driver: retryutils.NewExponentialDriver(r.p.RetryConfig.Base), + First: r.p.RetryConfig.Base, + Max: r.p.RetryConfig.Cap, + Jitter: retryutils.HalfJitter, + }) + if err != nil { + return + } + for { + tries = tries + 1 + discoveryConfigI, err = r.p.Client.DiscoveryConfigClient().GetDiscoveryConfig(ctx, id) + if trace.IsNotFound(err) { + select { + case <-ctx.Done(): + resp.Diagnostics.Append(diagFromWrappedErr("Error reading DiscoveryConfig", trace.Wrap(ctx.Err()), "discovery_config")) + return + case <-retry.After(): + } + if tries >= r.p.RetryConfig.MaxTries { + diagMessage := fmt.Sprintf("Error reading DiscoveryConfig (tried %d times) - state outdated, please import resource", tries) + resp.Diagnostics.AddError(diagMessage, "discovery_config") + return + } + continue + } + break + } + + if err != nil { + resp.Diagnostics.Append(diagFromWrappedErr("Error reading DiscoveryConfig", trace.Wrap(err), "discovery_config")) + return + } + + discoveryConfigResource = discoveryConfigI + + discoveryConfig = convert.ToProto(discoveryConfigResource) + + + diags = schemav1.CopyDiscoveryConfigToTerraform(ctx, discoveryConfig, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + plan.Attrs["id"] = types.String{Value: discoveryConfig.Header.Metadata.Name} + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} + +// Read reads teleport DiscoveryConfig +func (r resourceTeleportDiscoveryConfig) Read(ctx context.Context, req tfsdk.ReadResourceRequest, resp *tfsdk.ReadResourceResponse) { + var state types.Object + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + var id types.String + diags = req.State.GetAttribute(ctx, path.Root("header").AtName("metadata").AtName("name"), &id) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + discoveryConfigI, err := r.p.Client.DiscoveryConfigClient().GetDiscoveryConfig(ctx, id.Value) + if trace.IsNotFound(err) { + resp.State.RemoveResource(ctx) + return + } + + if err != nil { + resp.Diagnostics.Append(diagFromWrappedErr("Error reading DiscoveryConfig", trace.Wrap(err), "discovery_config")) + return + } + discoveryConfig := convert.ToProto(discoveryConfigI) + diags = schemav1.CopyDiscoveryConfigToTerraform(ctx, discoveryConfig, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} + +// Update updates teleport DiscoveryConfig +func (r resourceTeleportDiscoveryConfig) Update(ctx context.Context, req tfsdk.UpdateResourceRequest, resp *tfsdk.UpdateResourceResponse) { + if !r.p.IsConfigured(resp.Diagnostics) { + return + } + + var plan types.Object + diags := req.Plan.Get(ctx, &plan) + + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + discoveryConfig := &discoveryconfigv1.DiscoveryConfig{} + diags = schemav1.CopyDiscoveryConfigFromTerraform(ctx, plan, discoveryConfig) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + discoveryConfigResource, err := convert.FromProto(discoveryConfig) + if err != nil { + resp.Diagnostics.Append(diagFromWrappedErr("Error reading DiscoveryConfig", trace.Errorf("Can not convert %T to DiscoveryConfig: %s", discoveryConfigResource, err), "discovery_config")) + return + } + + + name := discoveryConfigResource.Metadata.Name + + discoveryConfigBefore, err := r.p.Client.DiscoveryConfigClient().GetDiscoveryConfig(ctx, name) + if err != nil { + resp.Diagnostics.Append(diagFromWrappedErr("Error reading DiscoveryConfig", err, "discovery_config")) + return + } + + _, err = r.p.Client.DiscoveryConfigClient().UpsertDiscoveryConfig(ctx, discoveryConfigResource) + if err != nil { + resp.Diagnostics.Append(diagFromWrappedErr("Error updating DiscoveryConfig", err, "discovery_config")) + return + } + var discoveryConfigI = discoveryConfigResource + + tries := 0 + retry, err := retryutils.NewRetryV2(retryutils.RetryV2Config{ + Driver: retryutils.NewExponentialDriver(r.p.RetryConfig.Base), + First: r.p.RetryConfig.Base, + Max: r.p.RetryConfig.Cap, + Jitter: retryutils.HalfJitter, + }) + if err != nil { + return + } + for { + tries = tries + 1 + discoveryConfigI, err = r.p.Client.DiscoveryConfigClient().GetDiscoveryConfig(ctx, name) + if err != nil { + resp.Diagnostics.Append(diagFromWrappedErr("Error reading DiscoveryConfig", err, "discovery_config")) + return + } + if discoveryConfigBefore.GetMetadata().Revision != discoveryConfigI.GetMetadata().Revision || false { + break + } + + select { + case <-ctx.Done(): + resp.Diagnostics.Append(diagFromWrappedErr("Error reading DiscoveryConfig", trace.Wrap(ctx.Err()), "discovery_config")) + return + case <-retry.After(): + } + if tries >= r.p.RetryConfig.MaxTries { + diagMessage := fmt.Sprintf("Error reading DiscoveryConfig (tried %d times) - state outdated, please import resource", tries) + resp.Diagnostics.AddError(diagMessage, "discovery_config") + return + } + } + + discoveryConfigResource = discoveryConfigI + + diags = schemav1.CopyDiscoveryConfigToTerraform(ctx, discoveryConfig, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + diags = resp.State.Set(ctx, plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} + +// Delete deletes Teleport DiscoveryConfig +func (r resourceTeleportDiscoveryConfig) Delete(ctx context.Context, req tfsdk.DeleteResourceRequest, resp *tfsdk.DeleteResourceResponse) { + var id types.String + diags := req.State.GetAttribute(ctx, path.Root("header").AtName("metadata").AtName("name"), &id) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + err := r.p.Client.DiscoveryConfigClient().DeleteDiscoveryConfig(ctx, id.Value) + if err != nil { + resp.Diagnostics.Append(diagFromWrappedErr("Error deleting DiscoveryConfig", trace.Wrap(err), "discovery_config")) + return + } + + resp.State.RemoveResource(ctx) +} + +// ImportState imports DiscoveryConfig state +func (r resourceTeleportDiscoveryConfig) ImportState(ctx context.Context, req tfsdk.ImportResourceStateRequest, resp *tfsdk.ImportResourceStateResponse) { + discoveryConfig, err := r.p.Client.DiscoveryConfigClient().GetDiscoveryConfig(ctx, req.ID) + if err != nil { + resp.Diagnostics.Append(diagFromWrappedErr("Error reading DiscoveryConfig", trace.Wrap(err), "discovery_config")) + return + } + + discoveryConfigResource := convert.ToProto(discoveryConfig) + + + var state types.Object + + diags := resp.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + diags = schemav1.CopyDiscoveryConfigToTerraform(ctx, discoveryConfigResource, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + id := discoveryConfig.Metadata.Name + + state.Attrs["id"] = types.String{Value: id} + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} diff --git a/integrations/terraform/testlib/discovery_config_test.go b/integrations/terraform/testlib/discovery_config_test.go new file mode 100644 index 0000000000000..89b16b34c489a --- /dev/null +++ b/integrations/terraform/testlib/discovery_config_test.go @@ -0,0 +1,133 @@ +// Teleport +// Copyright (C) 2025 Gravitational, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package testlib + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/stretchr/testify/require" + + "github.com/gravitational/teleport/api/types/discoveryconfig" + "github.com/gravitational/teleport/api/types/header" +) + +func (s *TerraformSuiteOSS) TestDiscoveryConfig() { + t := s.T() + name := "teleport_discovery_config.test" + + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: s.terraformProviders, + PreventPostDestroyRefresh: true, + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: s.getFixture("discovery_config_0_create.tf"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(name, "spec.discovery_group", "azure_teleport"), + resource.TestCheckResourceAttr(name, "spec.azure.0.types.0", "vm"), + resource.TestCheckResourceAttr(name, "spec.azure.0.regions.0", "eastus"), + resource.TestCheckResourceAttr(name, "spec.azure.0.subscriptions.0", "123123-123123-123123-123123"), + resource.TestCheckResourceAttr(name, "spec.azure.0.resource_groups.0", "group"), + resource.TestCheckResourceAttr(name, "spec.azure.0.tags.%", "1"), + resource.TestCheckResourceAttr(name, "spec.azure.0.install_params.join_method", "azure"), + resource.TestCheckResourceAttr(name, "spec.azure.0.install_params.script_name", "default-installer"), + resource.TestCheckResourceAttr(name, "spec.azure.0.install_params.join_token", "azure-token"), + resource.TestCheckResourceAttr(name, "spec.azure.0.install_params.azure.client_id", "managed-identity-id"), + ), + }, + { + Config: s.getFixture("discovery_config_0_create.tf"), + PlanOnly: true, + }, + { + Config: s.getFixture("discovery_config_1_update.tf"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(name, "spec.discovery_group", "azure_teleport_updated"), + resource.TestCheckResourceAttr(name, "spec.azure.0.types.0", "vm"), + resource.TestCheckResourceAttr(name, "spec.azure.0.types.1", "aks"), + resource.TestCheckResourceAttr(name, "spec.azure.0.regions.0", "westus"), + resource.TestCheckResourceAttr(name, "spec.azure.0.regions.1", "eastus"), + resource.TestCheckResourceAttr(name, "spec.azure.0.subscriptions.0", "456456-456456-456456-456456"), + resource.TestCheckResourceAttr(name, "spec.azure.0.resource_groups.0", "group"), + resource.TestCheckResourceAttr(name, "spec.azure.0.resource_groups.1", "group2"), + resource.TestCheckResourceAttr(name, "spec.azure.0.tags.env.0", "prod"), + resource.TestCheckResourceAttr(name, "spec.azure.0.install_params.script_name", "updated-installer"), + resource.TestCheckResourceAttr(name, "spec.azure.0.install_params.join_token", "azure-token-updated"), + resource.TestCheckResourceAttr(name, "spec.azure.0.install_params.azure.client_id", "managed-identity-id-updated"), + ), + }, + { + Config: s.getFixture("discovery_config_1_update.tf"), + PlanOnly: true, + }, + }, + }) +} + +func (s *TerraformSuiteOSS) TestImportDiscoveryConfig() { + t := s.T() + ctx, cancel := context.WithCancel(context.Background()) + t.Cleanup(cancel) + + r := "teleport_discovery_config" + id := "test_import" + name := r + "." + id + + discoveryCfg, err := discoveryconfig.NewDiscoveryConfig( + header.Metadata{ + Name: id, + Description: "Test discovery config for import", + Labels: map[string]string{ + "purpose": "test", + }, + }, + discoveryconfig.Spec{ + DiscoveryGroup: "test_group", + }, + ) + require.NoError(t, err) + + _, err = s.client.DiscoveryConfigClient().CreateDiscoveryConfig(ctx, discoveryCfg) + require.NoError(t, err) + + existing, err := s.client.DiscoveryConfigClient().GetDiscoveryConfig(ctx, id) + require.NoError(t, err) + + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: s.terraformProviders, + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: s.terraformConfig + "\n" + `resource "` + r + `" "` + id + `" { }`, + ResourceName: name, + ImportState: true, + ImportStateId: id, + ImportStateCheck: func(state []*terraform.InstanceState) error { + require.Equal(t, existing.Metadata.Name, state[0].Attributes["header.metadata.name"]) + require.Equal(t, existing.Metadata.Description, state[0].Attributes["header.metadata.description"]) + require.Equal(t, "test", state[0].Attributes["header.metadata.labels.purpose"]) + require.Equal(t, existing.Metadata.Revision, state[0].Attributes["header.metadata.revision"]) + require.Equal(t, "test_group", state[0].Attributes["spec.discovery_group"]) + + return nil + }, + }, + }, + }) +} diff --git a/integrations/terraform/testlib/fixtures/discovery_config_0_create.tf b/integrations/terraform/testlib/fixtures/discovery_config_0_create.tf new file mode 100644 index 0000000000000..24de081f0ce91 --- /dev/null +++ b/integrations/terraform/testlib/fixtures/discovery_config_0_create.tf @@ -0,0 +1,34 @@ +resource "teleport_discovery_config" "test" { + header = { + metadata = { + name = "test" + description = "Example azure discovery config" + labels = { + foo = "bar" + } + } + version = "v1" + } + spec = { + discovery_group = "azure_teleport" + azure = [{ + types = ["vm"] + regions = ["eastus"] + subscriptions = ["123123-123123-123123-123123"] + resource_groups = ["group"] + + tags = { + "*" = ["*"] + } + + install_params = { + join_method = "azure" + script_name = "default-installer" + join_token = "azure-token" + azure = { + client_id = "managed-identity-id" + } + } + }] + } +} diff --git a/integrations/terraform/testlib/fixtures/discovery_config_1_update.tf b/integrations/terraform/testlib/fixtures/discovery_config_1_update.tf new file mode 100644 index 0000000000000..6ba3a51b85b3a --- /dev/null +++ b/integrations/terraform/testlib/fixtures/discovery_config_1_update.tf @@ -0,0 +1,36 @@ +resource "teleport_discovery_config" "test" { + header = { + metadata = { + name = "test" + description = "Updated example azure discovery config" + labels = { + foo = "baz" + } + } + version = "v1" + } + spec = { + discovery_group = "azure_teleport_updated" + azure = [{ + types = ["vm", "aks"] + regions = ["westus", "eastus"] + subscriptions = ["456456-456456-456456-456456"] + resource_groups = ["group", "group2"] + + tags = { + "env" = ["prod"] + } + + install_params = { + join_method = "azure" + script_name = "updated-installer" + join_token = "azure-token-updated" + azure = { + client_id = "managed-identity-id-updated" + } + } + }] + } +} + + diff --git a/integrations/terraform/tfschema/discoveryconfig/v1/custom_types.go b/integrations/terraform/tfschema/discoveryconfig/v1/custom_types.go new file mode 100644 index 0000000000000..f7f70a2069e03 --- /dev/null +++ b/integrations/terraform/tfschema/discoveryconfig/v1/custom_types.go @@ -0,0 +1,36 @@ +// Teleport +// Copyright (C) 2025 Gravitational, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package v1 + +import ( + "github.com/gravitational/teleport/integrations/terraform/tfschema" + "github.com/gravitational/teleport/integrations/terraform/tfschema/resource153" +) + +type DurationType = tfschema.DurationType + +type DurationValue = tfschema.DurationValue + +var ( + GenSchemaTimestamp = resource153.GenSchemaTimestamp + CopyToTimestamp = resource153.CopyToTimestamp + CopyFromTimestamp = resource153.CopyFromTimestamp + + GenSchemaLabels = resource153.GenSchemaLabels + CopyFromLabels = resource153.CopyFromLabels + CopyToLabels = resource153.CopyToLabels +) diff --git a/integrations/terraform/tfschema/discoveryconfig/v1/discoveryconfig_terraform.go b/integrations/terraform/tfschema/discoveryconfig/v1/discoveryconfig_terraform.go new file mode 100644 index 0000000000000..cf815b6ea4c06 --- /dev/null +++ b/integrations/terraform/tfschema/discoveryconfig/v1/discoveryconfig_terraform.go @@ -0,0 +1,5807 @@ +/* +Copyright 2015-2022 Gravitational, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: teleport/discoveryconfig/v1/discoveryconfig.proto + +package v1 + +import ( + context "context" + fmt "fmt" + math "math" + time "time" + + proto "github.com/gogo/protobuf/proto" + github_com_gravitational_teleport_api_gen_proto_go_teleport_discoveryconfig_v1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/discoveryconfig/v1" + _ "github.com/gravitational/teleport/api/gen/proto/go/teleport/header/v1" + github_com_gravitational_teleport_api_gen_proto_go_teleport_header_v1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/header/v1" + _ "github.com/gravitational/teleport/api/types" + github_com_gravitational_teleport_api_types "github.com/gravitational/teleport/api/types" + github_com_gravitational_teleport_integrations_terraform_tfschema "github.com/gravitational/teleport/integrations/terraform/tfschema" + github_com_hashicorp_terraform_plugin_framework_attr "github.com/hashicorp/terraform-plugin-framework/attr" + github_com_hashicorp_terraform_plugin_framework_diag "github.com/hashicorp/terraform-plugin-framework/diag" + github_com_hashicorp_terraform_plugin_framework_tfsdk "github.com/hashicorp/terraform-plugin-framework/tfsdk" + github_com_hashicorp_terraform_plugin_framework_types "github.com/hashicorp/terraform-plugin-framework/types" + github_com_hashicorp_terraform_plugin_go_tftypes "github.com/hashicorp/terraform-plugin-go/tftypes" + _ "google.golang.org/protobuf/types/known/timestamppb" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// GenSchemaDiscoveryConfig returns tfsdk.Schema definition for DiscoveryConfig +func GenSchemaDiscoveryConfig(ctx context.Context) (github_com_hashicorp_terraform_plugin_framework_tfsdk.Schema, github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics) { + return github_com_hashicorp_terraform_plugin_framework_tfsdk.Schema{Attributes: map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "header": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "kind": { + Computed: true, + Description: "kind is a resource kind.", + Optional: true, + PlanModifiers: []github_com_hashicorp_terraform_plugin_framework_tfsdk.AttributePlanModifier{github_com_hashicorp_terraform_plugin_framework_tfsdk.UseStateForUnknown()}, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "metadata": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "description": { + Description: "description is object description.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "expires": GenSchemaTimestamp(ctx, github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + Computed: true, + Description: "expires is a global expiry time header can be set on any resource in the system.", + Optional: true, + PlanModifiers: []github_com_hashicorp_terraform_plugin_framework_tfsdk.AttributePlanModifier{github_com_hashicorp_terraform_plugin_framework_tfsdk.UseStateForUnknown()}, + Validators: []github_com_hashicorp_terraform_plugin_framework_tfsdk.AttributeValidator{github_com_gravitational_teleport_integrations_terraform_tfschema.MustTimeBeInFuture()}, + }), + "labels": { + Description: "labels is a set of labels.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.MapType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + "name": { + Description: "name is an object name.", + PlanModifiers: []github_com_hashicorp_terraform_plugin_framework_tfsdk.AttributePlanModifier{github_com_hashicorp_terraform_plugin_framework_tfsdk.RequiresReplace()}, + Required: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "namespace": { + Computed: true, + Description: "namespace is object namespace. The field should be called \"namespace\" when it returns in Teleport 2.4.", + Optional: true, + PlanModifiers: []github_com_hashicorp_terraform_plugin_framework_tfsdk.AttributePlanModifier{github_com_hashicorp_terraform_plugin_framework_tfsdk.UseStateForUnknown()}, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "revision": { + Computed: true, + Description: "revision is an opaque identifier which tracks the versions of a resource over time. Clients should ignore and not alter its value but must return the revision in any updates of a resource.", + Optional: true, + PlanModifiers: []github_com_hashicorp_terraform_plugin_framework_tfsdk.AttributePlanModifier{github_com_hashicorp_terraform_plugin_framework_tfsdk.UseStateForUnknown()}, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "metadata is resource metadata.", + Required: true, + }, + "sub_kind": { + Computed: true, + Description: "sub_kind is an optional resource sub kind, used in some resources.", + Optional: true, + PlanModifiers: []github_com_hashicorp_terraform_plugin_framework_tfsdk.AttributePlanModifier{github_com_hashicorp_terraform_plugin_framework_tfsdk.UseStateForUnknown()}, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "version": { + Description: "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`", + Required: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "Header is the resource header.", + Required: true, + }, + "id": { + Computed: true, + Optional: false, + PlanModifiers: []github_com_hashicorp_terraform_plugin_framework_tfsdk.AttributePlanModifier{github_com_hashicorp_terraform_plugin_framework_tfsdk.UseStateForUnknown()}, + Required: false, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "spec": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "access_graph": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "aws": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.ListNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "assume_role": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "external_id": { + Description: "ExternalID is the external ID used to assume a role in another account.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "role_arn": { + Description: "RoleARN is the fully specified AWS IAM role ARN.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "AssumeRoleARN is the AWS role to assume for database discovery.", + Optional: true, + }, + "cloud_trail_logs": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "region": { + Description: "The AWS region of the SQS queue for CloudTrail notifications, ex.: \"us-east-2\".", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "sqs_queue": { + Description: "The name or URL for CloudTrail log events, ex.: \"demo-cloudtrail-queue\".", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "Configuration settings for collecting AWS CloudTrail logs via an SQS queue.", + Optional: true, + }, + "eks_audit_logs": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{"tags": GenSchemaLabels(ctx, github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + Description: "The tags of EKS clusters for which apiserver audit logs should be fetched.", + Optional: true, + })}), + Description: "", + Optional: true, + }, + "integration": { + Description: "Integration is the integration name used to generate credentials to interact with AWS APIs.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "regions": { + Description: "Regions are AWS regions to import resources from.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + }), + Description: "AWS is a configuration for AWS Access Graph service poll service.", + Optional: true, + }, + "azure": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.ListNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "integration": { + Description: "Integration is the integration name used to generate credentials to interact with AWS APIs.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "subscription_id": { + Description: "SubscriptionID Is the ID of the Azure subscription to sync resources from", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "Azure is a configuration for Azure Access Graph service poll service.", + Optional: true, + }, + "poll_interval": { + Description: "PollInterval is the frequency at which to poll for resources", + Optional: true, + Type: DurationType{}, + }, + }), + Description: "AccessGraph is the configurations for syncing Cloud accounts into Access Graph.", + Optional: true, + }, + "aws": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.ListNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "assume_role": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "external_id": { + Description: "ExternalID is the external ID used to assume a role in another account.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "role_arn": { + Description: "RoleARN is the fully specified AWS IAM role ARN.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "AssumeRoleARN is the AWS role to assume for database discovery.", + Optional: true, + }, + "install": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "azure": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{"client_id": { + Description: "ClientID is the client ID of the managed identity discovered nodes should use to join the cluster.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }}), + Description: "Azure is the set of Azure-specific installation parameters.", + Optional: true, + }, + "enroll_mode": { + Description: "EnrollMode indicates the enrollment mode to be used when adding a node. Valid values: 0: uses eice for EC2 matchers which use an integration and script for all the other methods 1: uses script mode 2: uses eice mode (deprecated)", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.Int64Type, + }, + "http_proxy_settings": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "http_proxy": { + Description: "HTTPProxy is the URL for the HTTP proxy to use when making requests. When applied, this will set the HTTP_PROXY environment variable.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "https_proxy": { + Description: "HTTPSProxy is the URL for the HTTPS Proxy to use when making requests. When applied, this will set the HTTPS_PROXY environment variable.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "no_proxy": { + Description: "NoProxy is a comma separated list of URLs that will be excluded from proxying. When applied, this will set the NO_PROXY environment variable.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "HTTPProxySettings defines HTTP proxy settings for making HTTP requests. When set, this will set the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables before running the installation.", + Optional: true, + }, + "install_teleport": { + Description: "InstallTeleport disables agentless discovery", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.BoolType, + }, + "join_method": { + Description: "JoinMethod is the method to use when joining the cluster", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "join_token": { + Description: "JoinToken is the token to use when joining the cluster", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "proxy_addr": { + Description: "PublicProxyAddr is the address of the proxy the discovered node should use to connect to the cluster.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "script_name": { + Description: "ScriptName is the name of the teleport installer script resource for the cloud instance to execute", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "sshd_config": { + Description: "SSHDConfig provides the path to write sshd configuration changes", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "suffix": { + Description: "Suffix indicates the installation suffix for the teleport installation. Set this value if you want multiple installations of Teleport. See --install-suffix flag in teleport-update program. Note: only supported for Amazon EC2. Suffix name can only contain alphanumeric characters and hyphens.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "update_group": { + Description: "UpdateGroup indicates the update group for the teleport installation. This value is used to group installations in order to update them in batches. See --group flag in teleport-update program. Note: only supported for Amazon EC2. Group name can only contain alphanumeric characters and hyphens.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "Params sets the join method when installing on discovered EC2 nodes", + Optional: true, + }, + "integration": { + Description: "Integration is the integration name used to generate credentials to interact with AWS APIs. Environment credentials will not be used when this value is set.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "kube_app_discovery": { + Description: "KubeAppDiscovery controls whether Kubernetes App Discovery will be enabled for agents running on discovered clusters, currently only affects AWS EKS discovery in integration mode.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.BoolType, + }, + "regions": { + Description: "Regions are AWS regions to query for databases.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + "setup_access_for_arn": { + Description: "SetupAccessForARN is the role that the Discovery Service should create EKS Access Entries for. This value should match the IAM identity that Teleport Kubernetes Service uses. If this value is empty, the Discovery Service will attempt to set up access for its own identity (self).", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "ssm": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{"document_name": { + Description: "DocumentName is the name of the document to use when executing an SSM command", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }}), + Description: "SSM provides options to use when sending a document command to an EC2 node", + Optional: true, + }, + "tags": GenSchemaLabels(ctx, github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + Description: "Tags are AWS resource Tags to match.", + Optional: true, + }), + "types": { + Description: "Types are AWS database types to match, \"ec2\", \"rds\", \"redshift\", \"elasticache\", or \"memorydb\".", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + }), + Description: "AWS is a list of AWS Matchers.", + Optional: true, + }, + "azure": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.ListNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "install_params": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "azure": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{"client_id": { + Description: "ClientID is the client ID of the managed identity discovered nodes should use to join the cluster.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }}), + Description: "Azure is the set of Azure-specific installation parameters.", + Optional: true, + }, + "enroll_mode": { + Description: "EnrollMode indicates the enrollment mode to be used when adding a node. Valid values: 0: uses eice for EC2 matchers which use an integration and script for all the other methods 1: uses script mode 2: uses eice mode (deprecated)", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.Int64Type, + }, + "http_proxy_settings": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "http_proxy": { + Description: "HTTPProxy is the URL for the HTTP proxy to use when making requests. When applied, this will set the HTTP_PROXY environment variable.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "https_proxy": { + Description: "HTTPSProxy is the URL for the HTTPS Proxy to use when making requests. When applied, this will set the HTTPS_PROXY environment variable.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "no_proxy": { + Description: "NoProxy is a comma separated list of URLs that will be excluded from proxying. When applied, this will set the NO_PROXY environment variable.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "HTTPProxySettings defines HTTP proxy settings for making HTTP requests. When set, this will set the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables before running the installation.", + Optional: true, + }, + "install_teleport": { + Description: "InstallTeleport disables agentless discovery", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.BoolType, + }, + "join_method": { + Description: "JoinMethod is the method to use when joining the cluster", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "join_token": { + Description: "JoinToken is the token to use when joining the cluster", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "proxy_addr": { + Description: "PublicProxyAddr is the address of the proxy the discovered node should use to connect to the cluster.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "script_name": { + Description: "ScriptName is the name of the teleport installer script resource for the cloud instance to execute", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "sshd_config": { + Description: "SSHDConfig provides the path to write sshd configuration changes", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "suffix": { + Description: "Suffix indicates the installation suffix for the teleport installation. Set this value if you want multiple installations of Teleport. See --install-suffix flag in teleport-update program. Note: only supported for Amazon EC2. Suffix name can only contain alphanumeric characters and hyphens.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "update_group": { + Description: "UpdateGroup indicates the update group for the teleport installation. This value is used to group installations in order to update them in batches. See --group flag in teleport-update program. Note: only supported for Amazon EC2. Group name can only contain alphanumeric characters and hyphens.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "Params sets the join method when installing on discovered Azure nodes.", + Optional: true, + }, + "integration": { + Description: "Integration is the integration name used to generate credentials to interact with Azure APIs. Environment credentials will not be used when this value is set.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "regions": { + Description: "Regions are Azure locations to match for databases.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + "resource_groups": { + Description: "ResourceGroups are Azure resource groups to query for resources.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + "subscriptions": { + Description: "Subscriptions are Azure subscriptions to query for resources.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + "tags": GenSchemaLabels(ctx, github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + Description: "ResourceTags are Azure tags on resources to match.", + Optional: true, + }), + "types": { + Description: "Types are Azure types to match: \"mysql\", \"postgres\", \"aks\", \"vm\"", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + }), + Description: "Azure is a list of Azure Matchers.", + Optional: true, + }, + "discovery_group": { + Description: "DiscoveryGroup is used by discovery_service to add extra matchers. All the discovery_services that have the same discovery_group, will load the matchers of this resource.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "gcp": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.ListNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "install_params": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "azure": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{"client_id": { + Description: "ClientID is the client ID of the managed identity discovered nodes should use to join the cluster.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }}), + Description: "Azure is the set of Azure-specific installation parameters.", + Optional: true, + }, + "enroll_mode": { + Description: "EnrollMode indicates the enrollment mode to be used when adding a node. Valid values: 0: uses eice for EC2 matchers which use an integration and script for all the other methods 1: uses script mode 2: uses eice mode (deprecated)", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.Int64Type, + }, + "http_proxy_settings": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.SingleNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "http_proxy": { + Description: "HTTPProxy is the URL for the HTTP proxy to use when making requests. When applied, this will set the HTTP_PROXY environment variable.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "https_proxy": { + Description: "HTTPSProxy is the URL for the HTTPS Proxy to use when making requests. When applied, this will set the HTTPS_PROXY environment variable.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "no_proxy": { + Description: "NoProxy is a comma separated list of URLs that will be excluded from proxying. When applied, this will set the NO_PROXY environment variable.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "HTTPProxySettings defines HTTP proxy settings for making HTTP requests. When set, this will set the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables before running the installation.", + Optional: true, + }, + "install_teleport": { + Description: "InstallTeleport disables agentless discovery", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.BoolType, + }, + "join_method": { + Description: "JoinMethod is the method to use when joining the cluster", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "join_token": { + Description: "JoinToken is the token to use when joining the cluster", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "proxy_addr": { + Description: "PublicProxyAddr is the address of the proxy the discovered node should use to connect to the cluster.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "script_name": { + Description: "ScriptName is the name of the teleport installer script resource for the cloud instance to execute", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "sshd_config": { + Description: "SSHDConfig provides the path to write sshd configuration changes", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "suffix": { + Description: "Suffix indicates the installation suffix for the teleport installation. Set this value if you want multiple installations of Teleport. See --install-suffix flag in teleport-update program. Note: only supported for Amazon EC2. Suffix name can only contain alphanumeric characters and hyphens.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + "update_group": { + Description: "UpdateGroup indicates the update group for the teleport installation. This value is used to group installations in order to update them in batches. See --group flag in teleport-update program. Note: only supported for Amazon EC2. Group name can only contain alphanumeric characters and hyphens.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.StringType, + }, + }), + Description: "Params sets the join method when installing on discovered GCP nodes.", + Optional: true, + }, + "labels": GenSchemaLabels(ctx, github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + Description: "Labels are GCP labels to match.", + Optional: true, + }), + "locations": { + Description: "Locations are GKE locations to search resources for.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + "project_ids": { + Description: "ProjectIDs are the GCP project ID where the resources are deployed.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + "service_accounts": { + Description: "ServiceAccounts are the emails of service accounts attached to VMs.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + "tags": GenSchemaLabels(ctx, github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + Description: "Tags is obsolete and only exists for backwards compatibility. Use Labels instead.", + Optional: true, + }), + "types": { + Description: "Types are GKE resource types to match: \"gke\", \"vm\".", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + }), + Description: "GCP is a list of GCP Matchers.", + Optional: true, + }, + "kube": { + Attributes: github_com_hashicorp_terraform_plugin_framework_tfsdk.ListNestedAttributes(map[string]github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + "labels": GenSchemaLabels(ctx, github_com_hashicorp_terraform_plugin_framework_tfsdk.Attribute{ + Description: "Labels are Kubernetes services labels to match.", + Optional: true, + }), + "namespaces": { + Description: "Namespaces are Kubernetes namespaces in which to discover services", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + "types": { + Description: "Types are Kubernetes services types to match. Currently only 'app' is supported.", + Optional: true, + Type: github_com_hashicorp_terraform_plugin_framework_types.ListType{ElemType: github_com_hashicorp_terraform_plugin_framework_types.StringType}, + }, + }), + Description: "Kube is a list of Kubernetes Matchers.", + Optional: true, + }, + }), + Description: "Spec is an DiscoveryConfig specification.", + Required: true, + }, + }}, nil +} + +// CopyDiscoveryConfigFromTerraform copies contents of the source Terraform object into a target struct +func CopyDiscoveryConfigFromTerraform(_ context.Context, tf github_com_hashicorp_terraform_plugin_framework_types.Object, obj *github_com_gravitational_teleport_api_gen_proto_go_teleport_discoveryconfig_v1.DiscoveryConfig) github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics { + var diags github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics + { + a, ok := tf.Attrs["header"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.header"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.header", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.Header = nil + if !v.Null && !v.Unknown { + tf := v + obj.Header = &github_com_gravitational_teleport_api_gen_proto_go_teleport_header_v1.ResourceHeader{} + obj := obj.Header + { + a, ok := tf.Attrs["kind"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.header.kind"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.header.kind", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Kind = t + } + } + } + { + a, ok := tf.Attrs["sub_kind"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.header.sub_kind"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.header.sub_kind", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SubKind = t + } + } + } + { + a, ok := tf.Attrs["version"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.header.version"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.header.version", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Version = t + } + } + } + { + a, ok := tf.Attrs["metadata"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.header.metadata"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.header.metadata", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.Metadata = nil + if !v.Null && !v.Unknown { + tf := v + obj.Metadata = &github_com_gravitational_teleport_api_gen_proto_go_teleport_header_v1.Metadata{} + obj := obj.Metadata + { + a, ok := tf.Attrs["name"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.header.metadata.name"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.header.metadata.name", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Name = t + } + } + } + { + a, ok := tf.Attrs["namespace"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.header.metadata.namespace"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.header.metadata.namespace", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Namespace = t + } + } + } + { + a, ok := tf.Attrs["description"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.header.metadata.description"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.header.metadata.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Description = t + } + } + } + { + a, ok := tf.Attrs["labels"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.header.metadata.labels"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Map) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.header.metadata.labels", "github.com/hashicorp/terraform-plugin-framework/types.Map"}) + } else { + obj.Labels = make(map[string]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.header.metadata.labels", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Labels[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["expires"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.header.metadata.expires"}) + } + CopyFromTimestamp(diags, a, &obj.Expires) + } + { + a, ok := tf.Attrs["revision"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.header.metadata.revision"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.header.metadata.revision", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Revision = t + } + } + } + } + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["spec"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.Spec = nil + if !v.Null && !v.Unknown { + tf := v + obj.Spec = &github_com_gravitational_teleport_api_gen_proto_go_teleport_discoveryconfig_v1.DiscoveryConfigSpec{} + obj := obj.Spec + { + a, ok := tf.Attrs["discovery_group"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.discovery_group"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.discovery_group", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.DiscoveryGroup = t + } + } + } + { + a, ok := tf.Attrs["aws"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Aws = make([]*github_com_gravitational_teleport_api_types.AWSMatcher, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws", "github_com_hashicorp_terraform_plugin_framework_types.Object"}) + } else { + var t *github_com_gravitational_teleport_api_types.AWSMatcher + if !v.Null && !v.Unknown { + tf := v + t = &github_com_gravitational_teleport_api_types.AWSMatcher{} + obj := t + { + a, ok := tf.Attrs["types"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Types"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Types", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Types = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Types", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Types[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["regions"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Regions"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Regions", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Regions = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Regions", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Regions[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["assume_role"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.AssumeRole"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.AssumeRole", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.AssumeRole = nil + if !v.Null && !v.Unknown { + tf := v + obj.AssumeRole = &github_com_gravitational_teleport_api_types.AssumeRole{} + obj := obj.AssumeRole + { + a, ok := tf.Attrs["role_arn"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.AssumeRole.RoleARN"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.AssumeRole.RoleARN", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.RoleARN = t + } + } + } + { + a, ok := tf.Attrs["external_id"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.AssumeRole.ExternalID"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.AssumeRole.ExternalID", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ExternalID = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["tags"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Tags"}) + } + CopyFromLabels(diags, a, &obj.Tags) + } + { + a, ok := tf.Attrs["install"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.Params = nil + if !v.Null && !v.Unknown { + tf := v + obj.Params = &github_com_gravitational_teleport_api_types.InstallerParams{} + obj := obj.Params + { + a, ok := tf.Attrs["join_method"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.JoinMethod"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.JoinMethod", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t github_com_gravitational_teleport_api_types.JoinMethod + if !v.Null && !v.Unknown { + t = github_com_gravitational_teleport_api_types.JoinMethod(v.Value) + } + obj.JoinMethod = t + } + } + } + { + a, ok := tf.Attrs["join_token"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.JoinToken"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.JoinToken", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.JoinToken = t + } + } + } + { + a, ok := tf.Attrs["script_name"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.ScriptName"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.ScriptName", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ScriptName = t + } + } + } + { + a, ok := tf.Attrs["install_teleport"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.InstallTeleport"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Bool) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.InstallTeleport", "github.com/hashicorp/terraform-plugin-framework/types.Bool"}) + } else { + var t bool + if !v.Null && !v.Unknown { + t = bool(v.Value) + } + obj.InstallTeleport = t + } + } + } + { + a, ok := tf.Attrs["sshd_config"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.SSHDConfig"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.SSHDConfig", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SSHDConfig = t + } + } + } + { + a, ok := tf.Attrs["proxy_addr"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.PublicProxyAddr"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.PublicProxyAddr", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PublicProxyAddr = t + } + } + } + { + a, ok := tf.Attrs["azure"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.Azure"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.Azure", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.Azure = nil + if !v.Null && !v.Unknown { + tf := v + obj.Azure = &github_com_gravitational_teleport_api_types.AzureInstallerParams{} + obj := obj.Azure + { + a, ok := tf.Attrs["client_id"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.Azure.ClientID"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.Azure.ClientID", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ClientID = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["enroll_mode"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.EnrollMode"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Int64) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.EnrollMode", "github.com/hashicorp/terraform-plugin-framework/types.Int64"}) + } else { + var t github_com_gravitational_teleport_api_types.InstallParamEnrollMode + if !v.Null && !v.Unknown { + t = github_com_gravitational_teleport_api_types.InstallParamEnrollMode(v.Value) + } + obj.EnrollMode = t + } + } + } + { + a, ok := tf.Attrs["suffix"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.Suffix"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.Suffix", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Suffix = t + } + } + } + { + a, ok := tf.Attrs["update_group"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.UpdateGroup"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.UpdateGroup", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.UpdateGroup = t + } + } + } + { + a, ok := tf.Attrs["http_proxy_settings"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.HTTPProxySettings = nil + if !v.Null && !v.Unknown { + tf := v + obj.HTTPProxySettings = &github_com_gravitational_teleport_api_types.HTTPProxySettings{} + obj := obj.HTTPProxySettings + { + a, ok := tf.Attrs["http_proxy"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.HTTPProxy"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.HTTPProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.HTTPProxy = t + } + } + } + { + a, ok := tf.Attrs["https_proxy"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.HTTPSProxy"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.HTTPSProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.HTTPSProxy = t + } + } + } + { + a, ok := tf.Attrs["no_proxy"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.NoProxy"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.NoProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NoProxy = t + } + } + } + } + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["ssm"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.SSM"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.SSM", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.SSM = nil + if !v.Null && !v.Unknown { + tf := v + obj.SSM = &github_com_gravitational_teleport_api_types.AWSSSM{} + obj := obj.SSM + { + a, ok := tf.Attrs["document_name"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.SSM.DocumentName"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.SSM.DocumentName", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.DocumentName = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["integration"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.Integration"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.Integration", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Integration = t + } + } + } + { + a, ok := tf.Attrs["kube_app_discovery"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.KubeAppDiscovery"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Bool) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.KubeAppDiscovery", "github.com/hashicorp/terraform-plugin-framework/types.Bool"}) + } else { + var t bool + if !v.Null && !v.Unknown { + t = bool(v.Value) + } + obj.KubeAppDiscovery = t + } + } + } + { + a, ok := tf.Attrs["setup_access_for_arn"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.aws.SetupAccessForARN"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.aws.SetupAccessForARN", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SetupAccessForARN = t + } + } + } + } + obj.Aws[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["azure"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Azure = make([]*github_com_gravitational_teleport_api_types.AzureMatcher, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure", "github_com_hashicorp_terraform_plugin_framework_types.Object"}) + } else { + var t *github_com_gravitational_teleport_api_types.AzureMatcher + if !v.Null && !v.Unknown { + tf := v + t = &github_com_gravitational_teleport_api_types.AzureMatcher{} + obj := t + { + a, ok := tf.Attrs["subscriptions"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Subscriptions"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Subscriptions", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Subscriptions = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Subscriptions", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Subscriptions[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["resource_groups"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.ResourceGroups"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.ResourceGroups", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.ResourceGroups = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.ResourceGroups", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ResourceGroups[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["types"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Types"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Types", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Types = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Types", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Types[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["regions"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Regions"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Regions", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Regions = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Regions", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Regions[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["tags"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.ResourceTags"}) + } + CopyFromLabels(diags, a, &obj.ResourceTags) + } + { + a, ok := tf.Attrs["install_params"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.Params = nil + if !v.Null && !v.Unknown { + tf := v + obj.Params = &github_com_gravitational_teleport_api_types.InstallerParams{} + obj := obj.Params + { + a, ok := tf.Attrs["join_method"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.JoinMethod"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.JoinMethod", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t github_com_gravitational_teleport_api_types.JoinMethod + if !v.Null && !v.Unknown { + t = github_com_gravitational_teleport_api_types.JoinMethod(v.Value) + } + obj.JoinMethod = t + } + } + } + { + a, ok := tf.Attrs["join_token"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.JoinToken"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.JoinToken", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.JoinToken = t + } + } + } + { + a, ok := tf.Attrs["script_name"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.ScriptName"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.ScriptName", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ScriptName = t + } + } + } + { + a, ok := tf.Attrs["install_teleport"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.InstallTeleport"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Bool) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.InstallTeleport", "github.com/hashicorp/terraform-plugin-framework/types.Bool"}) + } else { + var t bool + if !v.Null && !v.Unknown { + t = bool(v.Value) + } + obj.InstallTeleport = t + } + } + } + { + a, ok := tf.Attrs["sshd_config"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.SSHDConfig"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.SSHDConfig", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SSHDConfig = t + } + } + } + { + a, ok := tf.Attrs["proxy_addr"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.PublicProxyAddr"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.PublicProxyAddr", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PublicProxyAddr = t + } + } + } + { + a, ok := tf.Attrs["azure"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.Azure"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.Azure", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.Azure = nil + if !v.Null && !v.Unknown { + tf := v + obj.Azure = &github_com_gravitational_teleport_api_types.AzureInstallerParams{} + obj := obj.Azure + { + a, ok := tf.Attrs["client_id"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.Azure.ClientID"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.Azure.ClientID", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ClientID = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["enroll_mode"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.EnrollMode"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Int64) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.EnrollMode", "github.com/hashicorp/terraform-plugin-framework/types.Int64"}) + } else { + var t github_com_gravitational_teleport_api_types.InstallParamEnrollMode + if !v.Null && !v.Unknown { + t = github_com_gravitational_teleport_api_types.InstallParamEnrollMode(v.Value) + } + obj.EnrollMode = t + } + } + } + { + a, ok := tf.Attrs["suffix"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.Suffix"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.Suffix", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Suffix = t + } + } + } + { + a, ok := tf.Attrs["update_group"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.UpdateGroup"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.UpdateGroup", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.UpdateGroup = t + } + } + } + { + a, ok := tf.Attrs["http_proxy_settings"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.HTTPProxySettings = nil + if !v.Null && !v.Unknown { + tf := v + obj.HTTPProxySettings = &github_com_gravitational_teleport_api_types.HTTPProxySettings{} + obj := obj.HTTPProxySettings + { + a, ok := tf.Attrs["http_proxy"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.HTTPProxy"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.HTTPProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.HTTPProxy = t + } + } + } + { + a, ok := tf.Attrs["https_proxy"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.HTTPSProxy"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.HTTPSProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.HTTPSProxy = t + } + } + } + { + a, ok := tf.Attrs["no_proxy"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.NoProxy"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.NoProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NoProxy = t + } + } + } + } + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["integration"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.azure.Integration"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.azure.Integration", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Integration = t + } + } + } + } + obj.Azure[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["gcp"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Gcp = make([]*github_com_gravitational_teleport_api_types.GCPMatcher, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp", "github_com_hashicorp_terraform_plugin_framework_types.Object"}) + } else { + var t *github_com_gravitational_teleport_api_types.GCPMatcher + if !v.Null && !v.Unknown { + tf := v + t = &github_com_gravitational_teleport_api_types.GCPMatcher{} + obj := t + { + a, ok := tf.Attrs["types"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Types"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Types", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Types = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Types", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Types[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["locations"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Locations"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Locations", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Locations = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Locations", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Locations[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["tags"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Tags"}) + } + CopyFromLabels(diags, a, &obj.Tags) + } + { + a, ok := tf.Attrs["project_ids"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.ProjectIDs"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.ProjectIDs", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.ProjectIDs = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.ProjectIDs", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ProjectIDs[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["service_accounts"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.ServiceAccounts"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.ServiceAccounts", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.ServiceAccounts = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.ServiceAccounts", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ServiceAccounts[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["install_params"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.Params = nil + if !v.Null && !v.Unknown { + tf := v + obj.Params = &github_com_gravitational_teleport_api_types.InstallerParams{} + obj := obj.Params + { + a, ok := tf.Attrs["join_method"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.JoinMethod"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.JoinMethod", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t github_com_gravitational_teleport_api_types.JoinMethod + if !v.Null && !v.Unknown { + t = github_com_gravitational_teleport_api_types.JoinMethod(v.Value) + } + obj.JoinMethod = t + } + } + } + { + a, ok := tf.Attrs["join_token"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.JoinToken"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.JoinToken", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.JoinToken = t + } + } + } + { + a, ok := tf.Attrs["script_name"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.ScriptName"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.ScriptName", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ScriptName = t + } + } + } + { + a, ok := tf.Attrs["install_teleport"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.InstallTeleport"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Bool) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.InstallTeleport", "github.com/hashicorp/terraform-plugin-framework/types.Bool"}) + } else { + var t bool + if !v.Null && !v.Unknown { + t = bool(v.Value) + } + obj.InstallTeleport = t + } + } + } + { + a, ok := tf.Attrs["sshd_config"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.SSHDConfig"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.SSHDConfig", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SSHDConfig = t + } + } + } + { + a, ok := tf.Attrs["proxy_addr"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.PublicProxyAddr"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.PublicProxyAddr", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.PublicProxyAddr = t + } + } + } + { + a, ok := tf.Attrs["azure"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.Azure"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.Azure", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.Azure = nil + if !v.Null && !v.Unknown { + tf := v + obj.Azure = &github_com_gravitational_teleport_api_types.AzureInstallerParams{} + obj := obj.Azure + { + a, ok := tf.Attrs["client_id"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.Azure.ClientID"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.Azure.ClientID", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ClientID = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["enroll_mode"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.EnrollMode"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Int64) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.EnrollMode", "github.com/hashicorp/terraform-plugin-framework/types.Int64"}) + } else { + var t github_com_gravitational_teleport_api_types.InstallParamEnrollMode + if !v.Null && !v.Unknown { + t = github_com_gravitational_teleport_api_types.InstallParamEnrollMode(v.Value) + } + obj.EnrollMode = t + } + } + } + { + a, ok := tf.Attrs["suffix"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.Suffix"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.Suffix", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Suffix = t + } + } + } + { + a, ok := tf.Attrs["update_group"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.UpdateGroup"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.UpdateGroup", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.UpdateGroup = t + } + } + } + { + a, ok := tf.Attrs["http_proxy_settings"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.HTTPProxySettings = nil + if !v.Null && !v.Unknown { + tf := v + obj.HTTPProxySettings = &github_com_gravitational_teleport_api_types.HTTPProxySettings{} + obj := obj.HTTPProxySettings + { + a, ok := tf.Attrs["http_proxy"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.HTTPProxy"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.HTTPProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.HTTPProxy = t + } + } + } + { + a, ok := tf.Attrs["https_proxy"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.HTTPSProxy"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.HTTPSProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.HTTPSProxy = t + } + } + } + { + a, ok := tf.Attrs["no_proxy"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.NoProxy"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.NoProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.NoProxy = t + } + } + } + } + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["labels"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.gcp.Labels"}) + } + CopyFromLabels(diags, a, &obj.Labels) + } + } + obj.Gcp[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["kube"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.kube"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.kube", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Kube = make([]*github_com_gravitational_teleport_api_types.KubernetesMatcher, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.kube", "github_com_hashicorp_terraform_plugin_framework_types.Object"}) + } else { + var t *github_com_gravitational_teleport_api_types.KubernetesMatcher + if !v.Null && !v.Unknown { + tf := v + t = &github_com_gravitational_teleport_api_types.KubernetesMatcher{} + obj := t + { + a, ok := tf.Attrs["types"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.kube.Types"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.kube.Types", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Types = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.kube.Types", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Types[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["namespaces"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.kube.Namespaces"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.kube.Namespaces", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Namespaces = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.kube.Namespaces", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Namespaces[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["labels"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.kube.Labels"}) + } + CopyFromLabels(diags, a, &obj.Labels) + } + } + obj.Kube[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["access_graph"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.AccessGraph = nil + if !v.Null && !v.Unknown { + tf := v + obj.AccessGraph = &github_com_gravitational_teleport_api_types.AccessGraphSync{} + obj := obj.AccessGraph + { + a, ok := tf.Attrs["aws"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.AWS"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.AWS = make([]*github_com_gravitational_teleport_api_types.AccessGraphAWSSync, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS", "github_com_hashicorp_terraform_plugin_framework_types.Object"}) + } else { + var t *github_com_gravitational_teleport_api_types.AccessGraphAWSSync + if !v.Null && !v.Unknown { + tf := v + t = &github_com_gravitational_teleport_api_types.AccessGraphAWSSync{} + obj := t + { + a, ok := tf.Attrs["regions"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.Regions"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.Regions", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Regions = make([]string, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.Regions", "github_com_hashicorp_terraform_plugin_framework_types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Regions[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["assume_role"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.AssumeRole = nil + if !v.Null && !v.Unknown { + tf := v + obj.AssumeRole = &github_com_gravitational_teleport_api_types.AssumeRole{} + obj := obj.AssumeRole + { + a, ok := tf.Attrs["role_arn"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole.RoleARN"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole.RoleARN", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.RoleARN = t + } + } + } + { + a, ok := tf.Attrs["external_id"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole.ExternalID"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole.ExternalID", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.ExternalID = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["integration"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.Integration"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.Integration", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Integration = t + } + } + } + { + a, ok := tf.Attrs["cloud_trail_logs"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.CloudTrailLogs = nil + if !v.Null && !v.Unknown { + tf := v + obj.CloudTrailLogs = &github_com_gravitational_teleport_api_types.AccessGraphAWSSyncCloudTrailLogs{} + obj := obj.CloudTrailLogs + { + a, ok := tf.Attrs["region"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs.Region"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs.Region", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Region = t + } + } + } + { + a, ok := tf.Attrs["sqs_queue"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs.SQSQueue"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs.SQSQueue", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SQSQueue = t + } + } + } + } + } + } + } + { + a, ok := tf.Attrs["eks_audit_logs"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.eks_audit_logs"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.eks_audit_logs", "github.com/hashicorp/terraform-plugin-framework/types.Object"}) + } else { + obj.EksAuditLogs = nil + if !v.Null && !v.Unknown { + tf := v + obj.EksAuditLogs = &github_com_gravitational_teleport_api_types.AccessGraphAWSSyncEKSAuditLogs{} + obj := obj.EksAuditLogs + { + a, ok := tf.Attrs["tags"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.eks_audit_logs.Tags"}) + } + CopyFromLabels(diags, a, &obj.Tags) + } + } + } + } + } + } + obj.AWS[k] = t + } + } + } + } + } + } + { + a, ok := tf.Attrs["poll_interval"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.PollInterval"}) + } else { + v, ok := a.(DurationValue) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.PollInterval", "DurationValue"}) + } else { + var t time.Duration + if !v.Null && !v.Unknown { + t = time.Duration(v.Value) + } + obj.PollInterval = t + } + } + } + { + a, ok := tf.Attrs["azure"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.Azure"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.Azure", "github.com/hashicorp/terraform-plugin-framework/types.List"}) + } else { + obj.Azure = make([]*github_com_gravitational_teleport_api_types.AccessGraphAzureSync, len(v.Elems)) + if !v.Null && !v.Unknown { + for k, a := range v.Elems { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.Azure", "github_com_hashicorp_terraform_plugin_framework_types.Object"}) + } else { + var t *github_com_gravitational_teleport_api_types.AccessGraphAzureSync + if !v.Null && !v.Unknown { + tf := v + t = &github_com_gravitational_teleport_api_types.AccessGraphAzureSync{} + obj := t + { + a, ok := tf.Attrs["subscription_id"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.Azure.SubscriptionID"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.Azure.SubscriptionID", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.SubscriptionID = t + } + } + } + { + a, ok := tf.Attrs["integration"] + if !ok { + diags.Append(attrReadMissingDiag{"DiscoveryConfig.spec.access_graph.Azure.Integration"}) + } else { + v, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrReadConversionFailureDiag{"DiscoveryConfig.spec.access_graph.Azure.Integration", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } else { + var t string + if !v.Null && !v.Unknown { + t = string(v.Value) + } + obj.Integration = t + } + } + } + } + obj.Azure[k] = t + } + } + } + } + } + } + } + } + } + } + } + } + } + } + return diags +} + +// CopyDiscoveryConfigToTerraform copies contents of the source Terraform object into a target struct +func CopyDiscoveryConfigToTerraform(ctx context.Context, obj *github_com_gravitational_teleport_api_gen_proto_go_teleport_discoveryconfig_v1.DiscoveryConfig, tf *github_com_hashicorp_terraform_plugin_framework_types.Object) github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics { + var diags github_com_hashicorp_terraform_plugin_framework_diag.Diagnostics + tf.Null = false + tf.Unknown = false + if tf.Attrs == nil { + tf.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value) + } + { + a, ok := tf.AttrTypes["header"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.header"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.header", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["header"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.Header == nil { + v.Null = true + } else { + obj := obj.Header + tf := &v + { + t, ok := tf.AttrTypes["kind"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.header.kind"}) + } else { + v, ok := tf.Attrs["kind"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.header.kind", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.header.kind", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Kind) == "" + } + v.Value = string(obj.Kind) + v.Unknown = false + tf.Attrs["kind"] = v + } + } + { + t, ok := tf.AttrTypes["sub_kind"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.header.sub_kind"}) + } else { + v, ok := tf.Attrs["sub_kind"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.header.sub_kind", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.header.sub_kind", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SubKind) == "" + } + v.Value = string(obj.SubKind) + v.Unknown = false + tf.Attrs["sub_kind"] = v + } + } + { + t, ok := tf.AttrTypes["version"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.header.version"}) + } else { + v, ok := tf.Attrs["version"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.header.version", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.header.version", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Version) == "" + } + v.Value = string(obj.Version) + v.Unknown = false + tf.Attrs["version"] = v + } + } + { + a, ok := tf.AttrTypes["metadata"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.header.metadata"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.header.metadata", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["metadata"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.Metadata == nil { + v.Null = true + } else { + obj := obj.Metadata + tf := &v + { + t, ok := tf.AttrTypes["name"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.header.metadata.name"}) + } else { + v, ok := tf.Attrs["name"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.header.metadata.name", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.header.metadata.name", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Name) == "" + } + v.Value = string(obj.Name) + v.Unknown = false + tf.Attrs["name"] = v + } + } + { + t, ok := tf.AttrTypes["namespace"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.header.metadata.namespace"}) + } else { + v, ok := tf.Attrs["namespace"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.header.metadata.namespace", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.header.metadata.namespace", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Namespace) == "" + } + v.Value = string(obj.Namespace) + v.Unknown = false + tf.Attrs["namespace"] = v + } + } + { + t, ok := tf.AttrTypes["description"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.header.metadata.description"}) + } else { + v, ok := tf.Attrs["description"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.header.metadata.description", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.header.metadata.description", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Description) == "" + } + v.Value = string(obj.Description) + v.Unknown = false + tf.Attrs["description"] = v + } + } + { + a, ok := tf.AttrTypes["labels"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.header.metadata.labels"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.MapType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.header.metadata.labels", "github.com/hashicorp/terraform-plugin-framework/types.MapType"}) + } else { + c, ok := tf.Attrs["labels"].(github_com_hashicorp_terraform_plugin_framework_types.Map) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.Map{ + + ElemType: o.ElemType, + Elems: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Labels)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Labels)) + } + } + if obj.Labels != nil { + t := o.ElemType + for k, a := range obj.Labels { + v, ok := tf.Attrs["labels"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.header.metadata.labels", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.header.metadata.labels", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = false + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Labels) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["labels"] = c + } + } + } + { + t, ok := tf.AttrTypes["expires"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.header.metadata.expires"}) + } else { + v := CopyToTimestamp(diags, obj.Expires, t, tf.Attrs["expires"]) + tf.Attrs["expires"] = v + } + } + { + t, ok := tf.AttrTypes["revision"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.header.metadata.revision"}) + } else { + v, ok := tf.Attrs["revision"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.header.metadata.revision", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.header.metadata.revision", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Revision) == "" + } + v.Value = string(obj.Revision) + v.Unknown = false + tf.Attrs["revision"] = v + } + } + } + v.Unknown = false + tf.Attrs["metadata"] = v + } + } + } + } + v.Unknown = false + tf.Attrs["header"] = v + } + } + } + { + a, ok := tf.AttrTypes["spec"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["spec"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.Spec == nil { + v.Null = true + } else { + obj := obj.Spec + tf := &v + { + t, ok := tf.AttrTypes["discovery_group"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.discovery_group"}) + } else { + v, ok := tf.Attrs["discovery_group"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.discovery_group", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.discovery_group", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.DiscoveryGroup) == "" + } + v.Value = string(obj.DiscoveryGroup) + v.Unknown = false + tf.Attrs["discovery_group"] = v + } + } + { + a, ok := tf.AttrTypes["aws"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["aws"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Aws)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Aws)) + } + } + if obj.Aws != nil { + o := o.ElemType.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if len(obj.Aws) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Aws)) + } + for k, a := range obj.Aws { + v, ok := tf.Attrs["aws"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if a == nil { + v.Null = true + } else { + obj := a + tf := &v + { + a, ok := tf.AttrTypes["types"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Types"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Types", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["types"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Types)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Types)) + } + } + if obj.Types != nil { + t := o.ElemType + if len(obj.Types) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Types)) + } + for k, a := range obj.Types { + v, ok := tf.Attrs["types"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Types", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Types", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Types) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["types"] = c + } + } + } + { + a, ok := tf.AttrTypes["regions"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Regions"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Regions", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["regions"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Regions)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Regions)) + } + } + if obj.Regions != nil { + t := o.ElemType + if len(obj.Regions) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Regions)) + } + for k, a := range obj.Regions { + v, ok := tf.Attrs["regions"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Regions", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Regions", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Regions) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["regions"] = c + } + } + } + { + a, ok := tf.AttrTypes["assume_role"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.AssumeRole"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.AssumeRole", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["assume_role"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.AssumeRole == nil { + v.Null = true + } else { + obj := obj.AssumeRole + tf := &v + { + t, ok := tf.AttrTypes["role_arn"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.AssumeRole.RoleARN"}) + } else { + v, ok := tf.Attrs["role_arn"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.AssumeRole.RoleARN", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.AssumeRole.RoleARN", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.RoleARN) == "" + } + v.Value = string(obj.RoleARN) + v.Unknown = false + tf.Attrs["role_arn"] = v + } + } + { + t, ok := tf.AttrTypes["external_id"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.AssumeRole.ExternalID"}) + } else { + v, ok := tf.Attrs["external_id"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.AssumeRole.ExternalID", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.AssumeRole.ExternalID", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ExternalID) == "" + } + v.Value = string(obj.ExternalID) + v.Unknown = false + tf.Attrs["external_id"] = v + } + } + } + v.Unknown = false + tf.Attrs["assume_role"] = v + } + } + } + { + t, ok := tf.AttrTypes["tags"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Tags"}) + } else { + v := CopyToLabels(diags, obj.Tags, t, tf.Attrs["tags"]) + tf.Attrs["tags"] = v + } + } + { + a, ok := tf.AttrTypes["install"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["install"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.Params == nil { + v.Null = true + } else { + obj := obj.Params + tf := &v + { + t, ok := tf.AttrTypes["join_method"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.JoinMethod"}) + } else { + v, ok := tf.Attrs["join_method"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Params.JoinMethod", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.JoinMethod", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.JoinMethod) == "" + } + v.Value = string(obj.JoinMethod) + v.Unknown = false + tf.Attrs["join_method"] = v + } + } + { + t, ok := tf.AttrTypes["join_token"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.JoinToken"}) + } else { + v, ok := tf.Attrs["join_token"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Params.JoinToken", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.JoinToken", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.JoinToken) == "" + } + v.Value = string(obj.JoinToken) + v.Unknown = false + tf.Attrs["join_token"] = v + } + } + { + t, ok := tf.AttrTypes["script_name"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.ScriptName"}) + } else { + v, ok := tf.Attrs["script_name"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Params.ScriptName", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.ScriptName", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ScriptName) == "" + } + v.Value = string(obj.ScriptName) + v.Unknown = false + tf.Attrs["script_name"] = v + } + } + { + t, ok := tf.AttrTypes["install_teleport"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.InstallTeleport"}) + } else { + v, ok := tf.Attrs["install_teleport"].(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{"DiscoveryConfig.spec.aws.Params.InstallTeleport", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.Bool) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.InstallTeleport", "github.com/hashicorp/terraform-plugin-framework/types.Bool"}) + } + v.Null = bool(obj.InstallTeleport) == false + } + v.Value = bool(obj.InstallTeleport) + v.Unknown = false + tf.Attrs["install_teleport"] = v + } + } + { + t, ok := tf.AttrTypes["sshd_config"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.SSHDConfig"}) + } else { + v, ok := tf.Attrs["sshd_config"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Params.SSHDConfig", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.SSHDConfig", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SSHDConfig) == "" + } + v.Value = string(obj.SSHDConfig) + v.Unknown = false + tf.Attrs["sshd_config"] = v + } + } + { + t, ok := tf.AttrTypes["proxy_addr"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.PublicProxyAddr"}) + } else { + v, ok := tf.Attrs["proxy_addr"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Params.PublicProxyAddr", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.PublicProxyAddr", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PublicProxyAddr) == "" + } + v.Value = string(obj.PublicProxyAddr) + v.Unknown = false + tf.Attrs["proxy_addr"] = v + } + } + { + a, ok := tf.AttrTypes["azure"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.Azure"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.Azure", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["azure"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.Azure == nil { + v.Null = true + } else { + obj := obj.Azure + tf := &v + { + t, ok := tf.AttrTypes["client_id"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.Azure.ClientID"}) + } else { + v, ok := tf.Attrs["client_id"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Params.Azure.ClientID", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.Azure.ClientID", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ClientID) == "" + } + v.Value = string(obj.ClientID) + v.Unknown = false + tf.Attrs["client_id"] = v + } + } + } + v.Unknown = false + tf.Attrs["azure"] = v + } + } + } + { + t, ok := tf.AttrTypes["enroll_mode"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.EnrollMode"}) + } else { + v, ok := tf.Attrs["enroll_mode"].(github_com_hashicorp_terraform_plugin_framework_types.Int64) + 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{"DiscoveryConfig.spec.aws.Params.EnrollMode", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.Int64) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.EnrollMode", "github.com/hashicorp/terraform-plugin-framework/types.Int64"}) + } + v.Null = int64(obj.EnrollMode) == 0 + } + v.Value = int64(obj.EnrollMode) + v.Unknown = false + tf.Attrs["enroll_mode"] = v + } + } + { + t, ok := tf.AttrTypes["suffix"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.Suffix"}) + } else { + v, ok := tf.Attrs["suffix"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Params.Suffix", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.Suffix", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Suffix) == "" + } + v.Value = string(obj.Suffix) + v.Unknown = false + tf.Attrs["suffix"] = v + } + } + { + t, ok := tf.AttrTypes["update_group"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.UpdateGroup"}) + } else { + v, ok := tf.Attrs["update_group"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Params.UpdateGroup", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.UpdateGroup", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.UpdateGroup) == "" + } + v.Value = string(obj.UpdateGroup) + v.Unknown = false + tf.Attrs["update_group"] = v + } + } + { + a, ok := tf.AttrTypes["http_proxy_settings"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["http_proxy_settings"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.HTTPProxySettings == nil { + v.Null = true + } else { + obj := obj.HTTPProxySettings + tf := &v + { + t, ok := tf.AttrTypes["http_proxy"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.HTTPProxy"}) + } else { + v, ok := tf.Attrs["http_proxy"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.HTTPProxy", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.HTTPProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.HTTPProxy) == "" + } + v.Value = string(obj.HTTPProxy) + v.Unknown = false + tf.Attrs["http_proxy"] = v + } + } + { + t, ok := tf.AttrTypes["https_proxy"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.HTTPSProxy"}) + } else { + v, ok := tf.Attrs["https_proxy"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.HTTPSProxy", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.HTTPSProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.HTTPSProxy) == "" + } + v.Value = string(obj.HTTPSProxy) + v.Unknown = false + tf.Attrs["https_proxy"] = v + } + } + { + t, ok := tf.AttrTypes["no_proxy"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.NoProxy"}) + } else { + v, ok := tf.Attrs["no_proxy"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.NoProxy", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Params.HTTPProxySettings.NoProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NoProxy) == "" + } + v.Value = string(obj.NoProxy) + v.Unknown = false + tf.Attrs["no_proxy"] = v + } + } + } + v.Unknown = false + tf.Attrs["http_proxy_settings"] = v + } + } + } + } + v.Unknown = false + tf.Attrs["install"] = v + } + } + } + { + a, ok := tf.AttrTypes["ssm"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.SSM"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.SSM", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["ssm"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.SSM == nil { + v.Null = true + } else { + obj := obj.SSM + tf := &v + { + t, ok := tf.AttrTypes["document_name"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.SSM.DocumentName"}) + } else { + v, ok := tf.Attrs["document_name"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.SSM.DocumentName", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.SSM.DocumentName", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.DocumentName) == "" + } + v.Value = string(obj.DocumentName) + v.Unknown = false + tf.Attrs["document_name"] = v + } + } + } + v.Unknown = false + tf.Attrs["ssm"] = v + } + } + } + { + t, ok := tf.AttrTypes["integration"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.Integration"}) + } else { + v, ok := tf.Attrs["integration"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.Integration", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.Integration", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Integration) == "" + } + v.Value = string(obj.Integration) + v.Unknown = false + tf.Attrs["integration"] = v + } + } + { + t, ok := tf.AttrTypes["kube_app_discovery"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.KubeAppDiscovery"}) + } else { + v, ok := tf.Attrs["kube_app_discovery"].(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{"DiscoveryConfig.spec.aws.KubeAppDiscovery", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.Bool) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.KubeAppDiscovery", "github.com/hashicorp/terraform-plugin-framework/types.Bool"}) + } + v.Null = bool(obj.KubeAppDiscovery) == false + } + v.Value = bool(obj.KubeAppDiscovery) + v.Unknown = false + tf.Attrs["kube_app_discovery"] = v + } + } + { + t, ok := tf.AttrTypes["setup_access_for_arn"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.aws.SetupAccessForARN"}) + } else { + v, ok := tf.Attrs["setup_access_for_arn"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.aws.SetupAccessForARN", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.aws.SetupAccessForARN", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SetupAccessForARN) == "" + } + v.Value = string(obj.SetupAccessForARN) + v.Unknown = false + tf.Attrs["setup_access_for_arn"] = v + } + } + } + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Aws) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["aws"] = c + } + } + } + { + a, ok := tf.AttrTypes["azure"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["azure"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Azure)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Azure)) + } + } + if obj.Azure != nil { + o := o.ElemType.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if len(obj.Azure) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Azure)) + } + for k, a := range obj.Azure { + v, ok := tf.Attrs["azure"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if a == nil { + v.Null = true + } else { + obj := a + tf := &v + { + a, ok := tf.AttrTypes["subscriptions"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Subscriptions"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Subscriptions", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["subscriptions"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Subscriptions)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Subscriptions)) + } + } + if obj.Subscriptions != nil { + t := o.ElemType + if len(obj.Subscriptions) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Subscriptions)) + } + for k, a := range obj.Subscriptions { + v, ok := tf.Attrs["subscriptions"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Subscriptions", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Subscriptions", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Subscriptions) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["subscriptions"] = c + } + } + } + { + a, ok := tf.AttrTypes["resource_groups"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.ResourceGroups"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.ResourceGroups", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["resource_groups"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.ResourceGroups)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.ResourceGroups)) + } + } + if obj.ResourceGroups != nil { + t := o.ElemType + if len(obj.ResourceGroups) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.ResourceGroups)) + } + for k, a := range obj.ResourceGroups { + v, ok := tf.Attrs["resource_groups"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.ResourceGroups", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.ResourceGroups", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.ResourceGroups) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["resource_groups"] = c + } + } + } + { + a, ok := tf.AttrTypes["types"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Types"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Types", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["types"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Types)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Types)) + } + } + if obj.Types != nil { + t := o.ElemType + if len(obj.Types) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Types)) + } + for k, a := range obj.Types { + v, ok := tf.Attrs["types"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Types", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Types", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Types) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["types"] = c + } + } + } + { + a, ok := tf.AttrTypes["regions"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Regions"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Regions", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["regions"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Regions)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Regions)) + } + } + if obj.Regions != nil { + t := o.ElemType + if len(obj.Regions) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Regions)) + } + for k, a := range obj.Regions { + v, ok := tf.Attrs["regions"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Regions", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Regions", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Regions) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["regions"] = c + } + } + } + { + t, ok := tf.AttrTypes["tags"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.ResourceTags"}) + } else { + v := CopyToLabels(diags, obj.ResourceTags, t, tf.Attrs["tags"]) + tf.Attrs["tags"] = v + } + } + { + a, ok := tf.AttrTypes["install_params"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["install_params"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.Params == nil { + v.Null = true + } else { + obj := obj.Params + tf := &v + { + t, ok := tf.AttrTypes["join_method"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.JoinMethod"}) + } else { + v, ok := tf.Attrs["join_method"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Params.JoinMethod", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.JoinMethod", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.JoinMethod) == "" + } + v.Value = string(obj.JoinMethod) + v.Unknown = false + tf.Attrs["join_method"] = v + } + } + { + t, ok := tf.AttrTypes["join_token"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.JoinToken"}) + } else { + v, ok := tf.Attrs["join_token"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Params.JoinToken", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.JoinToken", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.JoinToken) == "" + } + v.Value = string(obj.JoinToken) + v.Unknown = false + tf.Attrs["join_token"] = v + } + } + { + t, ok := tf.AttrTypes["script_name"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.ScriptName"}) + } else { + v, ok := tf.Attrs["script_name"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Params.ScriptName", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.ScriptName", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ScriptName) == "" + } + v.Value = string(obj.ScriptName) + v.Unknown = false + tf.Attrs["script_name"] = v + } + } + { + t, ok := tf.AttrTypes["install_teleport"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.InstallTeleport"}) + } else { + v, ok := tf.Attrs["install_teleport"].(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{"DiscoveryConfig.spec.azure.Params.InstallTeleport", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.Bool) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.InstallTeleport", "github.com/hashicorp/terraform-plugin-framework/types.Bool"}) + } + v.Null = bool(obj.InstallTeleport) == false + } + v.Value = bool(obj.InstallTeleport) + v.Unknown = false + tf.Attrs["install_teleport"] = v + } + } + { + t, ok := tf.AttrTypes["sshd_config"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.SSHDConfig"}) + } else { + v, ok := tf.Attrs["sshd_config"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Params.SSHDConfig", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.SSHDConfig", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SSHDConfig) == "" + } + v.Value = string(obj.SSHDConfig) + v.Unknown = false + tf.Attrs["sshd_config"] = v + } + } + { + t, ok := tf.AttrTypes["proxy_addr"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.PublicProxyAddr"}) + } else { + v, ok := tf.Attrs["proxy_addr"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Params.PublicProxyAddr", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.PublicProxyAddr", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PublicProxyAddr) == "" + } + v.Value = string(obj.PublicProxyAddr) + v.Unknown = false + tf.Attrs["proxy_addr"] = v + } + } + { + a, ok := tf.AttrTypes["azure"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.Azure"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.Azure", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["azure"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.Azure == nil { + v.Null = true + } else { + obj := obj.Azure + tf := &v + { + t, ok := tf.AttrTypes["client_id"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.Azure.ClientID"}) + } else { + v, ok := tf.Attrs["client_id"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Params.Azure.ClientID", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.Azure.ClientID", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ClientID) == "" + } + v.Value = string(obj.ClientID) + v.Unknown = false + tf.Attrs["client_id"] = v + } + } + } + v.Unknown = false + tf.Attrs["azure"] = v + } + } + } + { + t, ok := tf.AttrTypes["enroll_mode"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.EnrollMode"}) + } else { + v, ok := tf.Attrs["enroll_mode"].(github_com_hashicorp_terraform_plugin_framework_types.Int64) + 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{"DiscoveryConfig.spec.azure.Params.EnrollMode", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.Int64) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.EnrollMode", "github.com/hashicorp/terraform-plugin-framework/types.Int64"}) + } + v.Null = int64(obj.EnrollMode) == 0 + } + v.Value = int64(obj.EnrollMode) + v.Unknown = false + tf.Attrs["enroll_mode"] = v + } + } + { + t, ok := tf.AttrTypes["suffix"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.Suffix"}) + } else { + v, ok := tf.Attrs["suffix"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Params.Suffix", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.Suffix", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Suffix) == "" + } + v.Value = string(obj.Suffix) + v.Unknown = false + tf.Attrs["suffix"] = v + } + } + { + t, ok := tf.AttrTypes["update_group"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.UpdateGroup"}) + } else { + v, ok := tf.Attrs["update_group"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Params.UpdateGroup", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.UpdateGroup", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.UpdateGroup) == "" + } + v.Value = string(obj.UpdateGroup) + v.Unknown = false + tf.Attrs["update_group"] = v + } + } + { + a, ok := tf.AttrTypes["http_proxy_settings"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["http_proxy_settings"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.HTTPProxySettings == nil { + v.Null = true + } else { + obj := obj.HTTPProxySettings + tf := &v + { + t, ok := tf.AttrTypes["http_proxy"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.HTTPProxy"}) + } else { + v, ok := tf.Attrs["http_proxy"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.HTTPProxy", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.HTTPProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.HTTPProxy) == "" + } + v.Value = string(obj.HTTPProxy) + v.Unknown = false + tf.Attrs["http_proxy"] = v + } + } + { + t, ok := tf.AttrTypes["https_proxy"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.HTTPSProxy"}) + } else { + v, ok := tf.Attrs["https_proxy"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.HTTPSProxy", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.HTTPSProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.HTTPSProxy) == "" + } + v.Value = string(obj.HTTPSProxy) + v.Unknown = false + tf.Attrs["https_proxy"] = v + } + } + { + t, ok := tf.AttrTypes["no_proxy"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.NoProxy"}) + } else { + v, ok := tf.Attrs["no_proxy"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.NoProxy", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Params.HTTPProxySettings.NoProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NoProxy) == "" + } + v.Value = string(obj.NoProxy) + v.Unknown = false + tf.Attrs["no_proxy"] = v + } + } + } + v.Unknown = false + tf.Attrs["http_proxy_settings"] = v + } + } + } + } + v.Unknown = false + tf.Attrs["install_params"] = v + } + } + } + { + t, ok := tf.AttrTypes["integration"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.azure.Integration"}) + } else { + v, ok := tf.Attrs["integration"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.azure.Integration", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.azure.Integration", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Integration) == "" + } + v.Value = string(obj.Integration) + v.Unknown = false + tf.Attrs["integration"] = v + } + } + } + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Azure) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["azure"] = c + } + } + } + { + a, ok := tf.AttrTypes["gcp"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["gcp"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Gcp)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Gcp)) + } + } + if obj.Gcp != nil { + o := o.ElemType.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if len(obj.Gcp) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Gcp)) + } + for k, a := range obj.Gcp { + v, ok := tf.Attrs["gcp"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if a == nil { + v.Null = true + } else { + obj := a + tf := &v + { + a, ok := tf.AttrTypes["types"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Types"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Types", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["types"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Types)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Types)) + } + } + if obj.Types != nil { + t := o.ElemType + if len(obj.Types) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Types)) + } + for k, a := range obj.Types { + v, ok := tf.Attrs["types"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Types", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Types", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Types) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["types"] = c + } + } + } + { + a, ok := tf.AttrTypes["locations"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Locations"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Locations", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["locations"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Locations)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Locations)) + } + } + if obj.Locations != nil { + t := o.ElemType + if len(obj.Locations) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Locations)) + } + for k, a := range obj.Locations { + v, ok := tf.Attrs["locations"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Locations", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Locations", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Locations) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["locations"] = c + } + } + } + { + t, ok := tf.AttrTypes["tags"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Tags"}) + } else { + v := CopyToLabels(diags, obj.Tags, t, tf.Attrs["tags"]) + tf.Attrs["tags"] = v + } + } + { + a, ok := tf.AttrTypes["project_ids"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.ProjectIDs"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.ProjectIDs", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["project_ids"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.ProjectIDs)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.ProjectIDs)) + } + } + if obj.ProjectIDs != nil { + t := o.ElemType + if len(obj.ProjectIDs) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.ProjectIDs)) + } + for k, a := range obj.ProjectIDs { + v, ok := tf.Attrs["project_ids"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.ProjectIDs", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.ProjectIDs", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.ProjectIDs) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["project_ids"] = c + } + } + } + { + a, ok := tf.AttrTypes["service_accounts"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.ServiceAccounts"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.ServiceAccounts", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["service_accounts"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.ServiceAccounts)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.ServiceAccounts)) + } + } + if obj.ServiceAccounts != nil { + t := o.ElemType + if len(obj.ServiceAccounts) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.ServiceAccounts)) + } + for k, a := range obj.ServiceAccounts { + v, ok := tf.Attrs["service_accounts"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.ServiceAccounts", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.ServiceAccounts", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.ServiceAccounts) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["service_accounts"] = c + } + } + } + { + a, ok := tf.AttrTypes["install_params"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["install_params"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.Params == nil { + v.Null = true + } else { + obj := obj.Params + tf := &v + { + t, ok := tf.AttrTypes["join_method"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.JoinMethod"}) + } else { + v, ok := tf.Attrs["join_method"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Params.JoinMethod", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.JoinMethod", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.JoinMethod) == "" + } + v.Value = string(obj.JoinMethod) + v.Unknown = false + tf.Attrs["join_method"] = v + } + } + { + t, ok := tf.AttrTypes["join_token"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.JoinToken"}) + } else { + v, ok := tf.Attrs["join_token"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Params.JoinToken", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.JoinToken", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.JoinToken) == "" + } + v.Value = string(obj.JoinToken) + v.Unknown = false + tf.Attrs["join_token"] = v + } + } + { + t, ok := tf.AttrTypes["script_name"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.ScriptName"}) + } else { + v, ok := tf.Attrs["script_name"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Params.ScriptName", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.ScriptName", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ScriptName) == "" + } + v.Value = string(obj.ScriptName) + v.Unknown = false + tf.Attrs["script_name"] = v + } + } + { + t, ok := tf.AttrTypes["install_teleport"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.InstallTeleport"}) + } else { + v, ok := tf.Attrs["install_teleport"].(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{"DiscoveryConfig.spec.gcp.Params.InstallTeleport", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.Bool) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.InstallTeleport", "github.com/hashicorp/terraform-plugin-framework/types.Bool"}) + } + v.Null = bool(obj.InstallTeleport) == false + } + v.Value = bool(obj.InstallTeleport) + v.Unknown = false + tf.Attrs["install_teleport"] = v + } + } + { + t, ok := tf.AttrTypes["sshd_config"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.SSHDConfig"}) + } else { + v, ok := tf.Attrs["sshd_config"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Params.SSHDConfig", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.SSHDConfig", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SSHDConfig) == "" + } + v.Value = string(obj.SSHDConfig) + v.Unknown = false + tf.Attrs["sshd_config"] = v + } + } + { + t, ok := tf.AttrTypes["proxy_addr"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.PublicProxyAddr"}) + } else { + v, ok := tf.Attrs["proxy_addr"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Params.PublicProxyAddr", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.PublicProxyAddr", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.PublicProxyAddr) == "" + } + v.Value = string(obj.PublicProxyAddr) + v.Unknown = false + tf.Attrs["proxy_addr"] = v + } + } + { + a, ok := tf.AttrTypes["azure"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.Azure"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.Azure", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["azure"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.Azure == nil { + v.Null = true + } else { + obj := obj.Azure + tf := &v + { + t, ok := tf.AttrTypes["client_id"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.Azure.ClientID"}) + } else { + v, ok := tf.Attrs["client_id"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Params.Azure.ClientID", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.Azure.ClientID", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ClientID) == "" + } + v.Value = string(obj.ClientID) + v.Unknown = false + tf.Attrs["client_id"] = v + } + } + } + v.Unknown = false + tf.Attrs["azure"] = v + } + } + } + { + t, ok := tf.AttrTypes["enroll_mode"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.EnrollMode"}) + } else { + v, ok := tf.Attrs["enroll_mode"].(github_com_hashicorp_terraform_plugin_framework_types.Int64) + 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{"DiscoveryConfig.spec.gcp.Params.EnrollMode", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.Int64) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.EnrollMode", "github.com/hashicorp/terraform-plugin-framework/types.Int64"}) + } + v.Null = int64(obj.EnrollMode) == 0 + } + v.Value = int64(obj.EnrollMode) + v.Unknown = false + tf.Attrs["enroll_mode"] = v + } + } + { + t, ok := tf.AttrTypes["suffix"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.Suffix"}) + } else { + v, ok := tf.Attrs["suffix"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Params.Suffix", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.Suffix", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Suffix) == "" + } + v.Value = string(obj.Suffix) + v.Unknown = false + tf.Attrs["suffix"] = v + } + } + { + t, ok := tf.AttrTypes["update_group"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.UpdateGroup"}) + } else { + v, ok := tf.Attrs["update_group"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Params.UpdateGroup", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.UpdateGroup", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.UpdateGroup) == "" + } + v.Value = string(obj.UpdateGroup) + v.Unknown = false + tf.Attrs["update_group"] = v + } + } + { + a, ok := tf.AttrTypes["http_proxy_settings"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["http_proxy_settings"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.HTTPProxySettings == nil { + v.Null = true + } else { + obj := obj.HTTPProxySettings + tf := &v + { + t, ok := tf.AttrTypes["http_proxy"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.HTTPProxy"}) + } else { + v, ok := tf.Attrs["http_proxy"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.HTTPProxy", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.HTTPProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.HTTPProxy) == "" + } + v.Value = string(obj.HTTPProxy) + v.Unknown = false + tf.Attrs["http_proxy"] = v + } + } + { + t, ok := tf.AttrTypes["https_proxy"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.HTTPSProxy"}) + } else { + v, ok := tf.Attrs["https_proxy"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.HTTPSProxy", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.HTTPSProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.HTTPSProxy) == "" + } + v.Value = string(obj.HTTPSProxy) + v.Unknown = false + tf.Attrs["https_proxy"] = v + } + } + { + t, ok := tf.AttrTypes["no_proxy"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.NoProxy"}) + } else { + v, ok := tf.Attrs["no_proxy"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.NoProxy", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.gcp.Params.HTTPProxySettings.NoProxy", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.NoProxy) == "" + } + v.Value = string(obj.NoProxy) + v.Unknown = false + tf.Attrs["no_proxy"] = v + } + } + } + v.Unknown = false + tf.Attrs["http_proxy_settings"] = v + } + } + } + } + v.Unknown = false + tf.Attrs["install_params"] = v + } + } + } + { + t, ok := tf.AttrTypes["labels"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.gcp.Labels"}) + } else { + v := CopyToLabels(diags, obj.Labels, t, tf.Attrs["labels"]) + tf.Attrs["labels"] = v + } + } + } + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Gcp) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["gcp"] = c + } + } + } + { + a, ok := tf.AttrTypes["kube"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.kube"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.kube", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["kube"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Kube)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Kube)) + } + } + if obj.Kube != nil { + o := o.ElemType.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if len(obj.Kube) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Kube)) + } + for k, a := range obj.Kube { + v, ok := tf.Attrs["kube"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if a == nil { + v.Null = true + } else { + obj := a + tf := &v + { + a, ok := tf.AttrTypes["types"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.kube.Types"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.kube.Types", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["types"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Types)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Types)) + } + } + if obj.Types != nil { + t := o.ElemType + if len(obj.Types) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Types)) + } + for k, a := range obj.Types { + v, ok := tf.Attrs["types"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.kube.Types", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.kube.Types", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Types) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["types"] = c + } + } + } + { + a, ok := tf.AttrTypes["namespaces"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.kube.Namespaces"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.kube.Namespaces", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["namespaces"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Namespaces)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Namespaces)) + } + } + if obj.Namespaces != nil { + t := o.ElemType + if len(obj.Namespaces) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Namespaces)) + } + for k, a := range obj.Namespaces { + v, ok := tf.Attrs["namespaces"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.kube.Namespaces", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.kube.Namespaces", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Namespaces) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["namespaces"] = c + } + } + } + { + t, ok := tf.AttrTypes["labels"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.kube.Labels"}) + } else { + v := CopyToLabels(diags, obj.Labels, t, tf.Attrs["labels"]) + tf.Attrs["labels"] = v + } + } + } + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Kube) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["kube"] = c + } + } + } + { + a, ok := tf.AttrTypes["access_graph"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["access_graph"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.AccessGraph == nil { + v.Null = true + } else { + obj := obj.AccessGraph + tf := &v + { + a, ok := tf.AttrTypes["aws"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.AWS"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["aws"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.AWS)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.AWS)) + } + } + if obj.AWS != nil { + o := o.ElemType.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if len(obj.AWS) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.AWS)) + } + for k, a := range obj.AWS { + v, ok := tf.Attrs["aws"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if a == nil { + v.Null = true + } else { + obj := a + tf := &v + { + a, ok := tf.AttrTypes["regions"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.Regions"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.Regions", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["regions"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Regions)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Regions)) + } + } + if obj.Regions != nil { + t := o.ElemType + if len(obj.Regions) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Regions)) + } + for k, a := range obj.Regions { + v, ok := tf.Attrs["regions"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.access_graph.AWS.Regions", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.Regions", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(a) == "" + } + v.Value = string(a) + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Regions) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["regions"] = c + } + } + } + { + a, ok := tf.AttrTypes["assume_role"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["assume_role"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.AssumeRole == nil { + v.Null = true + } else { + obj := obj.AssumeRole + tf := &v + { + t, ok := tf.AttrTypes["role_arn"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole.RoleARN"}) + } else { + v, ok := tf.Attrs["role_arn"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole.RoleARN", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole.RoleARN", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.RoleARN) == "" + } + v.Value = string(obj.RoleARN) + v.Unknown = false + tf.Attrs["role_arn"] = v + } + } + { + t, ok := tf.AttrTypes["external_id"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole.ExternalID"}) + } else { + v, ok := tf.Attrs["external_id"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole.ExternalID", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.AssumeRole.ExternalID", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.ExternalID) == "" + } + v.Value = string(obj.ExternalID) + v.Unknown = false + tf.Attrs["external_id"] = v + } + } + } + v.Unknown = false + tf.Attrs["assume_role"] = v + } + } + } + { + t, ok := tf.AttrTypes["integration"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.Integration"}) + } else { + v, ok := tf.Attrs["integration"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.access_graph.AWS.Integration", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.Integration", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Integration) == "" + } + v.Value = string(obj.Integration) + v.Unknown = false + tf.Attrs["integration"] = v + } + } + { + a, ok := tf.AttrTypes["cloud_trail_logs"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["cloud_trail_logs"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.CloudTrailLogs == nil { + v.Null = true + } else { + obj := obj.CloudTrailLogs + tf := &v + { + t, ok := tf.AttrTypes["region"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs.Region"}) + } else { + v, ok := tf.Attrs["region"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs.Region", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs.Region", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Region) == "" + } + v.Value = string(obj.Region) + v.Unknown = false + tf.Attrs["region"] = v + } + } + { + t, ok := tf.AttrTypes["sqs_queue"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs.SQSQueue"}) + } else { + v, ok := tf.Attrs["sqs_queue"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs.SQSQueue", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.cloud_trail_logs.SQSQueue", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SQSQueue) == "" + } + v.Value = string(obj.SQSQueue) + v.Unknown = false + tf.Attrs["sqs_queue"] = v + } + } + } + v.Unknown = false + tf.Attrs["cloud_trail_logs"] = v + } + } + } + { + a, ok := tf.AttrTypes["eks_audit_logs"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.eks_audit_logs"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.AWS.eks_audit_logs", "github.com/hashicorp/terraform-plugin-framework/types.ObjectType"}) + } else { + v, ok := tf.Attrs["eks_audit_logs"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if obj.EksAuditLogs == nil { + v.Null = true + } else { + obj := obj.EksAuditLogs + tf := &v + { + t, ok := tf.AttrTypes["tags"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.AWS.eks_audit_logs.Tags"}) + } else { + v := CopyToLabels(diags, obj.Tags, t, tf.Attrs["tags"]) + tf.Attrs["tags"] = v + } + } + } + v.Unknown = false + tf.Attrs["eks_audit_logs"] = v + } + } + } + } + v.Unknown = false + c.Elems[k] = v + } + if len(obj.AWS) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["aws"] = c + } + } + } + { + t, ok := tf.AttrTypes["poll_interval"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.PollInterval"}) + } else { + v, ok := tf.Attrs["poll_interval"].(DurationValue) + 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{"DiscoveryConfig.spec.access_graph.PollInterval", err}) + } + v, ok = i.(DurationValue) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.PollInterval", "DurationValue"}) + } + v.Null = false + } + v.Value = time.Duration(obj.PollInterval) + v.Unknown = false + tf.Attrs["poll_interval"] = v + } + } + { + a, ok := tf.AttrTypes["azure"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.Azure"}) + } else { + o, ok := a.(github_com_hashicorp_terraform_plugin_framework_types.ListType) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.Azure", "github.com/hashicorp/terraform-plugin-framework/types.ListType"}) + } else { + c, ok := tf.Attrs["azure"].(github_com_hashicorp_terraform_plugin_framework_types.List) + if !ok { + c = github_com_hashicorp_terraform_plugin_framework_types.List{ + + ElemType: o.ElemType, + Elems: make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Azure)), + Null: true, + } + } else { + if c.Elems == nil { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Azure)) + } + } + if obj.Azure != nil { + o := o.ElemType.(github_com_hashicorp_terraform_plugin_framework_types.ObjectType) + if len(obj.Azure) != len(c.Elems) { + c.Elems = make([]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(obj.Azure)) + } + for k, a := range obj.Azure { + v, ok := tf.Attrs["azure"].(github_com_hashicorp_terraform_plugin_framework_types.Object) + if !ok { + v = github_com_hashicorp_terraform_plugin_framework_types.Object{ + + AttrTypes: o.AttrTypes, + Attrs: make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(o.AttrTypes)), + } + } else { + if v.Attrs == nil { + v.Attrs = make(map[string]github_com_hashicorp_terraform_plugin_framework_attr.Value, len(tf.AttrTypes)) + } + } + if a == nil { + v.Null = true + } else { + obj := a + tf := &v + { + t, ok := tf.AttrTypes["subscription_id"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.Azure.SubscriptionID"}) + } else { + v, ok := tf.Attrs["subscription_id"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.access_graph.Azure.SubscriptionID", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.Azure.SubscriptionID", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.SubscriptionID) == "" + } + v.Value = string(obj.SubscriptionID) + v.Unknown = false + tf.Attrs["subscription_id"] = v + } + } + { + t, ok := tf.AttrTypes["integration"] + if !ok { + diags.Append(attrWriteMissingDiag{"DiscoveryConfig.spec.access_graph.Azure.Integration"}) + } else { + v, ok := tf.Attrs["integration"].(github_com_hashicorp_terraform_plugin_framework_types.String) + 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{"DiscoveryConfig.spec.access_graph.Azure.Integration", err}) + } + v, ok = i.(github_com_hashicorp_terraform_plugin_framework_types.String) + if !ok { + diags.Append(attrWriteConversionFailureDiag{"DiscoveryConfig.spec.access_graph.Azure.Integration", "github.com/hashicorp/terraform-plugin-framework/types.String"}) + } + v.Null = string(obj.Integration) == "" + } + v.Value = string(obj.Integration) + v.Unknown = false + tf.Attrs["integration"] = v + } + } + } + v.Unknown = false + c.Elems[k] = v + } + if len(obj.Azure) > 0 { + c.Null = false + } + } + c.Unknown = false + tf.Attrs["azure"] = c + } + } + } + } + v.Unknown = false + tf.Attrs["access_graph"] = v + } + } + } + } + v.Unknown = false + tf.Attrs["spec"] = v + } + } + } + return diags +} + +// attrReadMissingDiag represents diagnostic message on an attribute missing in the source object +type attrReadMissingDiag struct { + Path string +} + +func (d attrReadMissingDiag) Severity() github_com_hashicorp_terraform_plugin_framework_diag.Severity { + return github_com_hashicorp_terraform_plugin_framework_diag.SeverityError +} + +func (d attrReadMissingDiag) Summary() string { + return "Error reading from Terraform object" +} + +func (d attrReadMissingDiag) Detail() string { + return fmt.Sprintf("A value for %v is missing in the source Terraform object Attrs", d.Path) +} + +func (d attrReadMissingDiag) Equal(o github_com_hashicorp_terraform_plugin_framework_diag.Diagnostic) bool { + return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail()) +} + +// attrReadConversionFailureDiag represents diagnostic message on a failed type conversion on read +type attrReadConversionFailureDiag struct { + Path string + Type string +} + +func (d attrReadConversionFailureDiag) Severity() github_com_hashicorp_terraform_plugin_framework_diag.Severity { + return github_com_hashicorp_terraform_plugin_framework_diag.SeverityError +} + +func (d attrReadConversionFailureDiag) Summary() string { + return "Error reading from Terraform object" +} + +func (d attrReadConversionFailureDiag) Detail() string { + return fmt.Sprintf("A value for %v can not be converted to %v", d.Path, d.Type) +} + +func (d attrReadConversionFailureDiag) Equal(o github_com_hashicorp_terraform_plugin_framework_diag.Diagnostic) bool { + return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail()) +} + +// attrWriteMissingDiag represents diagnostic message on an attribute missing in the target object +type attrWriteMissingDiag struct { + Path string +} + +func (d attrWriteMissingDiag) Severity() github_com_hashicorp_terraform_plugin_framework_diag.Severity { + return github_com_hashicorp_terraform_plugin_framework_diag.SeverityError +} + +func (d attrWriteMissingDiag) Summary() string { + return "Error writing to Terraform object" +} + +func (d attrWriteMissingDiag) Detail() string { + return fmt.Sprintf("A value for %v is missing in the source Terraform object AttrTypes", d.Path) +} + +func (d attrWriteMissingDiag) Equal(o github_com_hashicorp_terraform_plugin_framework_diag.Diagnostic) bool { + return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail()) +} + +// attrWriteConversionFailureDiag represents diagnostic message on a failed type conversion on write +type attrWriteConversionFailureDiag struct { + Path string + Type string +} + +func (d attrWriteConversionFailureDiag) Severity() github_com_hashicorp_terraform_plugin_framework_diag.Severity { + return github_com_hashicorp_terraform_plugin_framework_diag.SeverityError +} + +func (d attrWriteConversionFailureDiag) Summary() string { + return "Error writing to Terraform object" +} + +func (d attrWriteConversionFailureDiag) Detail() string { + return fmt.Sprintf("A value for %v can not be converted to %v", d.Path, d.Type) +} + +func (d attrWriteConversionFailureDiag) Equal(o github_com_hashicorp_terraform_plugin_framework_diag.Diagnostic) bool { + return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail()) +} + +// attrWriteGeneralError represents diagnostic message on a generic error on write +type attrWriteGeneralError struct { + Path string + Err error +} + +func (d attrWriteGeneralError) Severity() github_com_hashicorp_terraform_plugin_framework_diag.Severity { + return github_com_hashicorp_terraform_plugin_framework_diag.SeverityError +} + +func (d attrWriteGeneralError) Summary() string { + return "Error writing to Terraform object" +} + +func (d attrWriteGeneralError) Detail() string { + return fmt.Sprintf("%s: %s", d.Path, d.Err.Error()) +} + +func (d attrWriteGeneralError) Equal(o github_com_hashicorp_terraform_plugin_framework_diag.Diagnostic) bool { + return (d.Severity() == o.Severity()) && (d.Summary() == o.Summary()) && (d.Detail() == o.Detail()) +} diff --git a/integrations/terraform/tfschema/resource153/custom_types.go b/integrations/terraform/tfschema/resource153/custom_types.go index 5b6c5072da1a1..90fe33f77e1eb 100644 --- a/integrations/terraform/tfschema/resource153/custom_types.go +++ b/integrations/terraform/tfschema/resource153/custom_types.go @@ -27,6 +27,8 @@ import ( "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/timestamppb" + apitypes "github.com/gravitational/teleport/api/types" + "github.com/gravitational/teleport/integrations/terraform/tfschema" ) @@ -102,3 +104,15 @@ func CopyToDuration(diags diag.Diagnostics, o *durationpb.Duration, t attr.Type, return value } + +func GenSchemaLabels(ctx context.Context, attr tfsdk.Attribute) tfsdk.Attribute { + return tfschema.GenSchemaLabels(ctx, attr) +} + +func CopyFromLabels(diags diag.Diagnostics, v attr.Value, o *apitypes.Labels) { + tfschema.CopyFromLabels(diags, v, o) +} + +func CopyToLabels(diags diag.Diagnostics, o apitypes.Labels, t attr.Type, v attr.Value) attr.Value { + return tfschema.CopyToLabels(diags, o, t, v) +} diff --git a/lib/services/presets.go b/lib/services/presets.go index 1aba4583aac7c..f7372ed71ae6d 100644 --- a/lib/services/presets.go +++ b/lib/services/presets.go @@ -804,6 +804,7 @@ func NewPresetTerraformProviderRole() types.Role { types.NewRule(types.KindClusterNetworkingConfig, RW()), types.NewRule(types.KindDatabase, RW()), types.NewRule(types.KindDevice, RW()), + types.NewRule(types.KindDiscoveryConfig, RW()), types.NewRule(types.KindGithub, RW()), types.NewRule(types.KindLoginRule, RW()), types.NewRule(types.KindNode, RW()), diff --git a/lib/services/presets_test.go b/lib/services/presets_test.go index 7badb824825ef..e3484346c2569 100644 --- a/lib/services/presets_test.go +++ b/lib/services/presets_test.go @@ -755,6 +755,7 @@ func TestAddRoleDefaults(t *testing.T) { Verbs: RW(), }, // The missing resources got added as individual rules + types.NewRule(types.KindDiscoveryConfig, RW()), types.NewRule(types.KindAccessMonitoringRule, RW()), types.NewRule(types.KindDynamicWindowsDesktop, RW()), types.NewRule(types.KindStaticHostUser, RW()),