Skip to content

Commit

Permalink
feat: add rds aurora resource
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszjenek committed Jan 8, 2024
1 parent c52309d commit 6a78c43
Show file tree
Hide file tree
Showing 23 changed files with 1,112 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.terraform.lock.hcl
terraform.tfstate*
terraform.tfvars
.DS_Store
45 changes: 45 additions & 0 deletions examples/rds/aurora-mysql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| aws | ~> 5.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| humanitec | ~> 0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| rds | ../../../humanitec-resource-defs/rds/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 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| access\_key | AWS Access Key | `string` | n/a | yes |
| humanitec\_org\_id | Humanitec organization where resource definitions will be applied | `string` | n/a | yes |
| humanitec\_token | Humanitec API token | `string` | n/a | yes |
| k8s\_node\_security\_group\_id | AWS Security Group ID of the kubernetes nodes to allow access to the AWS RDS cluster | `string` | n/a | yes |
| name | Name that will be used in resouces' names | `string` | n/a | yes |
| region | AWS Region to create resources | `string` | n/a | yes |
| secret\_key | AWS Secret Key | `string` | n/a | yes |
| subnet\_ids | AWS Subnet IDs to use for the AWS RDS cluster | `set(string)` | n/a | yes |
| vpc\_id | AWS VPC ID | `string` | n/a | yes |
| humanitec\_host | Humanitec API host url | `string` | `"https://api.humanitec.io"` | no |
| resource\_packs\_aws\_rev | AWS Resource Pack git branch | `string` | `"refs/heads/main"` | no |
| resource\_packs\_aws\_url | AWS Resource Pack git url | `string` | `"https://github.com/humanitec-architecture/resource-packs-aws.git"` | no |
<!-- END_TF_DOCS -->
42 changes: 42 additions & 0 deletions examples/rds/aurora-mysql/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
resource "humanitec_application" "app" {
id = var.name
name = var.name
}

module "rds" {
source = "../../../humanitec-resource-defs/rds/aurora"

prefix = "${var.name}-"
resource_packs_aws_rev = var.resource_packs_aws_rev
resource_packs_aws_url = var.resource_packs_aws_url

access_key = var.access_key
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"
master_password = "password"

vpc = var.vpc_id
subnets = var.subnet_ids
db_subnet_group_name = "${var.name}-subnet-group"
create_db_subnet_group = true
security_group_rules = {
ingress = {
source_security_group_id = var.k8s_node_security_group_id
}
}
}

resource "humanitec_resource_definition_criteria" "rds" {
resource_definition_id = module.rds.id
app_id = humanitec_application.app.id
}
26 changes: 26 additions & 0 deletions examples/rds/aurora-mysql/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
humanitec = {
source = "humanitec/humanitec"
version = "~> 0"
}
}

required_version = ">= 1.3.0"
}

provider "aws" {
region = var.region
access_key = var.access_key
secret_key = var.secret_key
}

provider "humanitec" {
host = var.humanitec_host
org_id = var.humanitec_org_id
token = var.humanitec_token
}
36 changes: 36 additions & 0 deletions examples/rds/aurora-mysql/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

# AWS Access Key
access_key = ""

# Humanitec API host url
humanitec_host = "https://api.humanitec.io"

# Humanitec organization where resource definitions will be applied
humanitec_org_id = ""

# Humanitec API token
humanitec_token = ""

# AWS Security Group ID of the kubernetes nodes to allow access to the AWS RDS cluster
k8s_node_security_group_id = ""

# Name that will be used in resouces' names
name = ""

# AWS Region to create resources
region = ""

# AWS Resource Pack git branch
resource_packs_aws_rev = "refs/heads/main"

# AWS Resource Pack git url
resource_packs_aws_url = "https://github.com/humanitec-architecture/resource-packs-aws.git"

# AWS Secret Key
secret_key = ""

# AWS Subnet IDs to use for the AWS RDS cluster
subnet_ids = ""

# AWS VPC ID
vpc_id = ""
62 changes: 62 additions & 0 deletions examples/rds/aurora-mysql/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
variable "name" {
type = string
description = "Name that will be used in resouces' names"
}

variable "access_key" {
type = string
description = "AWS Access Key"
}

variable "secret_key" {
type = string
description = "AWS Secret Key"
}

variable "region" {
type = string
description = "AWS Region to create resources"
}

variable "humanitec_org_id" {
type = string
description = "Humanitec organization where resource definitions will be applied"
}

