Skip to content

Commit

Permalink
feat: add memorystore redis
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszjenek committed Jan 8, 2024
1 parent 80fa209 commit 2d065e5
Show file tree
Hide file tree
Showing 20 changed files with 558 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A collection of GCP resources ready to be used with [Humanitec](https://humanite

The following resources are included:

* None
* [redis/basic](./humanitec-resource-defs/redis/basic): GCP Memorystore Redis resource.

The `humanitec-resource-defs` directory includes the respective resource definitions.

Expand Down
46 changes: 46 additions & 0 deletions examples/redis/basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

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

## Providers

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

## Modules

| Name | Source | Version |
|------|--------|---------|
| redis | ../../../humanitec-resource-defs/redis/basic | n/a |

## Resources

| Name | Type |
|------|------|
| [humanitec_application.example](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/application) | resource |
| [humanitec_resource_definition_criteria.redis](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| alternative\_location\_id | n/a | `string` | n/a | yes |
| auth\_enabled | n/a | `bool` | n/a | yes |
| authorized\_network | n/a | `string` | n/a | yes |
| credentials | n/a | `any` | 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 |
| location\_id | n/a | `string` | n/a | yes |
| memory\_size\_gb | n/a | `number` | n/a | yes |
| name | n/a | `string` | n/a | yes |
| project | n/a | `string` | n/a | yes |
| region | n/a | `string` | n/a | yes |
| humanitec\_host | Humanitec API host url | `string` | `"https://api.humanitec.io"` | 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 -->
30 changes: 30 additions & 0 deletions examples/redis/basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
locals {
res_def_prefix = "${var.name}-"
}

resource "humanitec_application" "example" {
id = var.name
name = var.name
}

module "redis" {
source = "../../../humanitec-resource-defs/redis/basic"

prefix = local.res_def_prefix
display_name = var.name
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
memory_size_gb = var.memory_size_gb
location_id = var.location_id
alternative_location_id = var.alternative_location_id
authorized_network = var.authorized_network
auth_enabled = var.auth_enabled
}

resource "humanitec_resource_definition_criteria" "redis" {
resource_definition_id = module.redis.id
app_id = humanitec_application.example.id
}
16 changes: 16 additions & 0 deletions examples/redis/basic/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
terraform {
required_providers {
humanitec = {
source = "humanitec/humanitec"
version = "~> 0"
}
}

required_version = ">= 1.3.0"
}

provider "humanitec" {
host = var.humanitec_host
org_id = var.humanitec_org_id
token = var.humanitec_token
}
21 changes: 21 additions & 0 deletions examples/redis/basic/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
alternative_location_id = ""
auth_enabled = ""
authorized_network = ""
credentials = ""

# 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 = ""

location_id = ""
memory_size_gb = ""
name = ""
project = ""
region = ""
resource_packs_gcp_rev = "ref/heads/main"
resource_packs_gcp_url = "https://github.com/humanitec-architecture/resource-packs-gcp.git"
61 changes: 61 additions & 0 deletions examples/redis/basic/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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 "name" {
type = string
}

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 "project" {
type = string
}

variable "region" {
type = string
}

variable "credentials" {
type = any
}

variable "memory_size_gb" {
type = number
}

variable "location_id" {
type = string
}

variable "alternative_location_id" {
type = string
}

variable "authorized_network" {
type = string
}

variable "auth_enabled" {
type = bool
}
Empty file removed humanitec-resource-defs/.gitkeep
Empty file.
46 changes: 46 additions & 0 deletions humanitec-resource-defs/redis/basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!-- BEGIN_TF_DOCS -->
## 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 |
|------|-------------|------|---------|:--------:|
| alternative\_location\_id | n/a | `string` | n/a | yes |
| authorized\_network | n/a | `string` | n/a | yes |
| credentials | n/a | `any` | n/a | yes |
| display\_name | n/a | `string` | n/a | yes |
| location\_id | n/a | `string` | n/a | yes |
| memory\_size\_gb | n/a | `number` | n/a | yes |
| prefix | n/a | `string` | n/a | yes |
| project | n/a | `string` | n/a | yes |
| region | n/a | `string` | n/a | yes |
| auth\_enabled | n/a | `bool` | `false` | no |
| redis\_version | n/a | `string` | `"REDIS_4_0"` | no |
| reserved\_ip\_range | n/a | `string` | `null` | 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 |
| weekly\_maintenance\_windows | n/a | `any` | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| id | n/a |
<!-- END_TF_DOCS -->
41 changes: 41 additions & 0 deletions humanitec-resource-defs/redis/basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
resource "humanitec_resource_definition" "main" {
driver_type = "humanitec/terraform"
id = "${var.prefix}memorystore-redis"
name = "${var.prefix}memorystore-redis"
type = "redis"

driver_inputs = {
secrets_string = jsonencode({
variables = {
credentials = var.credentials
}

})

values_string = jsonencode({
source = {
path = "modules/redis/basic"
rev = var.resource_packs_gcp_rev
url = var.resource_packs_gcp_url
}

variables = {
name = "${var.prefix}redis"
project = var.project
region = var.region
app_id = "$${context.app.id}"
env_id = "$${context.env.id}"
res_id = "$${context.res.id}"
memory_size_gb = var.memory_size_gb
location_id = var.location_id
alternative_location_id = var.alternative_location_id
authorized_network = var.authorized_network
redis_version = var.redis_version
display_name = var.display_name
reserved_ip_range = var.reserved_ip_range
weekly_maintenance_windows = var.weekly_maintenance_windows
auth_enabled = var.auth_enabled
}
})
}
}
3 changes: 3 additions & 0 deletions humanitec-resource-defs/redis/basic/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "id" {
value = humanitec_resource_definition.main.id
}
10 changes: 10 additions & 0 deletions humanitec-resource-defs/redis/basic/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_providers {
humanitec = {
source = "humanitec/humanitec"
version = "~> 0"
}
}

required_version = ">= 1.3.0"
}
15 changes: 15 additions & 0 deletions humanitec-resource-defs/redis/basic/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
alternative_location_id = ""
auth_enabled = false
authorized_network = ""
credentials = ""
display_name = ""
location_id = ""
memory_size_gb = ""
prefix = ""
project = ""
redis_version = "REDIS_4_0"
region = ""
reserved_ip_range = ""
resource_packs_gcp_rev = "ref/heads/main"
resource_packs_gcp_url = "https://github.com/humanitec-architecture/resource-packs-gcp.git"
weekly_maintenance_windows = {}
65 changes: 65 additions & 0 deletions humanitec-resource-defs/redis/basic/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
variable "prefix" {
type = string
}

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 "project" {
type = string
}

variable "region" {
type = string
}

variable "credentials" {
type = any
}

variable "memory_size_gb" {
type = number
}

variable "location_id" {
type = string
}

variable "alternative_location_id" {
type = string
}

variable "authorized_network" {
type = string
}

variable "display_name" {
type = string
}

variable "redis_version" {
type = string
default = "REDIS_4_0"
}

variable "reserved_ip_range" {
type = string
default = null
}

variable "weekly_maintenance_windows" {
type = any
default = {}
}

variable "auth_enabled" {
type = bool
default = false
}
Empty file removed modules/.gitkeep
Empty file.
Loading

0 comments on commit 2d065e5

Please sign in to comment.