Skip to content

Commit

Permalink
merge upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dcreado committed Sep 12, 2022
2 parents d563f50 + 72ccbe9 commit bc1465e
Show file tree
Hide file tree
Showing 103 changed files with 3,527 additions and 645 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ A CLI tool that generates `tf`/`json` and `tfstate` files based on existing infr
* [RabbitMQ](/docs/rabbitmq.md)
* Network
* [Cloudflare](/docs/cloudflare.md)
* [Myrasec](/docs/myrasec.md)
* [PAN-OS](/docs/panos.md)
* VCS
* [Azure DevOps](/docs/azuredevops.md)
Expand All @@ -54,6 +55,7 @@ A CLI tool that generates `tf`/`json` and `tfstate` files based on existing infr
* [Mackerel](/docs/mackerel.md)
* [PagerDuty](/docs/pagerduty.md)
* [Opsgenie](/docs/opsgenie.md)
* [Honeycomb.io](/docs/honeycombio.md)
* Community
* [Keycloak](/docs/keycloak.md)
* [Logz.io](/docs/logz.md)
Expand Down Expand Up @@ -290,6 +292,7 @@ Links to download Terraform Providers:
* Kubernetes provider >=1.9.0 - [here](https://releases.hashicorp.com/terraform-provider-kubernetes/)
* RabbitMQ provider >=1.1.0 - [here](https://releases.hashicorp.com/terraform-provider-rabbitmq/)
* Network
* Myrasec provider >1.44 - [here](https://github.com/Myra-Security-GmbH/terraform-provider-myrasec)
* Cloudflare provider >1.16 - [here](https://releases.hashicorp.com/terraform-provider-cloudflare/)
* Fastly provider >0.16.1 - [here](https://releases.hashicorp.com/terraform-provider-fastly/)
* NS1 provider >1.8.3 - [here](https://releases.hashicorp.com/terraform-provider-ns1/)
Expand All @@ -302,6 +305,7 @@ Links to download Terraform Providers:
* Mackerel provider > 0.0.6 - [here](https://github.com/mackerelio-labs/terraform-provider-mackerel)
* Pagerduty >=1.9 - [here](https://releases.hashicorp.com/terraform-provider-pagerduty/)
* Opsgenie >= 0.6.0 [here](https://releases.hashicorp.com/terraform-provider-opsgenie/)
* Honeycomb.io >= 0.10.0 - [here](https://github.com/honeycombio/terraform-provider-honeycombio/releases)
* Community
* Keycloak provider >=1.19.0 - [here](https://github.com/mrparkers/terraform-provider-keycloak/)
* Logz.io provider >=1.1.1 - [here](https://github.com/jonboydell/logzio_terraform_provider/)
Expand Down
17 changes: 12 additions & 5 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 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
// 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,
Expand Down Expand Up @@ -52,6 +52,7 @@ type ImportOptions struct {
Filter []string
Plan bool `json:"-"`
Output string
NoSort bool
RetryCount int
RetrySleepMs int
}
Expand All @@ -72,6 +73,11 @@ func newImportCmd() *cobra.Command {
}

cmd.AddCommand(newCmdPlanImporter(options))
cmd.AddCommand(&cobra.Command{
Use: "no-sort",
Short: "Don't sort resources",
Long: "Don't sort resources",
})
for _, subcommand := range providerImporterSubcommands() {
providerCommand := subcommand(options)
_ = providerCommand.MarkPersistentFlagRequired("resources")
Expand Down Expand Up @@ -247,7 +253,7 @@ func printService(provider terraformutils.ProviderGenerator, serviceName string,
log.Println(provider.GetName() + " save " + serviceName)
// Print HCL files for Resources
path := Path(options.PathPattern, provider.GetName(), serviceName, options.PathOutput)
err := terraformoutput.OutputHclFiles(resources, provider, path, serviceName, options.Compact, options.Output)
err := terraformoutput.OutputHclFiles(resources, provider, path, serviceName, options.Compact, options.Output, !options.NoSort)
if err != nil {
return err
}
Expand All @@ -265,7 +271,7 @@ func printService(provider terraformutils.ProviderGenerator, serviceName string,
return err
}
// create Bucket file
if bucketStateDataFile, err := terraformutils.Print(bucket.BucketGetTfData(path), map[string]struct{}{}, options.Output); err == nil {
if bucketStateDataFile, err := terraformutils.Print(bucket.BucketGetTfData(path), map[string]struct{}{}, options.Output, !options.NoSort); err == nil {
terraformoutput.PrintFile(path+"/bucket.tf", bucketStateDataFile)
}
} else {
Expand Down Expand Up @@ -312,7 +318,7 @@ func printService(provider terraformutils.ProviderGenerator, serviceName string,
}
// create variables file
if len(provider.GetResourceConnections()[serviceName]) > 0 && options.Connect && len(variables["data"]["terraform_remote_state"]) > 0 {
variablesFile, err := terraformutils.Print(variables, map[string]struct{}{"config": {}}, options.Output)
variablesFile, err := terraformutils.Print(variables, map[string]struct{}{"config": {}}, options.Output, !options.NoSort)
if err != nil {
return err
}
Expand Down Expand Up @@ -342,7 +348,7 @@ func printService(provider terraformutils.ProviderGenerator, serviceName string,
}
// create variables file
if options.Connect {
variablesFile, err := terraformutils.Print(variables, map[string]struct{}{"config": {}}, options.Output)
variablesFile, err := terraformutils.Print(variables, map[string]struct{}{"config": {}}, options.Output, !options.NoSort)
if err != nil {
return err
}
Expand Down Expand Up @@ -398,6 +404,7 @@ func baseProviderFlags(flag *pflag.FlagSet, options *ImportOptions, sampleRes, s
flag.StringVarP(&options.Bucket, "bucket", "b", "", "gs://terraform-state")
flag.StringSliceVarP(&options.Filter, "filter", "f", []string{}, sampleFilters)
flag.BoolVarP(&options.Verbose, "verbose", "v", false, "")
flag.BoolVarP(&options.NoSort, "no-sort", "S", false, "set to disable sorting of HCL")
flag.StringVarP(&options.Output, "output", "O", "hcl", "output format hcl or json")
flag.IntVarP(&options.RetryCount, "retry-number", "n", 5, "number of retries to perform when refresh fails")
flag.IntVarP(&options.RetrySleepMs, "retry-sleep-ms", "m", 300, "time in ms to sleep between retries")
Expand Down
47 changes: 47 additions & 0 deletions cmd/provider_cmd_honeycombio.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2022 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 (
honeycombio_terraforming "github.com/GoogleCloudPlatform/terraformer/providers/honeycombio"

"github.com/GoogleCloudPlatform/terraformer/terraformutils"
"github.com/spf13/cobra"
)

func newCmdHoneycombioImporter(options ImportOptions) *cobra.Command {
cmd := &cobra.Command{
Use: "honeycombio",
Short: "Import current state to Terraform configuration from Honeycomb.io",
Long: "Import current state to Terraform configuration from Honeycomb.io",
RunE: func(cmd *cobra.Command, args []string) error {
provider := newHoneycombProvider()
err := Import(provider, options, options.Projects)
if err != nil {
return err
}
return nil
},
}

cmd.AddCommand(listCmd(newHoneycombProvider()))
baseProviderFlags(cmd.PersistentFlags(), &options, "derived_column,board", "board=id1,id2")
cmd.PersistentFlags().StringSliceVarP(&options.Projects, "datasets", "", []string{}, "hello-service,goodbye-service")

return cmd
}

func newHoneycombProvider() terraformutils.ProviderGenerator {
return &honeycombio_terraforming.HoneycombProvider{}
}
37 changes: 37 additions & 0 deletions cmd/provider_cmd_myrasec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cmd

import (
myrasec_terraforming "github.com/GoogleCloudPlatform/terraformer/providers/myrasec"
"github.com/GoogleCloudPlatform/terraformer/terraformutils"
"github.com/spf13/cobra"
)

//
// newCmdMyrasecImporter
//
func newCmdMyrasecImporter(options ImportOptions) *cobra.Command {
cmd := &cobra.Command{
Use: "myrasec",
Short: "Import current state to Terraform configuration from Myra Security",
Long: "Import current state to Terraform configuration from Myra Security",
RunE: func(cmd *cobra.Command, args []string) error {
provider := newMyrasecProvider()
err := Import(provider, options, []string{})
if err != nil {
return err
}
return nil
},
}

cmd.AddCommand(listCmd(newMyrasecProvider()))
baseProviderFlags(cmd.PersistentFlags(), &options, "domain", "")
return cmd
}

//
// newMyrasecProvider
//
func newMyrasecProvider() terraformutils.ProviderGenerator {
return &myrasec_terraforming.MyrasecProvider{}
}
4 changes: 4 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func providerImporterSubcommands() []func(options ImportOptions) *cobra.Command
newCmdOctopusDeployImporter,
newCmdRabbitMQImporter,
// Network
newCmdMyrasecImporter,
newCmdCloudflareImporter,
newCmdFastlyImporter,
newCmdNs1Importer,
Expand All @@ -75,6 +76,7 @@ func providerImporterSubcommands() []func(options ImportOptions) *cobra.Command
newCmdGrafanaImporter,
newCmdPagerDutyImporter,
newCmdOpsgenieImporter,
newCmdHoneycombioImporter,
// Community
newCmdKeycloakImporter,
newCmdLogzioImporter,
Expand Down Expand Up @@ -114,6 +116,7 @@ func providerGenerators() map[string]func() terraformutils.ProviderGenerator {
newOctopusDeployProvider,
newRabbitMQProvider,
// Network
newMyrasecProvider,
newCloudflareProvider,
// VCS
newAzureDevOpsProvider,
Expand All @@ -124,6 +127,7 @@ func providerGenerators() map[string]func() terraformutils.ProviderGenerator {
newDataDogProvider,
newNewRelicProvider,
newPagerDutyProvider,
newHoneycombProvider,
// Community
newKeycloakProvider,
newLogzioProvider,
Expand Down
2 changes: 2 additions & 0 deletions docs/heroku.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ List of supported Heroku resources:
* `heroku_pipeline`
* `pipeline_coupling`
* `heroku_pipeline_coupling`
* `team_app`
* `heroku_team_app`
* `team_collaborator`
* `heroku_team_collaborator`
* `team_member`
Expand Down
24 changes: 24 additions & 0 deletions docs/honeycombio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
### Use with Honeycomb.io

Example:

```
export HONEYCOMB_API_KEY=MYAPIKEY
./terraformer import honeycombio --resources=board,trigger
```

List of supported Honeycomb resources:

* `board`
* `honeycombio_board`
* `honeycombio_query`
* `honeycombio_query_annotation`
* `derived_column`
* `honeycombio_derived_column`
* `trigger`
* `honeycombio_trigger`
* `honeycombio_query`
* `slo`
* `honeycombio_slo`
* `honeycombio_burn_alert`
* `honeycombio_derived_column`
31 changes: 31 additions & 0 deletions docs/myrasec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
### Use with Myra Security

Example using a Myra Security API Key and corresponding Token:

```
export MYRASEC_API_SECRET=[MYRASEC_API_SECRET]
export MYRASEC_API_TOKEN=[MYRASEC_API_TOKEN]
./terraformer import myrasec --resources=domain
```

List of supported Myra Security services:
* `domain`
* `myrasec_domain`
* `dns`
* `myrasec_dns_record`
* `redirect`
* `myrasec_redirect`
* `cache_setting`
* `myrasec_cache_setting`
* `ratelimit`
* `myrasec_ratelimit`
* `ip_filter`
* `myrasec_ip_filter`
* `settings`
* `myrasec_settings`
* `waf_rule`
* `myrasec_waf_rule`
* `maintenance`
* `myrasec_maintenance`
* `error_page`
* `myrasec_error_page`

0 comments on commit bc1465e

Please sign in to comment.