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

Add Hyperdrive Resource provider #3111

Merged
merged 8 commits into from
Mar 14, 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 .changelog/3111.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
cloudflare_hyperdrive_config
```
86 changes: 86 additions & 0 deletions docs/resources/hyperdrive_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
page_title: "cloudflare_hyperdrive_config Resource - Cloudflare"
subcategory: ""
description: |-
The Hyperdrive Config https://developers.cloudflare.com/hyperdrive/ resource allows you to manage Cloudflare Hyperdrive Configs.
---

# cloudflare_hyperdrive_config (Resource)

The [Hyperdrive Config](https://developers.cloudflare.com/hyperdrive/) resource allows you to manage Cloudflare Hyperdrive Configs.

## Example Usage

```terraform
# Config using all default values
resource "cloudflare_hyperdrive_config" "no_defaults" {
account_id = "f037e56e89293a057740de681ac9abbe"
name = "my-hyperdrive-config"
origin = {
database = "postgres"
password = "my-password"
host = "my-database.example.com"
port = 5432
scheme = "postgres"
user = "my-user"
}
}

# Config not using any default values
resource "cloudflare_hyperdrive_config" "no_defaults" {
account_id = "f037e56e89293a057740de681ac9abbe"
name = "my-hyperdrive-config"
origin = {
database = "postgres"
password = "my-password"
host = "my-database.example.com"
port = 5432
scheme = "postgres"
user = "my-user"
}
caching = {
disabled = false
}
}
```
<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `account_id` (String) The account identifier to target for the resource.
- `name` (String) The name of the Hyperdrive configuration.
- `origin` (Attributes) The origin details for the Hyperdrive configuration. (see [below for nested schema](#nestedatt--origin))

### Optional

- `caching` (Attributes) The caching details for the Hyperdrive configuration. (see [below for nested schema](#nestedatt--caching))
- `id` (String) The identifier of this resource. This is the hyperdrive config value.

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

Required:

- `database` (String) The name of your origin database.
- `host` (String) The host (hostname or IP) of your origin database.
- `password` (String, Sensitive) The password of the Hyperdrive configuration.
- `port` (Number) The port (default: 5432 for Postgres) of your origin database.
carlos-alberto marked this conversation as resolved.
Show resolved Hide resolved
- `scheme` (String) Specifies the URL scheme used to connect to your origin database.
- `user` (String) The user of your origin database.


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

Optional:

- `disabled` (Boolean) Disable caching for this Hyperdrive configuration.

## Import

Import is supported using the following syntax:

```shell
$ terraform import cloudflare_hyperdrive_config.example <account_id>/<hyperdrive_config_id>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$ terraform import cloudflare_hyperdrive_config.example <account_id>/<hyperdrive_config_id>
12 changes: 12 additions & 0 deletions examples/resources/cloudflare_hyperdrive_config/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "cloudflare_hyperdrive_config" "no_defaults" {
account_id = "f037e56e89293a057740de681ac9abbe"
name = "my-hyperdrive-config"
origin = {
database = "postgres"
password = "my-password"
host = "my-database.example.com"
port = 5432
scheme = "postgres"
user = "my-user"
}
}
2 changes: 2 additions & 0 deletions internal/framework/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/cloudflare/terraform-provider-cloudflare/internal/framework/service/dlp_datasets"
"github.com/cloudflare/terraform-provider-cloudflare/internal/framework/service/email_routing_address"
"github.com/cloudflare/terraform-provider-cloudflare/internal/framework/service/email_routing_rule"
"github.com/cloudflare/terraform-provider-cloudflare/internal/framework/service/hyperdrive_config"
"github.com/cloudflare/terraform-provider-cloudflare/internal/framework/service/list_item"
"github.com/cloudflare/terraform-provider-cloudflare/internal/framework/service/origin_ca_certificate"
"github.com/cloudflare/terraform-provider-cloudflare/internal/framework/service/r2_bucket"
Expand Down Expand Up @@ -334,6 +335,7 @@ func (p *CloudflareProvider) Resources(ctx context.Context) []func() resource.Re
d1.NewResource,
email_routing_address.NewResource,
email_routing_rule.NewResource,
hyperdrive_config.NewResource,
list_item.NewResource,
r2_bucket.NewResource,
rulesets.NewResource,
Expand Down
33 changes: 33 additions & 0 deletions internal/framework/service/hyperdrive_config/model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package hyperdrive_config

import (
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
)

type HyperdriveConfigModel struct {
AccountID types.String `tfsdk:"account_id"`
ID types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
Origin *HyperdriveConfigOriginModel `tfsdk:"origin"`
Caching types.Object `tfsdk:"caching"`
}

type HyperdriveConfigOriginModel struct {
Database types.String `tfsdk:"database"`
Password types.String `tfsdk:"password"`
Host types.String `tfsdk:"host"`
Port types.Int64 `tfsdk:"port"`
Scheme types.String `tfsdk:"scheme"`
User types.String `tfsdk:"user"`
}

type HyperdriveConfigCachingModel struct {
Disabled types.Bool `tfsdk:"disabled"`
}

func (m HyperdriveConfigCachingModel) AttributeTypes() map[string]attr.Type {
return map[string]attr.Type{
"disabled": types.BoolType,
}
}
Loading
Loading