Skip to content

Commit

Permalink
Add Okta Provider (GoogleCloudPlatform#1000)
Browse files Browse the repository at this point in the history
* Add Okta Support

* Update Okta Provider Iteration 1

* Update Okta Provider Iteration 2
  • Loading branch information
rajnadimpalli authored Jul 27, 2021
1 parent 2571c21 commit dd5512d
Show file tree
Hide file tree
Showing 27 changed files with 1,843 additions and 39 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ A CLI tool that generates `tf`/`json` and `tfstate` files based on existing infr
* [GmailFilter](/docs/gmailfilter.md)
* [Grafana](/docs/grafana.md)
* [Vault](/docs/vault.md)
* Identity
* [Okta](/docs/okta.md)
- [Contributing](#contributing)
- [Developing](#developing)
- [Infrastructure](#infrastructure)
Expand Down
59 changes: 59 additions & 0 deletions cmd/provider_cmd_okta.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2018 The Terraformer Authors.
//
// 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 cmd

import (
"errors"
"os"

okta_terraforming "github.com/GoogleCloudPlatform/terraformer/providers/okta"
"github.com/GoogleCloudPlatform/terraformer/terraformutils"
"github.com/spf13/cobra"
)

func newCmdOktaImporter(options ImportOptions) *cobra.Command {
cmd := &cobra.Command{
Use: "okta",
Short: "Import current State to terraform configuration from okta",
Long: "Import current State to terraform configuration from okta",
RunE: func(cmd *cobra.Command, args []string) error {
token := os.Getenv("OKTA_API_TOKEN")
if len(token) == 0 {
return errors.New("API Token for Okta must be set through `OKTA_API_TOKEN` env var")
}
baseURL := os.Getenv("OKTA_BASE_URL")
if len(baseURL) == 0 {
return errors.New("Base URL for Okta must be set through `OKTA_BASE_URL` env var")
}
orgName := os.Getenv("OKTA_ORG_NAME")
if len(orgName) == 0 {
return errors.New("Org Name for Okta must be set through `OKTA_ORG_NAME` env var")
}

provider := newOktaProvider()
err := Import(provider, options, []string{orgName, token, baseURL})
if err != nil {
return err
}
return nil
},
}
cmd.AddCommand(listCmd(newOktaProvider()))
baseProviderFlags(cmd.PersistentFlags(), &options, "user", "okta_user=user1:user2:user3")
return cmd
}

func newOktaProvider() terraformutils.ProviderGenerator {
return &okta_terraforming.OktaProvider{}
}
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func providerImporterSubcommands() []func(options ImportOptions) *cobra.Command
newCmdXenorchestraImporter,
newCmdGmailfilterImporter,
newCmdVaultImporter,
newCmdOktaImporter,
}
}

Expand Down Expand Up @@ -119,6 +120,7 @@ func providerGenerators() map[string]func() terraformutils.ProviderGenerator {
newXenorchestraProvider,
newGmailfilterProvider,
newVaultProvider,
newOktaProvider,
} {
list[providerGen().GetName()] = providerGen
}
Expand Down
40 changes: 40 additions & 0 deletions docs/okta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
### Use with Okta

Example:

```
$ export OKTA_ORG_NAME=<ORG_NAME>
$ export OKTA_BASE_URL=<BASE_URL>
$ export OKTA_API_TOKEN=<API_TOKEN>
$ terraformer import okta --resources=user,group
```

List of supported Okta services:

* `user`
* `okta_user`
* `user_type`
* `group`
* `okta_group`
* `policy`
* `okta_policy_password`
* `okta_policy_rule_password`
* `okta_policy_mfa`
* `okta_policy_rule_mfa`
* `okta_policy_signon`
* `okta_policy_rule_signon`
* `authorization_server`
* `okta_auth_server`
* `okta_auth_server_scope`
* `okta_auth_server_claim`
* `okta_auth_server_policy`
* `event_hook`
* `inline_hook`
* `template_sms`
* `trusted_origin`






29 changes: 24 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
cloud.google.com/go/storage v1.14.0
github.com/Azure/azure-sdk-for-go v42.3.0+incompatible
github.com/Azure/azure-storage-blob-go v0.10.0
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Azure/go-autorest/autorest v0.11.12
github.com/DataDog/datadog-api-client-go v1.0.0-beta.20
github.com/IBM-Cloud/bluemix-go v0.0.0-20210203095940-db28d5e07b55
Expand All @@ -17,8 +18,11 @@ require (
github.com/IBM/keyprotect-go-client v0.6.0
github.com/IBM/networking-go-sdk v0.13.0
github.com/IBM/vpc-go-sdk v0.4.1
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/OctopusDeploy/go-octopusdeploy v1.6.0
github.com/PaloAltoNetworks/pango v0.5.2-0.20210514062125-b809b85eb51c
github.com/SAP/go-hdb v0.105.2 // indirect
github.com/SermoDigital/jose v0.9.1 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.60.295
github.com/aliyun/aliyun-tablestore-go-sdk v4.1.2+incompatible
github.com/apache/openwhisk-client-go v0.0.0-20210106144548-17d556327cd3
Expand Down Expand Up @@ -96,34 +100,48 @@ require (
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cloudflare/cloudflare-go v0.13.6
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 // indirect
github.com/containerd/continuity v0.1.0 // indirect
github.com/ddelnano/terraform-provider-mikrotik/client v0.0.0-20210401060029-7f652169b2c4
github.com/ddelnano/terraform-provider-xenorchestra/client v0.0.0-20210401070256-0d721c6762ef
github.com/denisenkom/go-mssqldb v0.10.0 // indirect
github.com/denverdino/aliyungo v0.0.0-20200327235253-d59c209c7e93
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/digitalocean/godo v1.57.0
github.com/docker/go-connections v0.4.0 // indirect
github.com/dollarshaveclub/new-relic-synthetics-go v0.0.0-20170605224734-4dc3dd6ae884
github.com/duosecurity/duo_api_golang v0.0.0-20201112143038-0e07e9f869e3 // indirect
github.com/elazarl/go-bindata-assetfs v1.0.1 // indirect
github.com/fastly/go-fastly/v3 v3.6.0
github.com/fatih/structs v1.1.0 // indirect
github.com/gocql/gocql v0.0.0-20210707082121-9a3953d1826d // indirect
github.com/google/go-github/v35 v35.1.0
github.com/gophercloud/gophercloud v0.17.0
github.com/grafana/grafana-api-golang-client v0.0.0-20210218192924-9ccd2365d2a6
github.com/hashicorp/go-azure-helpers v0.10.0
github.com/hashicorp/go-cleanhttp v0.5.1
github.com/hashicorp/go-hclog v0.15.0
github.com/hashicorp/go-plugin v1.4.0
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-hclog v0.16.2
github.com/hashicorp/go-memdb v1.3.2 // indirect
github.com/hashicorp/go-plugin v1.4.1
github.com/hashicorp/hcl v1.0.0
github.com/hashicorp/terraform v0.12.31
github.com/hashicorp/vault v0.10.4
github.com/heimweh/go-pagerduty v0.0.0-20210412205347-cc0e5d3c14d4
github.com/heroku/heroku-go/v5 v5.1.0
github.com/hokaccha/go-prettyjson v0.0.0-20210113012101-fb4e108d2519 // indirect
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334
github.com/jefferai/jsonx v1.0.1 // indirect
github.com/jmespath/go-jmespath v0.4.0
github.com/jonboydell/logzio_client v1.2.0
github.com/labd/commercetools-go-sdk v0.3.1
github.com/linode/linodego v0.24.1
github.com/mrparkers/terraform-provider-keycloak v0.0.0-20200506151941-509881368409
github.com/nicksnyder/go-i18n v1.10.1 // indirect
github.com/ns1/ns1-go v2.4.0+incompatible
github.com/okta/okta-sdk-golang/v2 v2.3.1
github.com/okta/terraform-provider-okta v0.0.0-20210723144213-09bad12091e9
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opencontainers/runc v1.0.1 // indirect
github.com/ory/dockertest v3.3.5+incompatible // indirect
github.com/packethost/packngo v0.9.0
github.com/paultyng/go-newrelic/v4 v4.10.0
github.com/pkg/errors v0.9.1
Expand All @@ -135,14 +153,15 @@ require (
github.com/vultr/govultr v0.5.0
github.com/yandex-cloud/go-genproto v0.0.0-20200722140432-762fe965ce77
github.com/yandex-cloud/go-sdk v0.0.0-20200722140627-2194e5077f13
github.com/zclconf/go-cty v1.7.1
github.com/zclconf/go-cty v1.8.4
github.com/zorkian/go-datadog-api v2.30.0+incompatible
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99
golang.org/x/text v0.3.5
golang.org/x/text v0.3.6
gonum.org/v1/gonum v0.7.0
google.golang.org/api v0.40.0
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705
gopkg.in/jarcoal/httpmock.v1 v1.0.0-00010101000000-000000000000 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
k8s.io/apimachinery v0.21.0
k8s.io/client-go v0.21.0
)
Expand Down
Loading

0 comments on commit dd5512d

Please sign in to comment.