diff --git a/.gitignore b/.gitignore index 7286fca..82aa1f5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ terraform.tfvars terraform.tfplan terraform.tfstate bin/ -terraform-provider-monte-carlo +terraform-provider-montecarlo modules-dev/ /pkg/ website/.vagrant diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..bd37524 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,46 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "montecarlo Provider" +subcategory: "" +description: |- + This open-source Terraform provider enables users to seamlessly and quickly integrate the Monte Carlo https://www.montecarlodata.com/ data reliabillity platform into their infrastructure as a code (IaC) workflows. Provider ensures this functionality by communicating with Monte Carlo via its GraphQL API. +--- + +# montecarlo Provider + +This open-source _Terraform_ provider enables users to seamlessly and quickly integrate the **[Monte Carlo](https://www.montecarlodata.com/)** data reliabillity platform into their infrastructure as a code (IaC) workflows. Provider ensures this functionality by communicating with **Monte Carlo** via its GraphQL API. + +## Example Usage + +```terraform +terraform { + required_providers { + monte_carlo = { + source = "kiwicom/montecarlo" + version = "~> 0.0.1" + } + } +} + +provider "monte_carlo" { + account_service_key = { + id = "montecarlo" + token = "montecarlo" + } +} +``` + + +## Schema + +### Required + +- `account_service_key` (Attributes) Monte Carlo generated **Account Service Key** used to authenticate API calls of this provider. Should not be confused with personal API key.

For more information: https://docs.getmontecarlo.com/docs/creating-an-api-token#creating-an-api-key