variable "humanitec_token" {
type = string
description = "Humanitec API token"
}

variable "humanitec_host" {
type = string
default = "https://api.humanitec.io"
description = "Humanitec API host url"
}

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
default = "refs/heads/main"
}

variable "vpc_id" {
description = "AWS VPC ID"
type = string
}

variable "subnet_ids" {
description = "AWS Subnet IDs to use for the AWS RDS cluster"
type = set(string)
}

variable "k8s_node_security_group_id" {
description = "AWS Security Group ID of the kubernetes nodes to allow access to the AWS RDS cluster"
type = string
}
45 changes: 45 additions & 0 deletions examples/rds/aurora-postgres/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| aws | ~> 5.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| humanitec | ~> 0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| rds | ../../../humanitec-resource-defs/rds/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 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| access\_key | AWS Access Key | `string` | n/a | yes |
| humanitec\_org\_id | Humanitec organization where resource definitions will be applied | `string` | n/a | yes |
| humanitec\_token | Humanitec API token | `string` | n/a | yes |
| k8s\_node\_security\_group\_id | AWS Security Group ID of the kubernetes nodes to allow access to the AWS RDS cluster | `string` | n/a | yes |
| name | Name that will be used in resouces' names | `string` | n/a | yes |
| region | AWS Region to create resources | `string` | n/a | yes |
| secret\_key | AWS Secret Key | `string` | n/a | yes |
| subnet\_ids | AWS Subnet IDs to use for the AWS RDS cluster | `set(string)` | n/a | yes |
| vpc\_id | AWS VPC ID | `string` | n/a | yes |
| humanitec\_host | Humanitec API host url | `string` | `"https://api.humanitec.io"` | no |
| resource\_packs\_aws\_rev | AWS Resource Pack git branch | `string` | `"refs/heads/main"` | no |
| resource\_packs\_aws\_url | AWS Resource Pack git url | `string` | `"https://github.com/humanitec-architecture/resource-packs-aws.git"` | no |
<!-- END_TF_DOCS -->
36 changes: 36 additions & 0 deletions examples/rds/aurora-postgres/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
resource "humanitec_application" "app" {
id = var.name
name = var.name
}

module "rds" {
source = "../../../humanitec-resource-defs/rds/aurora"

prefix = "${var.name}-"
resource_packs_aws_rev = var.resource_packs_aws_rev
resource_packs_aws_url = var.resource_packs_aws_url

access_key = var.access_key
secret_key = var.secret_key
region = var.region

name = "${var.name}-database"
database_name = "my_database"
master_username = "username"
master_password = "password"

vpc = var.vpc_id
subnets = var.subnet_ids
db_subnet_group_name = "${var.name}-subnet-group"
create_db_subnet_group = true
security_group_rules = {
ingress = {
source_security_group_id = var.k8s_node_security_group_id
}
}
}

resource "humanitec_resource_definition_criteria" "rds" {
resource_definition_id = module.rds.id
app_id = humanitec_application.app.id
}
26 changes: 26 additions & 0 deletions examples/rds/aurora-postgres/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
humanitec = {
source = "humanitec/humanitec"
version = "~> 0"
}
}

required_version = ">= 1.3.0"
}

provider "aws" {
region = var.region
access_key = var.access_key
secret_key = var.secret_key
}

provider "humanitec" {
host = var.humanitec_host
org_id = var.humanitec_org_id
token = var.humanitec_token
}
36 changes: 36 additions & 0 deletions examples/rds/aurora-postgres/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

# AWS Access Key
access_key = ""

# Humanitec API host url
humanitec_host = "https://api.humanitec.io"

# Humanitec organization where resource definitions will be applied
humanitec_org_id = ""

# Humanitec API token
humanitec_token = ""

# AWS Security Group ID of the kubernetes nodes to allow access to the AWS RDS cluster
k8s_node_security_group_id = ""

# Name that will be used in resouces' names
name = ""

# AWS Region to create resources
region = ""

# AWS Resource Pack git branch
resource_packs_aws_rev = "refs/heads/main"

# AWS Resource Pack git url
resource_packs_aws_url = "https://github.com/humanitec-architecture/resource-packs-aws.git"

# AWS Secret Key
secret_key = ""

# AWS Subnet IDs to use for the AWS RDS cluster
subnet_ids = ""

# AWS VPC ID
vpc_id = ""
Loading

0 comments on commit 6a78c43

Please sign in to comment.