-
Notifications
You must be signed in to change notification settings - Fork 2k
Support DiscoveryConfig in terraform provider #61680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| } | ||
|
Comment on lines
+33
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a couple of values that are set when the As an example, if the install_params is not set, it will set the:
I'm not sure we can do the same logic here, but if possible let's at least ensure the example value is set to those values. |
||
| }] | ||
| } | ||
| } | ||
|
|
||
| # 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" | ||
| } | ||
| } | ||
| }] | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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' | ||
GavinFrazar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - '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" | ||
Uh oh!
There was an error while loading. Please reload this page.