Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions terraform/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ $(BUILDDIR)/terraform-provider-teleport_%: terraform-provider-teleport-v$(VERSIO
mv $(BUILDDIR)/terraform-provider-teleport $@

CUSTOM_IMPORTS_TMP_DIR ?= /tmp/protoc-gen-terraform/custom-imports
PROTOC_GEN_TERRAFORM_VERSION ?= v1.4.1
PROTOC_GEN_TERRAFORM_VERSION ?= v1.4.2
PROTOC_GEN_TERRAFORM_EXISTS := $(shell protoc-gen-terraform version 2>&1 >/dev/null | grep 'protoc-gen-terraform $(PROTOC_GEN_TERRAFORM_VERSION)')

.PHONY: gen-tfschema
gen-tfschema:
ifndef PROTOC_GEN_TERRAFORM_EXISTS
@echo "protoc-gen-terraform v1.4.1 is not installed. Please, refer to README.md for installation instructions."
@echo "protoc-gen-terraform $(PROTOC_GEN_TERRAFORM_VERSION) is not installed. Please, refer to README.md for installation instructions."
@exit -1
endif

Expand Down
38 changes: 38 additions & 0 deletions terraform/example/okta_import_rule.tf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Teleport Okta Import Rule resource

resource "teleport_okta_import_rule" "example" {
metadata = {
description = "Example Okta Import Rule"
labels = {
"example" = "yes"
}
}

version = "v1"

spec = {
priority = 100
mappings = [
{
add_labels = {
"label1": "value1"
}
matches = [
{
app_ids = ["1", "2", "3"]
},
],
},
{
add_labels = {
"label2": "value2"
}
matches = [
{
group_ids = ["1", "2", "3"]
},
],
},
]
}
}
1 change: 1 addition & 0 deletions terraform/example/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ spec:
- app
- db
- login_rule
- okta_import_rule
verbs: ['list','create','read','update','delete']
version: v6
---
Expand Down
19 changes: 19 additions & 0 deletions terraform/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,22 @@ var (
IsPlainStruct: true,
TerraformResourceType: "teleport_login_rule",
}

oktaImportRule = payload{
Name: "OktaImportRule",
TypeName: "OktaImportRuleV1",
VarName: "oktaImportRule",
IfaceName: "OktaImportRule",
GetMethod: "OktaClient().GetOktaImportRule",
CreateMethod: "OktaClient().CreateOktaImportRule",
UpdateMethod: "OktaClient().UpdateOktaImportRule",
DeleteMethod: "OktaClient().DeleteOktaImportRule",
UpsertMethodArity: 2,
ID: "oktaImportRule.Metadata.Name",
Kind: "okta_import_rule",
HasStaticID: false,
TerraformResourceType: "teleport_okta_import_rule",
}
)

func main() {
Expand Down Expand Up @@ -359,6 +375,8 @@ func genTFSchema() {
generateDataSource(user, pluralDataSource)
generateResource(loginRule, pluralResource)
generateDataSource(loginRule, pluralDataSource)
generateResource(oktaImportRule, pluralResource)
generateDataSource(oktaImportRule, pluralDataSource)
}

func generateResource(p payload, tpl string) {
Expand Down Expand Up @@ -402,6 +420,7 @@ var (
"database": tfschema.GenSchemaDatabaseV3,
"github_connector": tfschema.GenSchemaGithubConnectorV3,
"login_rule": loginruleSchema.GenSchemaLoginRule,
"okta_import_rule": tfschema.GenSchemaOktaImportRuleV1,
"oidc_connector": tfschema.GenSchemaOIDCConnectorV3,
"provision_token": tfschema.GenSchemaProvisionTokenV2,
"role": tfschema.GenSchemaRoleV6,
Expand Down
24 changes: 21 additions & 3 deletions terraform/protoc-gen-terraform-teleport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ types:
- "DatabaseV3"
- "GithubConnectorV3"
- "OIDCConnectorV3"
- "OktaImportRuleV1"
- "ProvisionTokenV2"
- "RoleV6"
- "SAMLConnectorV2"
Expand Down Expand Up @@ -64,6 +65,13 @@ injected_fields:
computed: true
plan_modifiers:
- "github.com/hashicorp/terraform-plugin-framework/tfsdk.UseStateForUnknown()"
OktaImportRuleV1:
-
name: id
type: github.com/hashicorp/terraform-plugin-framework/types.StringType
computed: true
plan_modifiers:
- "github.com/hashicorp/terraform-plugin-framework/tfsdk.UseStateForUnknown()"
ProvisionTokenV2:
-
name: id
Expand Down Expand Up @@ -113,10 +121,10 @@ exclude_fields:
- "Metadata.ID"

# AuthPreference
- "AuthPreferenceV2.Metadata.Name" # It's a signleton resource
- "AuthPreferenceV2.Metadata.Name" # It's a singleton resource

# NetworkingConfig
- "ClusterNetworkingConfigV2.Metadata.Name" # It's a signleton resource
- "ClusterNetworkingConfigV2.Metadata.Name" # It's a singleton resource

# Status
- "DatabaseV3.Status"
Expand All @@ -126,7 +134,7 @@ exclude_fields:
- "RoleV6.Spec.Deny.Namespaces"

# SessionRecordingConfig
- "SessionRecordingConfigV2.Metadata.Name" # It's a signleton resource
- "SessionRecordingConfigV2.Metadata.Name" # It's a singleton resource

# User
- "UserSpecV2.LocalAuth" # We do not need to set user auth data
Expand Down Expand Up @@ -179,6 +187,10 @@ computed_fields:
- "OIDCConnectorV3.Kind"
- "OIDCConnectorV3.Version"

# Okta import rule
- "OktaImportRuleV1.Kind"
- "OktaImportRuleV1.Version"

# Role
- "RoleV6.Spec.Options.MaxSessionTTL"
- "RoleV6.Spec.Options.CertificateFormat"
Expand Down Expand Up @@ -260,6 +272,10 @@ required_fields:
- "OIDCConnectorV3.Spec"
- "OIDCConnectorV3.Metadata.Name"

# Okta import rule
- "OktaImportRuleV1.Spec"
- "OktaImportRuleV1.Metadata.Name"

# Provision token
- "ProvisionTokenV2.Spec"
- "ProvisionTokenV2.Spec.Options"
Expand Down Expand Up @@ -332,6 +348,8 @@ validators:
- UseVersionBetween(3,3)
OIDCConnectorV3.Version:
- UseVersionBetween(3,3)
OktaImportRuleV1.Version:
- UseVersionBetween(1,1)
ProvisionTokenV2.Version:
- UseVersionBetween(2,2)
RoleV6.Version:
Expand Down
81 changes: 81 additions & 0 deletions terraform/provider/data_source_teleport_okta_import_rule.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions terraform/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ func (p *Provider) GetResources(_ context.Context) (map[string]tfsdk.ResourceTyp
"teleport_user": resourceTeleportUserType{},
"teleport_bot": resourceTeleportBotType{},
"teleport_login_rule": resourceTeleportLoginRuleType{},
"teleport_okta_import_rule": resourceTeleportOktaImportRuleType{},
}, nil
}

Expand All @@ -591,5 +592,6 @@ func (p *Provider) GetDataSources(_ context.Context) (map[string]tfsdk.DataSourc
"teleport_trusted_cluster": dataSourceTeleportTrustedClusterType{},
"teleport_user": dataSourceTeleportUserType{},
"teleport_login_rule": dataSourceTeleportLoginRuleType{},
"teleport_okta_import_rule": dataSourceTeleportOktaImportRuleType{},
}, nil
}
Loading