(see [below for nested schema](#nestedatt--account_service_key)) + + +### Nested Schema for `account_service_key` + +Required: + +- `id` (String, Sensitive) Monte Carlo _Account service key_ **ID**. +- `token` (String, Sensitive) Monte Carlo _Account service key_ **token**. diff --git a/docs/resources/bigquery_warehouse.md b/docs/resources/bigquery_warehouse.md new file mode 100644 index 0000000..6573105 --- /dev/null +++ b/docs/resources/bigquery_warehouse.md @@ -0,0 +1,40 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "montecarlo_bigquery_warehouse Resource - terraform-provider-montecarlo" +subcategory: "" +description: |- + This resource represents the integration of Monte Carlo with BigQuery data warehouse. While this resource is not responsible for handling data access and other operations, such as data filtering, it is responsible for managing the connection to BigQuery using the provided service account key. +--- + +# montecarlo_bigquery_warehouse (Resource) + +This resource represents the integration of Monte Carlo with BigQuery data warehouse. While this resource is not responsible for handling data access and other operations, such as data filtering, it is responsible for managing the connection to BigQuery using the provided service account key. + +## Example Usage + +```terraform +resource "montecarlo_bigquery_warehouse" "example" { + name = "name" + data_collector_uuid = "uuid" + service_account_key = "{}" + deletion_protection = false +} +``` + + +## Schema + +### Required + +- `data_collector_uuid` (String) Unique identifier of data collector this warehouse will be attached to. Its not possible to change data collectors of already created warehouse, therefore if Terraform detects change in this attribute it will plan recreation (which might not be successfull due to deletion protection flag). Since this property is immutable in Monte Carlo warehouses it can be only changed in the configuration +- `name` (String) The name of the BigQuery warehouse as it will be presented in Monte Carlo. +- `service_account_key` (String, Sensitive) Service account key used by the warehouse connection for authentication and authorization against BigQuery. The very same service account is used to grant required permissions to Monte Carlo BigQuery warehouse for the data access. For more information follow Monte Carlo documentation: https://docs.getmontecarlo.com/docs/bigquery + +### Optional + +- `deletion_protection` (Boolean) Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the instance will fail. This setting will prevent the deletion even if the real resource is already deleted. + +### Read-Only + +- `connection_uuid` (String) Unique identifier of connection responsible for communication with BigQuery. +- `uuid` (String) Unique identifier of warehouse managed by this resource. diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..026c42c --- /dev/null +++ b/examples/README.md @@ -0,0 +1,9 @@ +# Examples + +This directory contains examples that are mostly used for documentation, but can also be run/tested manually via the Terraform CLI. + +The document generation tool looks for files in the following locations by default. All other *.tf files besides the ones mentioned below are ignored by the documentation tool. This is useful for creating examples that can run and/or ar testable even if some parts are not relevant for the documentation. + +* **provider/provider.tf** example file for the provider index page +* **data-sources/`full data source name`/data-source.tf** example file for the named data source page +* **resources/`full resource name`/resource.tf** example file for the named data source page diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf new file mode 100644 index 0000000..1374893 --- /dev/null +++ b/examples/provider/provider.tf @@ -0,0 +1,15 @@ +terraform { + required_providers { + monte_carlo = { + source = "kiwicom/montecarlo" + version = "~> 0.0.1" + } + } +} + +provider "monte_carlo" { + account_service_key = { + id = "montecarlo" + token = "montecarlo" + } +} diff --git a/examples/resources/montecarlo_bigquery_warehouse/resource.tf b/examples/resources/montecarlo_bigquery_warehouse/resource.tf new file mode 100644 index 0000000..7461955 --- /dev/null +++ b/examples/resources/montecarlo_bigquery_warehouse/resource.tf @@ -0,0 +1,6 @@ +resource "montecarlo_bigquery_warehouse" "example" { + name = "name" + data_collector_uuid = "uuid" + service_account_key = "{}" + deletion_protection = false +} diff --git a/go.mod b/go.mod index 3e94a73..6292577 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/kiwicom/terraform-provider-monte-carlo +module github.com/kiwicom/terraform-provider-montecarlo go 1.21.1 @@ -20,8 +20,8 @@ require ( github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect github.com/klauspost/compress v1.16.7 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/oklog/run v1.0.0 // indirect github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect @@ -32,5 +32,6 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect google.golang.org/grpc v1.57.0 // indirect google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/yaml.v2 v2.3.0 // indirect nhooyr.io/websocket v1.8.7 // indirect ) diff --git a/go.sum b/go.sum index a0c3d28..e3da3d7 100644 --- a/go.sum +++ b/go.sum @@ -71,11 +71,13 @@ github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQs github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= @@ -107,6 +109,7 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -125,8 +128,9 @@ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index 7af7ba4..33f8396 100644 --- a/main.go +++ b/main.go @@ -5,11 +5,21 @@ import ( "flag" "log" - "github.com/kiwicom/terraform-provider-monte-carlo/monte_carlo/provider" + "github.com/kiwicom/terraform-provider-montecarlo/monte_carlo/provider" "github.com/hashicorp/terraform-plugin-framework/providerserver" ) +// Run "go generate" to format example terraform files and generate the docs for the registry/website + +// If you do not have terraform installed, you can remove the formatting command, but its suggested to +// ensure the documentation is formatted properly. +//go:generate terraform fmt -recursive ./examples/ + +// Run the docs generation tool, check its repository for more information on how it works and how docs +// can be customized. +//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.16.0 + var ( // these will be set by the goreleaser configuration // to appropriate values for the compiled binary. @@ -18,7 +28,7 @@ var ( func main() { flag.Parse() - opts := providerserver.ServeOpts{Address: "registry.terraform.io/kiwicom/data-platform", Debug: false} + opts := providerserver.ServeOpts{Address: "registry.terraform.io/kiwicom/montecarlo", Debug: false} if err := providerserver.Serve(context.Background(), provider.New(version), opts); err != nil { log.Fatal(err.Error()) } diff --git a/monte_carlo/common/common.go b/monte_carlo/common/common.go index 7bf4e29..a21f26d 100644 --- a/monte_carlo/common/common.go +++ b/monte_carlo/common/common.go @@ -1,6 +1,6 @@ package common -import "github.com/kiwicom/terraform-provider-monte-carlo/monte_carlo/client" +import "github.com/kiwicom/terraform-provider-montecarlo/monte_carlo/client" // Cyclic types commonly shared in this provider packages diff --git a/monte_carlo/provider/provider.go b/monte_carlo/provider/provider.go index 83602bb..f0514cf 100644 --- a/monte_carlo/provider/provider.go +++ b/monte_carlo/provider/provider.go @@ -4,9 +4,9 @@ import ( "context" "fmt" - "github.com/kiwicom/terraform-provider-monte-carlo/monte_carlo/client" - "github.com/kiwicom/terraform-provider-monte-carlo/monte_carlo/common" - "github.com/kiwicom/terraform-provider-monte-carlo/monte_carlo/resources" + "github.com/kiwicom/terraform-provider-montecarlo/monte_carlo/client" + "github.com/kiwicom/terraform-provider-montecarlo/monte_carlo/common" + "github.com/kiwicom/terraform-provider-montecarlo/monte_carlo/resources" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/provider" @@ -38,25 +38,29 @@ type ProviderAccountServiceKeyModel struct { } func (p *Provider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) { - resp.TypeName = "monte_carlo" + resp.TypeName = "montecarlo" resp.Version = p.version } func (p *Provider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { resp.Schema = schema.Schema{ - Blocks: map[string]schema.Block{ - "account_service_key": schema.SingleNestedBlock{ - MarkdownDescription: "Monte Carlo generated Account Service Key used to authenticate API calls of " + - "this provider. Should not be confused with personal API key. For more information: " + - "https://docs.getmontecarlo.com/docs/creating-an-api-token#creating-an-api-key", + MarkdownDescription: "This open-source _Terraform_ provider enables users to seamlessly and quickly integrate the " + + "**[Monte Carlo](https://www.montecarlodata.com/)** data reliabillity platform into their infrastructure as a code " + + "(IaC) workflows. Provider ensures this functionality by communicating with **Monte Carlo** via its GraphQL API.", + Attributes: map[string]schema.Attribute{ + "account_service_key": schema.SingleNestedAttribute{ + MarkdownDescription: "Monte Carlo generated **Account Service Key** used to authenticate API calls of " + + "this provider. Should not be confused with personal API key.

For more information: " + + "https://docs.getmontecarlo.com/docs/creating-an-api-token#creating-an-api-key

", + Required: true, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - MarkdownDescription: "Monte Carlo Account service key ID.", + MarkdownDescription: "Monte Carlo **Account service key** _ID_.", Required: true, Sensitive: true, }, "token": schema.StringAttribute{ - MarkdownDescription: "Monte Carlo Account service key token.", + MarkdownDescription: "Monte Carlo **Account service key** _token_.", Required: true, Sensitive: true, }, diff --git a/monte_carlo/resources/bigquery_warehouse.go b/monte_carlo/resources/bigquery_warehouse.go index 2c510da..d1ac35f 100644 --- a/monte_carlo/resources/bigquery_warehouse.go +++ b/monte_carlo/resources/bigquery_warehouse.go @@ -6,8 +6,8 @@ import ( "encoding/json" "fmt" - "github.com/kiwicom/terraform-provider-monte-carlo/monte_carlo/client" - "github.com/kiwicom/terraform-provider-monte-carlo/monte_carlo/common" + "github.com/kiwicom/terraform-provider-montecarlo/monte_carlo/client" + "github.com/kiwicom/terraform-provider-montecarlo/monte_carlo/common" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path"