Skip to content
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

feat: added federated graph and federated subgraph resources #6

Merged
merged 1 commit into from
Jul 29, 2024
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
3 changes: 3 additions & 0 deletions .changes/unreleased/Added-20240729-083340.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Added
body: added wundergraph_federated_graph and wundergraph_federated_subgraph resources
time: 2024-07-29T08:33:40.812506446+02:00
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
# Terraform Provider Scaffolding (Terraform Plugin Framework)
# Terraform Provider Wundergraph

_This template repository is built on the [Terraform Plugin Framework](https://github.com/hashicorp/terraform-plugin-framework). The template repository built on the [Terraform Plugin SDK](https://github.com/hashicorp/terraform-plugin-sdk) can be found at [terraform-provider-scaffolding](https://github.com/hashicorp/terraform-provider-scaffolding). See [Which SDK Should I Use?](https://developer.hashicorp.com/terraform/plugin/framework-benefits) in the Terraform documentation for additional information._

This repository is a *template* for a [Terraform](https://www.terraform.io) provider. It is intended as a starting point for creating Terraform providers, containing:

- A resource and a data source (`internal/provider/`),
- Examples (`examples/`) and generated documentation (`docs/`),
- Miscellaneous meta files.

These files contain boilerplate code that you will need to edit to create your own Terraform provider. Tutorials for creating Terraform providers can be found on the [HashiCorp Developer](https://developer.hashicorp.com/terraform/tutorials/providers-plugin-framework) platform. _Terraform Plugin Framework specific guides are titled accordingly._

Please see the [GitHub template repository documentation](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template) for how to create a new repository from this template on GitHub.

Once you've written your provider, you'll want to [publish it on the Terraform Registry](https://developer.hashicorp.com/terraform/registry/providers/publishing) so that others can use it.
This is the Terraform provider for [Wundergraph](https://wundergraph.com/).

## Requirements

Expand Down
54 changes: 54 additions & 0 deletions docs/resources/federated_graph.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "wundergraph_federated_graph Resource - terraform-provider-wundergraph"
subcategory: ""
description: |-
Federated graph.
---

# wundergraph_federated_graph (Resource)

Federated graph.

## Example Usage

```terraform
resource "wundergraph_federated_graph" "my-federated-graph" {
name = "my.federated.graph"
namespace = "default"
routing_url = "https://my-federated-graph.com"
label_matchers = [
{
key = "some"
values = ["label"]
}
]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name of the federated graph to create. It is usually in the format of <org>.<env> and is used to uniquely identify your federated graph.
- `routing_url` (String) The routing url of your router. This is the url that the router will be accessible at.

### Optional

- `admission_webhook_secret` (String, Sensitive) The admission webhook secret is used to sign requests to the webhook url.
- `admission_webhook_url` (String) The admission webhook url. This is the url that the controlplane will use to implement admission control for the federated graph.
- `label_matchers` (Attributes List) The label matcher is used to select the subgraphs to federate. (see [below for nested schema](#nestedatt--label_matchers))
- `namespace` (String) The namespace name of the federated graph.

### Read-Only

- `id` (String) Identifier

<a id="nestedatt--label_matchers"></a>
### Nested Schema for `label_matchers`

Required:

- `key` (String) The key of the label matcher.
- `values` (List of String) The key of the label matcher.
52 changes: 52 additions & 0 deletions docs/resources/federated_subgraph.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "wundergraph_federated_subgraph Resource - terraform-provider-wundergraph"
subcategory: ""
description: |-
federated subgraph resource.
---

# wundergraph_federated_subgraph (Resource)

federated subgraph resource.

## Example Usage

```terraform
data "local_file" "schema" {
filename = "${path.module}/my-subgraph.graphql"
}

resource "wundergraph_federated_subgraph" "my-subgraph" {
name = "my.subgraph"
namespace = "default"
schema = data.local_file.schema.content
routing_url = "https://my-subgraph.com"
labels = {
"some" = "label"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name of the subgraph to create. It is usually in the format of <org>.<service.name> and is used to uniquely identify your federated subgraph.
- `schema` (String) The schema to upload to the subgraph. This should be the full schema in SDL format.

### Optional

- `is_event_driven_graph` (Boolean) Set whether the subgraph is an Event-Driven Graph (EDG). Errors will be returned for the inclusion of most other parameters if the subgraph is an Event-Driven Graph.
- `is_feature_subgraph` (Boolean) Set whether the subgraph is a feature subgraph.
- `labels` (Map of String) The labels to apply to the subgraph.
- `namespace` (String) The namespace name of the subgraph.
- `routing_url` (String) The routing URL of your subgraph. This is the url at which the subgraph will be accessible. Required unless the event-driven-graph flag is set. Returns an error if the event-driven-graph flag is set.
- `subscription_protocol` (String) The protocol to use when subscribing to the subgraph. The supported protocols are ws, sse, and sse_post.
- `subscription_url` (String) The protocol to use when subscribing to the subgraph. The supported protocols are ws, sse, and sse_post. Returns an error if the event-driven-graph flag is set.
- `websocket_subprotocol` (String) The subprotocol to use when subscribing to the subgraph. The supported protocols are auto, graphql-ws, and graphql-transport-ws. Should be used only if the subscription protocol is ws. For more information see https://cosmo-docs.wundergraph.com/router/subscriptions/websocket-subprotocols.

### Read-Only

- `id` (String) Identifier
11 changes: 11 additions & 0 deletions examples/resources/wundergraph_federated_graph/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resource "wundergraph_federated_graph" "my-federated-graph" {
name = "my.federated.graph"
namespace = "default"
routing_url = "https://my-federated-graph.com"
label_matchers = [
{
key = "some"
values = ["label"]
}
]
}
13 changes: 13 additions & 0 deletions examples/resources/wundergraph_federated_subgraph/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
data "local_file" "schema" {
filename = "${path.module}/my-subgraph.graphql"
}

resource "wundergraph_federated_subgraph" "my-subgraph" {
name = "my.subgraph"
namespace = "default"
schema = data.local_file.schema.content
routing_url = "https://my-subgraph.com"
labels = {
"some" = "label"
}
}
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ require (
connectrpc.com/connect v1.16.2
github.com/hashicorp/terraform-plugin-docs v0.19.4
github.com/hashicorp/terraform-plugin-framework v1.10.0
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0
github.com/hashicorp/terraform-plugin-go v0.23.0
github.com/stretchr/testify v1.9.0
google.golang.org/protobuf v1.34.2
)

Expand All @@ -25,6 +27,7 @@ require (
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/bufbuild/protocompile v0.14.0 // indirect
github.com/cloudflare/circl v1.3.9 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
Expand Down Expand Up @@ -54,11 +57,11 @@ require (
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/yuin/goldmark v1.7.4 // indirect
Expand All @@ -71,7 +74,7 @@ require (
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f // indirect
google.golang.org/grpc v1.65.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSey
github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA=
github.com/hashicorp/terraform-plugin-framework v1.10.0 h1:xXhICE2Fns1RYZxEQebwkB2+kXouLC932Li9qelozrc=
github.com/hashicorp/terraform-plugin-framework v1.10.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM=
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 h1:bxZfGo9DIUoLLtHMElsu+zwqI4IsMZQBRRy4iLzZJ8E=
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0/go.mod h1:wGeI02gEhj9nPANU62F2jCaHjXulejm/X+af4PdZaNo=
github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co=
github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
Expand Down Expand Up @@ -233,6 +235,8 @@ golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade h1:oCRSWfwGXQsqlVdErcyTt4A93Y8fo0/9D4b1gnI++qo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f h1:RARaIm8pxYuxyNPbBQf5igT7XdOyCNtat1qAT2ZxjU4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240725223205-93522f1f2a9f/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ func (p *WundergraphProvider) Configure(ctx context.Context, req provider.Config
func (p *WundergraphProvider) Resources(ctx context.Context) []func() resource.Resource {
return []func() resource.Resource{
resources.NewNamespaceResource,
resources.NewFederatedSubgraphResource,
resources.NewFederatedGraphResource,
}
}

Expand Down
Loading
Loading