-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from johanneswuerbach/cloudsql
feat: cloudsql
- Loading branch information
Showing
37 changed files
with
947 additions
and
13 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
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,59 @@ | ||
# Example: mysql resource based on GCP CloudSQL | ||
|
||
This example configures a [mysql](https://developer.humanitec.com/platform-orchestrator/reference/resource-types/#mysql) Resource Definition using GCP CloudSQL. | ||
|
||
The created Resource Definition can be used in your Score file using: | ||
|
||
```yaml | ||
resources: | ||
... | ||
db: | ||
type: mysql | ||
``` | ||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
| Name | Version | | ||
|------|---------| | ||
| terraform | >= 1.3.0 | | ||
| google | ~> 5.17 | | ||
| humanitec | ~> 0 | | ||
## Providers | ||
| Name | Version | | ||
|------|---------| | ||
| google | ~> 5.17 | | ||
| humanitec | ~> 0 | | ||
## Modules | ||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| mysql | ../../humanitec-resource-defs/mysql/basic | n/a | | ||
## Resources | ||
| Name | Type | | ||
|------|------| | ||
| [google_compute_global_address.private_ip_address](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_global_address) | resource | | ||
| [google_project_service.servicenetworking](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_service) | resource | | ||
| [google_service_networking_connection.private_vpc_connection](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_networking_connection) | resource | | ||
| [humanitec_application.example](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/application) | resource | | ||
| [humanitec_resource_definition_criteria.mysql](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource | | ||
| [google_compute_network.network](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_network) | data source | | ||
## Inputs | ||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| credentials | n/a | `string` | n/a | yes | | ||
| private\_network | The VPC network from which the Cloud SQL instance is accessible for private IP. | `string` | n/a | yes | | ||
| project | n/a | `string` | n/a | yes | | ||
| region | n/a | `string` | n/a | yes | | ||
| name | Name of the example application | `string` | `"hum-rp-mysql-example"` | no | | ||
| prefix | Prefix of the created resources | `string` | `"hum-rp-mysql-ex-"` | no | | ||
| resource\_packs\_gcp\_rev | n/a | `string` | `"ref/heads/main"` | no | | ||
| resource\_packs\_gcp\_url | n/a | `string` | `"https://github.com/humanitec-architecture/resource-packs-gcp.git"` | no | | ||
<!-- END_TF_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,52 @@ | ||
resource "humanitec_application" "example" { | ||
id = var.name | ||
name = var.name | ||
} | ||
|
||
data "google_compute_network" "network" { | ||
name = var.private_network | ||
} | ||
|
||
resource "google_project_service" "servicenetworking" { | ||
service = "servicenetworking.googleapis.com" | ||
disable_on_destroy = false | ||
} | ||
|
||
resource "google_compute_global_address" "private_ip_address" { | ||
name = "${var.prefix}private-ip-address" | ||
purpose = "VPC_PEERING" | ||
address_type = "INTERNAL" | ||
prefix_length = 16 | ||
network = data.google_compute_network.network.id | ||
} | ||
|
||
resource "google_service_networking_connection" "private_vpc_connection" { | ||
network = data.google_compute_network.network.id | ||
service = "servicenetworking.googleapis.com" | ||
reserved_peering_ranges = [google_compute_global_address.private_ip_address.name] | ||
|
||
depends_on = [google_project_service.servicenetworking] | ||
} | ||
|
||
module "mysql" { | ||
source = "../../humanitec-resource-defs/mysql/basic" | ||
|
||
prefix = var.prefix | ||
resource_packs_gcp_rev = var.resource_packs_gcp_rev | ||
resource_packs_gcp_url = var.resource_packs_gcp_url | ||
project = var.project | ||
region = var.region | ||
credentials = var.credentials | ||
|
||
database_version = "MYSQL_8_0" | ||
tier = "db-f1-micro" | ||
private_network = data.google_compute_network.network.id | ||
|
||
depends_on = [google_service_networking_connection.private_vpc_connection] | ||
} | ||
|
||
resource "humanitec_resource_definition_criteria" "mysql" { | ||
resource_definition_id = module.mysql.id | ||
app_id = humanitec_application.example.id | ||
force_delete = true | ||
} |
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,27 @@ | ||
terraform { | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "~> 5.17" | ||
} | ||
humanitec = { | ||
source = "humanitec/humanitec" | ||
version = "~> 0" | ||
} | ||
} | ||
|
||
required_version = ">= 1.3.0" | ||
} | ||
|
||
provider "humanitec" {} | ||
|
||
provider "google" { | ||
project = var.project | ||
region = var.region | ||
credentials = var.credentials | ||
|
||
default_labels = { | ||
"managed_by" = "terraform" | ||
"source" = "github.com/humanitec-architecture/resource-pack-gcp" | ||
} | ||
} |
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,15 @@ | ||
credentials = "" | ||
|
||
# Name of the example application | ||
name = "hum-rp-mysql-example" | ||
|
||
# Prefix of the created resources | ||
prefix = "hum-rp-mysql-ex-" | ||
|
||
# The VPC network from which the Cloud SQL instance is accessible for private IP. | ||
private_network = "" | ||
|
||
project = "" | ||
region = "" | ||
resource_packs_gcp_rev = "ref/heads/main" | ||
resource_packs_gcp_url = "https://github.com/humanitec-architecture/resource-packs-gcp.git" |
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 @@ | ||
variable "name" { | ||
description = "Name of the example application" | ||
type = string | ||
default = "hum-rp-mysql-example" | ||
} | ||
|
||
variable "resource_packs_gcp_rev" { | ||
type = string | ||
default = "ref/heads/main" | ||
} | ||
|
||
variable "resource_packs_gcp_url" { | ||
type = string | ||
default = "https://github.com/humanitec-architecture/resource-packs-gcp.git" | ||
} | ||
|
||
variable "prefix" { | ||
description = "Prefix of the created resources" | ||
type = string | ||
default = "hum-rp-mysql-ex-" | ||
} | ||
|
||
variable "project" { | ||
type = string | ||
} | ||
|
||
variable "region" { | ||
type = string | ||
} | ||
|
||
variable "credentials" { | ||
type = string | ||
} | ||
|
||
variable "private_network" { | ||
type = string | ||
description = "The VPC network from which the Cloud SQL instance is accessible for private IP." | ||
} |
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,59 @@ | ||
# Example: postgres resource based on GCP CloudSQL | ||
|
||
This example configures a [postgres](https://developer.humanitec.com/platform-orchestrator/reference/resource-types/#postgres) Resource Definition using GCP CloudSQL. | ||
|
||
The created Resource Definition can be used in your Score file using: | ||
|
||
```yaml | ||
resources: | ||
... | ||
db: | ||
type: postgres | ||
``` | ||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
| Name | Version | | ||
|------|---------| | ||
| terraform | >= 1.3.0 | | ||
| google | ~> 5.17 | | ||
| humanitec | ~> 0 | | ||
## Providers | ||
| Name | Version | | ||
|------|---------| | ||
| google | ~> 5.17 | | ||
| humanitec | ~> 0 | | ||
## Modules | ||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| postgres | ../../humanitec-resource-defs/postgres/basic | n/a | | ||
## Resources | ||
| Name | Type | | ||
|------|------| | ||
| [google_compute_global_address.private_ip_address](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_global_address) | resource | | ||
| [google_project_service.servicenetworking](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_service) | resource | | ||
| [google_service_networking_connection.private_vpc_connection](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_networking_connection) | resource | | ||
| [humanitec_application.example](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/application) | resource | | ||
| [humanitec_resource_definition_criteria.postgres](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource | | ||
| [google_compute_network.network](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_network) | data source | | ||
## Inputs | ||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| credentials | n/a | `string` | n/a | yes | | ||
| private\_network | The VPC network from which the Cloud SQL instance is accessible for private IP. | `string` | n/a | yes | | ||
| project | n/a | `string` | n/a | yes | | ||
| region | n/a | `string` | n/a | yes | | ||
| name | Name of the example application | `string` | `"hum-rp-postgres-example"` | no | | ||
| prefix | Prefix of the created resources | `string` | `"hum-rp-postgres-ex-"` | no | | ||
| resource\_packs\_gcp\_rev | n/a | `string` | `"ref/heads/main"` | no | | ||
| resource\_packs\_gcp\_url | n/a | `string` | `"https://github.com/humanitec-architecture/resource-packs-gcp.git"` | no | | ||
<!-- END_TF_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,52 @@ | ||
resource "humanitec_application" "example" { | ||
id = var.name | ||
name = var.name | ||
} | ||
|
||
data "google_compute_network" "network" { | ||
name = var.private_network | ||
} | ||
|
||
resource "google_project_service" "servicenetworking" { | ||
service = "servicenetworking.googleapis.com" | ||
disable_on_destroy = false | ||
} | ||
|
||
resource "google_compute_global_address" "private_ip_address" { | ||
name = "${var.prefix}private-ip-address" | ||
purpose = "VPC_PEERING" | ||
address_type = "INTERNAL" | ||
prefix_length = 16 | ||
network = data.google_compute_network.network.id | ||
} | ||
|
||
resource "google_service_networking_connection" "private_vpc_connection" { | ||
network = data.google_compute_network.network.id | ||
service = "servicenetworking.googleapis.com" | ||
reserved_peering_ranges = [google_compute_global_address.private_ip_address.name] | ||
|
||
depends_on = [google_project_service.servicenetworking] | ||
} | ||
|
||
module "postgres" { | ||
source = "../../humanitec-resource-defs/postgres/basic" | ||
|
||
prefix = var.prefix | ||
resource_packs_gcp_rev = var.resource_packs_gcp_rev | ||
resource_packs_gcp_url = var.resource_packs_gcp_url | ||
project = var.project | ||
region = var.region | ||
credentials = var.credentials | ||
|
||
database_version = "POSTGRES_15" | ||
tier = "db-f1-micro" | ||
private_network = data.google_compute_network.network.id | ||
|
||
depends_on = [google_service_networking_connection.private_vpc_connection] | ||
} | ||
|
||
resource "humanitec_resource_definition_criteria" "postgres" { | ||
resource_definition_id = module.postgres.id | ||
app_id = humanitec_application.example.id | ||
force_delete = true | ||
} |
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,27 @@ | ||
terraform { | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "~> 5.17" | ||
} | ||
humanitec = { | ||
source = "humanitec/humanitec" | ||
version = "~> 0" | ||
} | ||
} | ||
|
||
required_version = ">= 1.3.0" | ||
} | ||
|
||
provider "humanitec" {} | ||
|
||
provider "google" { | ||
project = var.project | ||
region = var.region | ||
credentials = var.credentials | ||
|
||
default_labels = { | ||
"managed_by" = "terraform" | ||
"source" = "github.com/humanitec-architecture/resource-pack-gcp" | ||
} | ||
} |
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,15 @@ | ||
credentials = "" | ||
|
||
# Name of the example application | ||
name = "hum-rp-postgres-example" | ||
|
||
# Prefix of the created resources | ||
prefix = "hum-rp-postgres-ex-" | ||
|
||
# The VPC network from which the Cloud SQL instance is accessible for private IP. | ||
private_network = "" | ||
|
||
project = "" | ||
region = "" | ||
resource_packs_gcp_rev = "ref/heads/main" | ||
resource_packs_gcp_url = "https://github.com/humanitec-architecture/resource-packs-gcp.git" |
Oops, something went wrong.