-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release initial version of sys11dbaas terraform provider
Signed-off-by: Niklas Ott <[email protected]>
- Loading branch information
0 parents
commit 55c618e
Showing
18 changed files
with
5,371 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.tfstate | ||
*.tfstate.backup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
include: | ||
- project: syseleven/gitlab-ci-templates | ||
ref: 3.29.3 | ||
file: job-templates/TerraformValidate.yml | ||
- project: syseleven/gitlab-ci-templates | ||
ref: 3.29.3 | ||
file: job-templates/TerraformFormat.yml | ||
- project: syseleven/gitlab-ci-templates | ||
ref: 3.29.3 | ||
file: MarkdownLint.yml | ||
|
||
stages: | ||
- test | ||
|
||
workflow: | ||
rules: | ||
- if: $CI_MERGE_REQUEST_IID | ||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH | ||
- if: $CI_COMMIT_TAG | ||
|
||
default: | ||
retry: | ||
max: 2 | ||
when: | ||
- runner_system_failure | ||
|
||
################################################################## | ||
# JOBS # | ||
################################################################## | ||
|
||
terraform-format: | ||
extends: | ||
- .terraform-format | ||
|
||
terraform-validate: | ||
extends: | ||
- .terraform-validate | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# it's generated and the genereator has some interesting design choices, so ignore it | ||
docs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# terraform-provider-sys11dbaas | ||
|
||
## Generator | ||
|
||
This project was initially generated using [terraform-plugin-codegen-openapi](https://github.com/hashicorp/terraform-plugin-codegen-openapi) | ||
and [terraform-plugin-codegen-framework](https://github.com/hashicorp/terraform-plugin-codegen-framework) | ||
However, i had to fix so much stuff by hand, i don't think those can ever be used again to add something to this provider. | ||
But feel free to try in a branch. I left the provider-spec file in the repo. | ||
|
||
## Development | ||
|
||
Override the provider in your `~/.terraformrc` file: | ||
|
||
```terraform | ||
provider_installation { | ||
dev_overrides { | ||
"registry.terraform.io/syseleven/sys11dbaas" = "/home/me/go/bin" | ||
} | ||
# For all other providers, install them directly from their origin provider | ||
# registries as normal. If you omit this, Terraform will _only_ use | ||
# the dev_overrides block, and so no other providers will be available. | ||
direct {} | ||
} | ||
``` | ||
|
||
Then run `go install` in this directory. You should now be able to use the provider. | ||
|
||
```terraform | ||
terraform { | ||
required_providers { | ||
sys11dbaas = { | ||
source = "registry.terraform.io/syseleven/sys11dbaas" | ||
} | ||
} | ||
} | ||
provider "sys11dbaas" { | ||
[...] | ||
} | ||
``` | ||
|
||
Don't forget to run `go install` again after code changes. | ||
|
||
## Generate docs | ||
|
||
```bash | ||
go generate | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "sys11dbaas Provider" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# sys11dbaas Provider | ||
|
||
|
||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `api_key` (String) | ||
- `organization` (String) | ||
- `project` (String) | ||
- `url` (String) | ||
- `wait_for_creation` (Boolean) Wait until databases are fully deployed and usable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "sys11dbaas_database Resource - terraform-provider-sys11dbaas" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# sys11dbaas_database (Resource) | ||
|
||
|
||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `application_config` (Attributes) (see [below for nested schema](#nestedatt--application_config)) | ||
- `name` (String) The name of the database. | ||
- `service_config` (Attributes) (see [below for nested schema](#nestedatt--service_config)) | ||
|
||
### Optional | ||
|
||
- `description` (String) fulltext description of the database | ||
|
||
### Read-Only | ||
|
||
- `created_at` (String) the date when the database was created | ||
- `created_by` (String) the initial creator of the database | ||
- `last_modified_at` (String) the date when the database was last modified | ||
- `last_modified_by` (String) the user who last changed of the database | ||
- `phase` (String) | ||
- `resource_status` (String) | ||
- `status` (String) | ||
- `uuid` (String) The UUID of the database. | ||
|
||
<a id="nestedatt--application_config"></a> | ||
### Nested Schema for `application_config` | ||
|
||
Required: | ||
|
||
- `instances` (Number) How many nodes the cluster should have | ||
- `type` (String) | ||
- `version` (String) minor version of postgresql | ||
|
||
Optional: | ||
|
||
- `password` (String, Sensitive) The password for the admin user | ||
- `recovery` (Attributes) (see [below for nested schema](#nestedatt--application_config--recovery)) | ||
- `scheduled_backups` (Attributes) The scheduled backup policy for the database. (see [below for nested schema](#nestedatt--application_config--scheduled_backups)) | ||
|
||
Read-Only: | ||
|
||
- `hostname` (String) The dns name of the database in the format uuid.postgresql.syseleven.services. | ||
- `ip_address` (String) The public IP address of the database. It will be pending if no address has been assigned yet. | ||
|
||
<a id="nestedatt--application_config--recovery"></a> | ||
### Nested Schema for `application_config.recovery` | ||
|
||
Optional: | ||
|
||
- `exclusive` (Boolean) | ||
- `source` (String) | ||
- `target_lsn` (String) | ||
- `target_name` (String) | ||
- `target_time` (String) | ||
- `target_xid` (String) | ||
|
||
|
||
<a id="nestedatt--application_config--scheduled_backups"></a> | ||
### Nested Schema for `application_config.scheduled_backups` | ||
|
||
Optional: | ||
|
||
- `retention` (Number) How long Backups should be stored | ||
- `schedule` (Attributes) The schedules for the backup policy. (see [below for nested schema](#nestedatt--application_config--scheduled_backups--schedule)) | ||
|
||
<a id="nestedatt--application_config--scheduled_backups--schedule"></a> | ||
### Nested Schema for `application_config.scheduled_backups.schedule` | ||
|
||
Optional: | ||
|
||
- `hour` (Number) The hour when the full backup should start. If this value is omitted, a random hour between 1am and 5am will be generated. | ||
- `minute` (Number) The minute when the full backup should start. If this value is omitted, a random minute will be generated. | ||
|
||
|
||
|
||
|
||
<a id="nestedatt--service_config"></a> | ||
### Nested Schema for `service_config` | ||
|
||
Required: | ||
|
||
- `disksize` (Number) Disksize in GB | ||
- `flavor` (String) vm flavor to use | ||
- `region` (String) the region for the database | ||
- `type` (String) | ||
|
||
Optional: | ||
|
||
- `maintenance_window` (Attributes) The maintenance window. This will be a time window for updates and maintenance. If omitted, a random window will be generated. (see [below for nested schema](#nestedatt--service_config--maintenance_window)) | ||
- `remote_ips` (List of String) List of IP addresses, that should be allowed to connect to the database | ||
|
||
<a id="nestedatt--service_config--maintenance_window"></a> | ||
### Nested Schema for `service_config.maintenance_window` | ||
|
||
Optional: | ||
|
||
- `day_of_week` (Number) Day of week as a cron time (0=Sun, 1=Mon, ..., 6=Sat). If omitted, a random day will be used. | ||
- `start_hour` (Number) Hour when the maintenance window starts. If omitted, a random hour between 20 and 4 will be used. | ||
- `start_minute` (Number) Minute when the maintenance window starts. If omitted, a random minute will be used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Example PostgreSQL DB | ||
|
||
```bash | ||
TF_VAR_api_key=$DBAAS_TOKEN TF_VAR_api_url=$DBAAS_URL TF_VAR_project=$DBAAS_PROJECT TF_VAR_org=$DBAAS_ORG terraform plan | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
terraform { | ||
required_version = ">= 1.8" | ||
required_providers { | ||
sys11dbaas = { | ||
source = "registry.terraform.io/syseleven/sys11dbaas" | ||
version = "~> 1" | ||
} | ||
} | ||
} | ||
|
||
variable "api_key" { | ||
type = string | ||
} | ||
|
||
variable "api_url" { | ||
type = string | ||
} | ||
|
||
variable "project" { | ||
type = string | ||
} | ||
|
||
variable "org" { | ||
type = string | ||
} | ||
|
||
provider "sys11dbaas" { | ||
url = var.api_url | ||
api_key = var.api_key | ||
project = var.project | ||
organization = var.org | ||
wait_for_creation = "true" | ||
} | ||
|
||
resource "sys11dbaas_database" "my_first_tf_db" { | ||
name = "my-first-terraform-db" | ||
description = "this is my first terraform db" | ||
application_config = { | ||
instances = 3 | ||
password = "veryS3cretPassword" | ||
type = "postgresql" | ||
version = 16.2 | ||
scheduled_backups = { | ||
schedule = { | ||
hour = 4 | ||
} | ||
} | ||
} | ||
service_config = { | ||
disksize = 25 | ||
flavor = "m2c.small" | ||
region = "dus2" | ||
type = "database" | ||
remote_ips = [ | ||
"0.0.0.0/0" | ||
] | ||
} | ||
} | ||
|
||
output "my_first_tf_db" { | ||
value = [resource.sys11dbaas_database.my_first_tf_db.uuid, resource.sys11dbaas_database.my_first_tf_db.status, resource.sys11dbaas_database.my_first_tf_db.phase, resource.sys11dbaas_database.my_first_tf_db.resource_status] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
provider: | ||
name: sys11dbaas | ||
resources: | ||
database: | ||
create: | ||
path: /{org_id}/{project_id}/v1/databases | ||
method: POST | ||
read: | ||
path: /{org_id}/{project_id}/v1/databases/{db_uuid} | ||
method: GET | ||
update: | ||
path: /{org_id}/{project_id}/v1/databases/{db_uuid} | ||
method: PUT | ||
delete: | ||
path: /{org_id}/{project_id}/v1/databases/{db_uuid} | ||
method: DELETE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module terraform-provider-sys11dbaas | ||
|
||
go 1.21.5 | ||
|
||
require ( | ||
github.com/hashicorp/terraform-plugin-framework v1.6.1 | ||
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 | ||
github.com/hashicorp/terraform-plugin-go v0.22.0 | ||
github.com/hashicorp/terraform-plugin-log v0.9.0 | ||
github.com/syseleven/sys11dbaas-sdk v0.0.0-00010101000000-000000000000 | ||
) | ||
|
||
replace github.com/syseleven/sys11dbaas-sdk => ../sys11dbaas-sdk | ||
|
||
require ( | ||
github.com/fatih/color v1.16.0 // indirect | ||
github.com/golang/protobuf v1.5.4 // indirect | ||
github.com/hashicorp/go-hclog v1.6.2 // indirect | ||
github.com/hashicorp/go-plugin v1.6.0 // indirect | ||
github.com/hashicorp/go-uuid v1.0.3 // indirect | ||
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect | ||
github.com/hashicorp/terraform-svchost v0.1.1 // indirect | ||
github.com/hashicorp/yamux v0.1.1 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/mitchellh/go-testing-interface v1.14.1 // indirect | ||
github.com/oklog/run v1.1.0 // indirect | ||
github.com/stretchr/testify v1.8.2 // indirect | ||
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect | ||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect | ||
golang.org/x/net v0.22.0 // indirect | ||
golang.org/x/sys v0.18.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 // indirect | ||
google.golang.org/grpc v1.62.1 // indirect | ||
google.golang.org/protobuf v1.33.0 // indirect | ||
) |
Oops, something went wrong.