diff --git a/README.md b/README.md index b99d2fb..13dac8f 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,10 @@ The following resources are included: * [iam-policy/sqs](./humanitec-resource-defs/iam-policy/sqs): IAM policy for an SQS queue. * [iam-role/service-account](./humanitec-resource-defs/iam-role/service-account): An assumable IAM role, by a k8s service account. * [k8s/service-account](./humanitec-resource-defs/k8s/service-account): A `k8s-service-account` linked to an IAM role. -* [rds/aurora](./humanitec-resource-defs/rds/aurora): A `postgres` or `mysql` resource using AWS RDS Aurora. -* [rds/basic](./humanitec-resource-defs/rds/basic): A `postgres` or `mysql` resource using AWS RDS. +* [mysql/aurora](./humanitec-resource-defs/rds/aurora): A `mysql` resource using AWS RDS Aurora. +* [mysql/basic](./humanitec-resource-defs/rds/basic): A `mysql` resource using AWS RDS. +* [postgres/aurora](./humanitec-resource-defs/rds/aurora): A `postgres` resource using AWS RDS Aurora. +* [postgres/basic](./humanitec-resource-defs/rds/basic): A `postgres` resource using AWS RDS. * [redis/basic](./humanitec-resource-defs/redis/basic): A `redis` resource using AWS ElastiCache. * [s3/basic](./humanitec-resource-defs/s3/basic): A basic `s3` bucket. * [sqs/basic](./humanitec-resource-defs/sqs/basic): A basic `sqs` queue. diff --git a/examples/mysql/aurora/README.md b/examples/mysql/aurora/README.md index dc19f90..91687c8 100644 --- a/examples/mysql/aurora/README.md +++ b/examples/mysql/aurora/README.md @@ -30,14 +30,14 @@ resources: | Name | Source | Version | |------|--------|---------| -| rds | ../../../humanitec-resource-defs/rds/aurora | n/a | +| mysql | ../../../humanitec-resource-defs/mysql/aurora | n/a | ## Resources | Name | Type | |------|------| | [humanitec_application.app](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/application) | resource | -| [humanitec_resource_definition_criteria.rds](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource | +| [humanitec_resource_definition_criteria.mysql](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource | ## Inputs diff --git a/examples/mysql/aurora/main.tf b/examples/mysql/aurora/main.tf index 30fe722..c5017ea 100644 --- a/examples/mysql/aurora/main.tf +++ b/examples/mysql/aurora/main.tf @@ -3,8 +3,8 @@ resource "humanitec_application" "app" { name = var.name } -module "rds" { - source = "../../../humanitec-resource-defs/rds/aurora" +module "mysql" { + source = "../../../humanitec-resource-defs/mysql/aurora" prefix = "${var.name}-" resource_packs_aws_rev = var.resource_packs_aws_rev @@ -14,12 +14,6 @@ module "rds" { secret_key = var.secret_key region = var.region - type = "mysql" - - engine = "aurora-mysql" - engine_version = "8.0" - group_family = "aurora-mysql8.0" - name = "${var.name}-database" database_name = "my_database" master_username = "username" @@ -36,7 +30,7 @@ module "rds" { } } -resource "humanitec_resource_definition_criteria" "rds" { - resource_definition_id = module.rds.id +resource "humanitec_resource_definition_criteria" "mysql" { + resource_definition_id = module.mysql.id app_id = humanitec_application.app.id } diff --git a/examples/mysql/basic/README.md b/examples/mysql/basic/README.md index 450d9e0..79cd984 100644 --- a/examples/mysql/basic/README.md +++ b/examples/mysql/basic/README.md @@ -31,7 +31,7 @@ resources: | Name | Source | Version | |------|--------|---------| -| rds | ../../../humanitec-resource-defs/rds/basic | n/a | +| mysql | ../../../humanitec-resource-defs/mysql/basic | n/a | ## Resources @@ -40,7 +40,7 @@ resources: | [aws_security_group.mysql](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource | | [aws_vpc_security_group_ingress_rule.k8s_node_mysql](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_security_group_ingress_rule) | resource | | [humanitec_application.app](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/application) | resource | -| [humanitec_resource_definition_criteria.rds](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource | +| [humanitec_resource_definition_criteria.mysql](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource | ## Inputs diff --git a/examples/mysql/basic/main.tf b/examples/mysql/basic/main.tf index 836e4b6..576d42e 100644 --- a/examples/mysql/basic/main.tf +++ b/examples/mysql/basic/main.tf @@ -3,8 +3,8 @@ resource "humanitec_application" "app" { name = var.name } -module "rds" { - source = "../../../humanitec-resource-defs/rds/basic" +module "mysql" { + source = "../../../humanitec-resource-defs/mysql/basic" prefix = "${var.name}-" resource_packs_aws_rev = var.resource_packs_aws_rev @@ -19,12 +19,6 @@ module "rds" { username = "username" password = "password" - type = "mysql" - engine = "mysql" - engine_version = "8.0" - group_family = "mysql8.0" - major_engine_version = "8.0" - create_db_subnet_group = true db_subnet_group_name = "${var.name}-subnet-group" subnet_ids = var.subnet_ids @@ -32,8 +26,8 @@ module "rds" { vpc_security_group_ids = [aws_security_group.mysql.id] } -resource "humanitec_resource_definition_criteria" "rds" { - resource_definition_id = module.rds.id +resource "humanitec_resource_definition_criteria" "mysql" { + resource_definition_id = module.mysql.id app_id = humanitec_application.app.id } @@ -47,7 +41,7 @@ resource "aws_vpc_security_group_ingress_rule" "k8s_node_mysql" { security_group_id = aws_security_group.mysql.id referenced_security_group_id = var.k8s_node_security_group_id - from_port = 5432 + from_port = 3306 ip_protocol = "tcp" - to_port = 5432 + to_port = 3306 } diff --git a/examples/postgres/aurora/README.md b/examples/postgres/aurora/README.md index b487bb7..65e8929 100644 --- a/examples/postgres/aurora/README.md +++ b/examples/postgres/aurora/README.md @@ -30,14 +30,14 @@ resources: | Name | Source | Version | |------|--------|---------| -| rds | ../../../humanitec-resource-defs/rds/aurora | n/a | +| postgres | ../../../humanitec-resource-defs/postgres/aurora | n/a | ## Resources | Name | Type | |------|------| | [humanitec_application.app](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/application) | resource | -| [humanitec_resource_definition_criteria.rds](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource | +| [humanitec_resource_definition_criteria.postgres](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource | ## Inputs diff --git a/examples/postgres/aurora/main.tf b/examples/postgres/aurora/main.tf index ea8fc1b..8a1e972 100644 --- a/examples/postgres/aurora/main.tf +++ b/examples/postgres/aurora/main.tf @@ -3,8 +3,8 @@ resource "humanitec_application" "app" { name = var.name } -module "rds" { - source = "../../../humanitec-resource-defs/rds/aurora" +module "postgres" { + source = "../../../humanitec-resource-defs/postgres/aurora" prefix = "${var.name}-" resource_packs_aws_rev = var.resource_packs_aws_rev @@ -30,7 +30,7 @@ module "rds" { } } -resource "humanitec_resource_definition_criteria" "rds" { - resource_definition_id = module.rds.id +resource "humanitec_resource_definition_criteria" "postgres" { + resource_definition_id = module.postgres.id app_id = humanitec_application.app.id } diff --git a/examples/postgres/basic/README.md b/examples/postgres/basic/README.md index 1bab5b1..d2a19ad 100644 --- a/examples/postgres/basic/README.md +++ b/examples/postgres/basic/README.md @@ -31,7 +31,7 @@ resources: | Name | Source | Version | |------|--------|---------| -| rds | ../../../humanitec-resource-defs/rds/basic | n/a | +| postgres | ../../../humanitec-resource-defs/postgres/basic | n/a | ## Resources @@ -40,7 +40,7 @@ resources: | [aws_security_group.postgres](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource | | [aws_vpc_security_group_ingress_rule.k8s_node_postgres](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_security_group_ingress_rule) | resource | | [humanitec_application.app](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/application) | resource | -| [humanitec_resource_definition_criteria.rds](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource | +| [humanitec_resource_definition_criteria.postgres](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource | ## Inputs diff --git a/examples/postgres/basic/main.tf b/examples/postgres/basic/main.tf index 15de372..f0a9f2a 100644 --- a/examples/postgres/basic/main.tf +++ b/examples/postgres/basic/main.tf @@ -3,8 +3,8 @@ resource "humanitec_application" "app" { name = var.name } -module "rds" { - source = "../../../humanitec-resource-defs/rds/basic" +module "postgres" { + source = "../../../humanitec-resource-defs/postgres/basic" prefix = "${var.name}-" resource_packs_aws_rev = var.resource_packs_aws_rev @@ -26,8 +26,8 @@ module "rds" { vpc_security_group_ids = [aws_security_group.postgres.id] } -resource "humanitec_resource_definition_criteria" "rds" { - resource_definition_id = module.rds.id +resource "humanitec_resource_definition_criteria" "postgres" { + resource_definition_id = module.postgres.id app_id = humanitec_application.app.id } @@ -45,4 +45,3 @@ resource "aws_vpc_security_group_ingress_rule" "k8s_node_postgres" { ip_protocol = "tcp" to_port = 5432 } - diff --git a/humanitec-resource-defs/mysql/aurora/README.md b/humanitec-resource-defs/mysql/aurora/README.md new file mode 100644 index 0000000..f118ac2 --- /dev/null +++ b/humanitec-resource-defs/mysql/aurora/README.md @@ -0,0 +1,63 @@ + +## Requirements + +| Name | Version | +|------|---------| +| terraform | >= 1.3.0 | +| humanitec | ~> 0 | + +## Providers + +| Name | Version | +|------|---------| +| humanitec | ~> 0 | + +## Resources + +| Name | Type | +|------|------| +| [humanitec_resource_definition.main](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| access\_key | n/a | `string` | n/a | yes | +| database\_name | n/a | `string` | n/a | yes | +| db\_subnet\_group\_name | n/a | `string` | n/a | yes | +| master\_password | n/a | `string` | n/a | yes | +| master\_username | n/a | `string` | n/a | yes | +| name | n/a | `string` | n/a | yes | +| prefix | n/a | `string` | n/a | yes | +| region | n/a | `string` | n/a | yes | +| resource\_packs\_aws\_rev | AWS Resource Pack git branch | `string` | n/a | yes | +| secret\_key | n/a | `string` | n/a | yes | +| subnets | n/a | `set(string)` | n/a | yes | +| vpc | n/a | `string` | n/a | yes | +| apply\_immediately | n/a | `bool` | `true` | no | +| create\_cloudwatch\_log\_group | n/a | `bool` | `false` | no | +| create\_db\_cluster\_activity\_stream | n/a | `bool` | `false` | no | +| create\_db\_subnet\_group | n/a | `bool` | `true` | no | +| db\_cluster\_activity\_stream\_kms\_key\_id | n/a | `string` | `null` | no | +| db\_cluster\_activity\_stream\_mode | n/a | `string` | `"async"` | no | +| db\_cluster\_parameter\_group\_parameters | n/a | `set(any)` | `[]` | no | +| db\_parameter\_group\_parameters | n/a | `set(any)` | `[]` | no | +| enabled\_cloudwatch\_logs\_exports | n/a | `set(string)` | `[]` | no | +| endpoints | n/a | `any` | `{}` | no | +| engine | n/a | `string` | `"aurora-mysql"` | no | +| engine\_version | n/a | `string` | `"8.0"` | no | +| group\_family | n/a | `string` | `"aurora-mysql8.0"` | no | +| instances | n/a | `map(any)` |
{| no | +| resource\_packs\_aws\_url | AWS Resource Pack git url | `string` | `"https://github.com/humanitec-architecture/resource-packs-aws.git"` | no | +| security\_group\_rules | n/a | `any` | `{}` | no | +| skip\_final\_snapshot | n/a | `bool` | `true` | no | +| storage\_encrypted | n/a | `bool` | `true` | no | +| storage\_type | n/a | `string` | `"aurora"` | no | +| type | n/a | `string` | `"mysql"` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| id | n/a | + \ No newline at end of file diff --git a/humanitec-resource-defs/rds/aurora/main.tf b/humanitec-resource-defs/mysql/aurora/main.tf similarity index 100% rename from humanitec-resource-defs/rds/aurora/main.tf rename to humanitec-resource-defs/mysql/aurora/main.tf diff --git a/humanitec-resource-defs/rds/aurora/outputs.tf b/humanitec-resource-defs/mysql/aurora/outputs.tf similarity index 100% rename from humanitec-resource-defs/rds/aurora/outputs.tf rename to humanitec-resource-defs/mysql/aurora/outputs.tf diff --git a/humanitec-resource-defs/rds/aurora/providers.tf b/humanitec-resource-defs/mysql/aurora/providers.tf similarity index 100% rename from humanitec-resource-defs/rds/aurora/providers.tf rename to humanitec-resource-defs/mysql/aurora/providers.tf diff --git a/humanitec-resource-defs/mysql/aurora/terraform.tfvars.example b/humanitec-resource-defs/mysql/aurora/terraform.tfvars.example new file mode 100644 index 0000000..c1ff154 --- /dev/null +++ b/humanitec-resource-defs/mysql/aurora/terraform.tfvars.example @@ -0,0 +1,47 @@ +access_key = "" +apply_immediately = true +create_cloudwatch_log_group = false +create_db_cluster_activity_stream = false +create_db_subnet_group = true +database_name = "" +db_cluster_activity_stream_kms_key_id = "" +db_cluster_activity_stream_mode = "async" +db_cluster_parameter_group_parameters = [] +db_parameter_group_parameters = [] +db_subnet_group_name = "" +enabled_cloudwatch_logs_exports = [] +endpoints = {} +engine = "aurora-mysql" +engine_version = "8.0" +group_family = "aurora-mysql8.0" +instances = { + "1": { + "db_parameter_group_name": "default.aurora-mysql8.0", + "instance_class": "db.r5.2xlarge", + "publicly_accessible": true + }, + "2": { + "identifier": "static-member-1", + "instance_class": "db.r5.2xlarge" + } +} +master_password = "" +master_username = "" +name = "" +prefix = "" +region = "" + +# AWS Resource Pack git branch +resource_packs_aws_rev = "" + +# AWS Resource Pack git url +resource_packs_aws_url = "https://github.com/humanitec-architecture/resource-packs-aws.git" + +secret_key = "" +security_group_rules = {} +skip_final_snapshot = true +storage_encrypted = true +storage_type = "aurora" +subnets = "" +type = "mysql" +vpc = "" \ No newline at end of file diff --git a/humanitec-resource-defs/mysql/aurora/variables.tf b/humanitec-resource-defs/mysql/aurora/variables.tf new file mode 100644 index 0000000..54c384c --- /dev/null +++ b/humanitec-resource-defs/mysql/aurora/variables.tf @@ -0,0 +1,159 @@ +variable "prefix" { + type = string +} + +variable "resource_packs_aws_url" { + description = "AWS Resource Pack git url" + type = string + default = "https://github.com/humanitec-architecture/resource-packs-aws.git" +} + +variable "resource_packs_aws_rev" { + description = "AWS Resource Pack git branch" + type = string +} + +variable "access_key" { + type = string +} + +variable "secret_key" { + type = string +} + +variable "region" { + type = string +} + +variable "name" { + type = string +} + +variable "database_name" { + type = string +} + +variable "master_username" { + type = string +} + +variable "master_password" { + type = string +} + +variable "vpc" { + type = string +} + +variable "subnets" { + type = set(string) +} + +variable "db_subnet_group_name" { + type = string +} + +variable "create_db_subnet_group" { + type = bool + default = true +} + +variable "type" { + type = string + default = "mysql" +} + +variable "engine" { + type = string + default = "aurora-mysql" +} + +variable "engine_version" { + type = string + default = "8.0" +} + +variable "group_family" { + type = string + default = "aurora-mysql8.0" +} + +variable "storage_type" { + type = string + default = "aurora" +} + +variable "storage_encrypted" { + type = bool + default = true +} + +variable "instances" { + type = map(any) + default = { + 1 = { + instance_class = "db.r5.2xlarge" + publicly_accessible = true + db_parameter_group_name = "default.aurora-mysql8.0" + } + 2 = { + identifier = "static-member-1" + instance_class = "db.r5.2xlarge" + } + } +} + +variable "endpoints" { + type = any + default = {} +} + +variable "security_group_rules" { + type = any + default = {} +} + +variable "apply_immediately" { + type = bool + default = true +} + +variable "skip_final_snapshot" { + type = bool + default = true +} + +variable "db_cluster_parameter_group_parameters" { + type = set(any) + default = [] +} + +variable "db_parameter_group_parameters" { + type = set(any) + default = [] +} + +variable "create_cloudwatch_log_group" { + type = bool + default = false +} + +variable "enabled_cloudwatch_logs_exports" { + type = set(string) + default = [] +} + +variable "create_db_cluster_activity_stream" { + type = bool + default = false +} + +variable "db_cluster_activity_stream_kms_key_id" { + type = string + default = null +} + +variable "db_cluster_activity_stream_mode" { + type = string + default = "async" +} diff --git a/humanitec-resource-defs/mysql/basic/README.md b/humanitec-resource-defs/mysql/basic/README.md new file mode 100644 index 0000000..d293195 --- /dev/null +++ b/humanitec-resource-defs/mysql/basic/README.md @@ -0,0 +1,70 @@ + +## Requirements + +| Name | Version | +|------|---------| +| terraform | >= 1.3.0 | +| humanitec | ~> 0 | + +## Providers + +| Name | Version | +|------|---------| +| humanitec | ~> 0 | + +## Resources + +| Name | Type | +|------|------| +| [humanitec_resource_definition.main](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| access\_key | n/a | `string` | n/a | yes | +| database\_name | n/a | `string` | n/a | yes | +| db\_subnet\_group\_name | n/a | `string` | n/a | yes | +| name | n/a | `string` | n/a | yes | +| password | n/a | `string` | n/a | yes | +| prefix | n/a | `string` | n/a | yes | +| region | n/a | `string` | n/a | yes | +| resource\_packs\_aws\_rev | AWS Resource Pack git branch | `string` | n/a | yes | +| secret\_key | n/a | `string` | n/a | yes | +| subnet\_ids | n/a | `set(string)` | n/a | yes | +| username | n/a | `string` | n/a | yes | +| vpc\_security\_group\_ids | n/a | `set(string)` | n/a | yes | +| allocated\_storage | n/a | `number` | `20` | no | +| backup\_retention\_period | n/a | `number` | `1` | no | +| backup\_window | n/a | `string` | `null` | no | +| create\_cloudwatch\_log\_group | n/a | `bool` | `false` | no | +| create\_db\_subnet\_group | n/a | `bool` | `true` | no | +| create\_monitoring\_role | n/a | `bool` | `true` | no | +| deletion\_protection | n/a | `bool` | `false` | no | +| enabled\_cloudwatch\_logs\_exports | n/a | `set(string)` | `[]` | no | +| engine | n/a | `string` | `"mysql"` | no | +| engine\_version | n/a | `string` | `"8.0"` | no | +| group\_family | n/a | `string` | `"mysql8.0"` | no | +| instance\_class | n/a | `string` | `"db.t4g.large"` | no | +| maintenance\_window | n/a | `string` | `null` | no | +| major\_engine\_version | n/a | `string` | `"8.0"` | no | +| max\_allocated\_storage | n/a | `number` | `100` | no | +| monitoring\_interval | n/a | `number` | `60` | no | +| monitoring\_role\_description | n/a | `string` | `"Monitoring role for RDS basic cluster"` | no | +| monitoring\_role\_name | n/a | `string` | `"rds-basic-monitoring-role"` | no | +| monitoring\_role\_use\_name\_prefix | n/a | `bool` | `true` | no | +| multi\_az | n/a | `bool` | `true` | no | +| parameters | n/a | `set(any)` | `[]` | no | +| performance\_insights\_enabled | n/a | `bool` | `true` | no | +| performance\_insights\_retention\_period | n/a | `number` | `7` | no | +| port | n/a | `number` | `3306` | no | +| resource\_packs\_aws\_url | AWS Resource Pack git url | `string` | `"https://github.com/humanitec-architecture/resource-packs-aws.git"` | no | +| skip\_final\_snapshot | n/a | `bool` | `true` | no | +| type | n/a | `string` | `"mysql"` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| id | n/a | + \ No newline at end of file diff --git a/humanitec-resource-defs/rds/basic/main.tf b/humanitec-resource-defs/mysql/basic/main.tf similarity index 100% rename from humanitec-resource-defs/rds/basic/main.tf rename to humanitec-resource-defs/mysql/basic/main.tf diff --git a/humanitec-resource-defs/rds/basic/outputs.tf b/humanitec-resource-defs/mysql/basic/outputs.tf similarity index 100% rename from humanitec-resource-defs/rds/basic/outputs.tf rename to humanitec-resource-defs/mysql/basic/outputs.tf diff --git a/humanitec-resource-defs/rds/basic/providers.tf b/humanitec-resource-defs/mysql/basic/providers.tf similarity index 100% rename from humanitec-resource-defs/rds/basic/providers.tf rename to humanitec-resource-defs/mysql/basic/providers.tf diff --git a/humanitec-resource-defs/mysql/basic/terraform.tfvars.example b/humanitec-resource-defs/mysql/basic/terraform.tfvars.example new file mode 100644 index 0000000..39f8ffb --- /dev/null +++ b/humanitec-resource-defs/mysql/basic/terraform.tfvars.example @@ -0,0 +1,44 @@ +access_key = "" +allocated_storage = 20 +backup_retention_period = 1 +backup_window = "" +create_cloudwatch_log_group = false +create_db_subnet_group = true +create_monitoring_role = true +database_name = "" +db_subnet_group_name = "" +deletion_protection = false +enabled_cloudwatch_logs_exports = [] +engine = "mysql" +engine_version = "8.0" +group_family = "mysql8.0" +instance_class = "db.t4g.large" +maintenance_window = "" +major_engine_version = "8.0" +max_allocated_storage = 100 +monitoring_interval = 60 +monitoring_role_description = "Monitoring role for RDS basic cluster" +monitoring_role_name = "rds-basic-monitoring-role" +monitoring_role_use_name_prefix = true +multi_az = true +name = "" +parameters = [] +password = "" +performance_insights_enabled = true +performance_insights_retention_period = 7 +port = 3306 +prefix = "" +region = "" + +# AWS Resource Pack git branch +resource_packs_aws_rev = "" + +# AWS Resource Pack git url +resource_packs_aws_url = "https://github.com/humanitec-architecture/resource-packs-aws.git" + +secret_key = "" +skip_final_snapshot = true +subnet_ids = "" +type = "mysql" +username = "" +vpc_security_group_ids = "" \ No newline at end of file diff --git a/humanitec-resource-defs/mysql/basic/variables.tf b/humanitec-resource-defs/mysql/basic/variables.tf new file mode 100644 index 0000000..b22d409 --- /dev/null +++ b/humanitec-resource-defs/mysql/basic/variables.tf @@ -0,0 +1,186 @@ +variable "prefix" { + type = string +} + +variable "resource_packs_aws_url" { + description = "AWS Resource Pack git url" + type = string + default = "https://github.com/humanitec-architecture/resource-packs-aws.git" +} + +variable "resource_packs_aws_rev" { + description = "AWS Resource Pack git branch" + type = string +} + +variable "region" { + type = string +} + +variable "access_key" { + type = string +} + +variable "secret_key" { + type = string +} + +variable "name" { + type = string +} + +variable "database_name" { + type = string +} + +variable "username" { + type = string + sensitive = true +} + +variable "password" { + type = string + sensitive = true +} + +variable "create_db_subnet_group" { + type = bool + default = true +} + +variable "db_subnet_group_name" { + type = string +} + +variable "subnet_ids" { + type = set(string) +} + +variable "vpc_security_group_ids" { + type = set(string) +} + +variable "port" { + type = number + default = 3306 +} + +variable "type" { + type = string + default = "mysql" +} + +variable "engine" { + type = string + default = "mysql" +} + +variable "engine_version" { + type = string + default = "8.0" +} + +variable "major_engine_version" { + type = string + default = "8.0" +} + +variable "group_family" { + type = string + default = "mysql8.0" +} + +variable "instance_class" { + type = string + default = "db.t4g.large" +} + +variable "allocated_storage" { + type = number + default = 20 +} + +variable "max_allocated_storage" { + type = number + default = 100 +} + +variable "multi_az" { + type = bool + default = true +} + +variable "maintenance_window" { + type = string + default = null # "Mon:00:00-Mon:03:00" +} + +variable "backup_window" { + type = string + default = null # "03:00-06:00" +} + +variable "backup_retention_period" { + type = number + default = 1 +} + +variable "create_cloudwatch_log_group" { + type = bool + default = false +} + +variable "enabled_cloudwatch_logs_exports" { + type = set(string) + default = [] +} + +variable "skip_final_snapshot" { + type = bool + default = true +} + +variable "deletion_protection" { + type = bool + default = false +} + +variable "performance_insights_enabled" { + type = bool + default = true +} + +variable "performance_insights_retention_period" { + type = number + default = 7 +} + +variable "create_monitoring_role" { + type = bool + default = true +} + +variable "monitoring_interval" { + type = number + default = 60 +} + +variable "monitoring_role_name" { + type = string + default = "rds-basic-monitoring-role" +} + +variable "monitoring_role_use_name_prefix" { + type = bool + default = true +} + +variable "monitoring_role_description" { + type = string + default = "Monitoring role for RDS basic cluster" +} + +variable "parameters" { + type = set(any) + default = [] +} diff --git a/humanitec-resource-defs/rds/aurora/README.md b/humanitec-resource-defs/postgres/aurora/README.md similarity index 100% rename from humanitec-resource-defs/rds/aurora/README.md rename to humanitec-resource-defs/postgres/aurora/README.md diff --git a/humanitec-resource-defs/postgres/aurora/main.tf b/humanitec-resource-defs/postgres/aurora/main.tf new file mode 100644 index 0000000..37efbb2 --- /dev/null +++ b/humanitec-resource-defs/postgres/aurora/main.tf @@ -0,0 +1,56 @@ +resource "humanitec_resource_definition" "main" { + driver_type = "humanitec/terraform" + id = "${var.prefix}rds-aurora" + name = "${var.prefix}rds-aurora" + type = var.type + + driver_inputs = { + secrets_string = jsonencode({ + variables = { + access_key = var.access_key + secret_key = var.secret_key + } + }) + + values_string = jsonencode({ + source = { + path = "modules/rds/aurora" + rev = var.resource_packs_aws_rev + url = var.resource_packs_aws_url + } + + variables = { + region = var.region + res_id = "$${context.res.id}" + app_id = "$${context.app.id}" + env_id = "$${context.env.id}" + + name = var.name + database_name = var.database_name + master_username = var.master_username + master_password = var.master_password + vpc = var.vpc + subnets = var.subnets + db_subnet_group_name = var.db_subnet_group_name + create_db_subnet_group = var.create_db_subnet_group + engine = var.engine + engine_version = var.engine_version + group_family = var.group_family + storage_type = var.storage_type + storage_encrypted = var.storage_encrypted + instances = var.instances + endpoints = var.endpoints + security_group_rules = var.security_group_rules + apply_immediately = var.apply_immediately + skip_final_snapshot = var.skip_final_snapshot + db_cluster_parameter_group_parameters = var.db_cluster_parameter_group_parameters + db_parameter_group_parameters = var.db_parameter_group_parameters + enabled_cloudwatch_logs_exports = var.enabled_cloudwatch_logs_exports + create_cloudwatch_log_group = var.create_cloudwatch_log_group + create_db_cluster_activity_stream = var.create_db_cluster_activity_stream + db_cluster_activity_stream_kms_key_id = var.db_cluster_activity_stream_kms_key_id + db_cluster_activity_stream_mode = var.db_cluster_activity_stream_mode + } + }) + } +} diff --git a/humanitec-resource-defs/postgres/aurora/outputs.tf b/humanitec-resource-defs/postgres/aurora/outputs.tf new file mode 100644 index 0000000..28542ec --- /dev/null +++ b/humanitec-resource-defs/postgres/aurora/outputs.tf @@ -0,0 +1,3 @@ +output "id" { + value = humanitec_resource_definition.main.id +} diff --git a/humanitec-resource-defs/postgres/aurora/providers.tf b/humanitec-resource-defs/postgres/aurora/providers.tf new file mode 100644 index 0000000..f452f5e --- /dev/null +++ b/humanitec-resource-defs/postgres/aurora/providers.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + humanitec = { + source = "humanitec/humanitec" + version = "~> 0" + } + } + required_version = ">= 1.3.0" +} diff --git a/humanitec-resource-defs/rds/aurora/terraform.tfvars.example b/humanitec-resource-defs/postgres/aurora/terraform.tfvars.example similarity index 100% rename from humanitec-resource-defs/rds/aurora/terraform.tfvars.example rename to humanitec-resource-defs/postgres/aurora/terraform.tfvars.example diff --git a/humanitec-resource-defs/rds/aurora/variables.tf b/humanitec-resource-defs/postgres/aurora/variables.tf similarity index 100% rename from humanitec-resource-defs/rds/aurora/variables.tf rename to humanitec-resource-defs/postgres/aurora/variables.tf diff --git a/humanitec-resource-defs/rds/basic/README.md b/humanitec-resource-defs/postgres/basic/README.md similarity index 100% rename from humanitec-resource-defs/rds/basic/README.md rename to humanitec-resource-defs/postgres/basic/README.md diff --git a/humanitec-resource-defs/postgres/basic/main.tf b/humanitec-resource-defs/postgres/basic/main.tf new file mode 100644 index 0000000..ffeb6de --- /dev/null +++ b/humanitec-resource-defs/postgres/basic/main.tf @@ -0,0 +1,61 @@ +resource "humanitec_resource_definition" "main" { + driver_type = "humanitec/terraform" + id = "${var.prefix}rds" + name = "${var.prefix}rds" + type = var.type + + driver_inputs = { + secrets_string = jsonencode({ + variables = { + access_key = var.access_key + secret_key = var.secret_key + } + }) + + values_string = jsonencode({ + source = { + path = "modules/rds/basic" + rev = var.resource_packs_aws_rev + url = var.resource_packs_aws_url + } + variables = { + region = var.region + res_id = "$${context.res.id}" + app_id = "$${context.app.id}" + env_id = "$${context.env.id}" + name = var.name + database_name = var.database_name + username = var.username + password = var.password + create_db_subnet_group = var.create_db_subnet_group + db_subnet_group_name = var.db_subnet_group_name + subnet_ids = var.subnet_ids + vpc_security_group_ids = var.vpc_security_group_ids + port = var.port + engine = var.engine + engine_version = var.engine_version + major_engine_version = var.major_engine_version + group_family = var.group_family + instance_class = var.instance_class + allocated_storage = var.allocated_storage + max_allocated_storage = var.max_allocated_storage + multi_az = var.multi_az + maintenance_window = var.maintenance_window + backup_window = var.backup_window + backup_retention_period = var.backup_retention_period + create_cloudwatch_log_group = var.create_cloudwatch_log_group + enabled_cloudwatch_logs_exports = var.enabled_cloudwatch_logs_exports + skip_final_snapshot = var.skip_final_snapshot + deletion_protection = var.deletion_protection + performance_insights_enabled = var.performance_insights_enabled + performance_insights_retention_period = var.performance_insights_retention_period + create_monitoring_role = var.create_monitoring_role + monitoring_interval = var.monitoring_interval + monitoring_role_name = var.monitoring_role_name + monitoring_role_use_name_prefix = var.monitoring_role_use_name_prefix + monitoring_role_description = var.monitoring_role_description + parameters = var.parameters + } + }) + } +} diff --git a/humanitec-resource-defs/postgres/basic/outputs.tf b/humanitec-resource-defs/postgres/basic/outputs.tf new file mode 100644 index 0000000..28542ec --- /dev/null +++ b/humanitec-resource-defs/postgres/basic/outputs.tf @@ -0,0 +1,3 @@ +output "id" { + value = humanitec_resource_definition.main.id +} diff --git a/humanitec-resource-defs/postgres/basic/providers.tf b/humanitec-resource-defs/postgres/basic/providers.tf new file mode 100644 index 0000000..f452f5e --- /dev/null +++ b/humanitec-resource-defs/postgres/basic/providers.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + humanitec = { + source = "humanitec/humanitec" + version = "~> 0" + } + } + required_version = ">= 1.3.0" +} diff --git a/humanitec-resource-defs/rds/basic/terraform.tfvars.example b/humanitec-resource-defs/postgres/basic/terraform.tfvars.example similarity index 100% rename from humanitec-resource-defs/rds/basic/terraform.tfvars.example rename to humanitec-resource-defs/postgres/basic/terraform.tfvars.example diff --git a/humanitec-resource-defs/rds/basic/variables.tf b/humanitec-resource-defs/postgres/basic/variables.tf similarity index 100% rename from humanitec-resource-defs/rds/basic/variables.tf rename to humanitec-resource-defs/postgres/basic/variables.tf
"1": {
"db_parameter_group_name": "default.aurora-mysql8.0",
"instance_class": "db.r5.2xlarge",
"publicly_accessible": true
},
"2": {
"identifier": "static-member-1",
"instance_class": "db.r5.2xlarge"
}
}