Skip to content

Commit

Permalink
feat(ovh): add missing modules
Browse files Browse the repository at this point in the history
Signed-off-by: Frederic Leger <[email protected]>
  • Loading branch information
fredleger committed Dec 5, 2024
1 parent 2cc839f commit f13f1da
Show file tree
Hide file tree
Showing 71 changed files with 1,433 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ovh/bucket/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.terraform
.terraform.lock.hcl
terraform.tfvars
terraform.tfstate
terraform.tfstate.*
Empty file added ovh/bucket/.tflint.hcl
Empty file.
50 changes: 50 additions & 0 deletions ovh/bucket/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# OVH S3 bucket

Create a S3 compatible object storage bucket and policy for a user with write access.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.3 |
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | ~> 1.49.0 |
| <a name="requirement_ovh"></a> [ovh](#requirement\_ovh) | ~> 0.26.0 |
| <a name="requirement_time"></a> [time](#requirement\_time) | ~> 0.9.1 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | ~> 1.49.0 |
| <a name="provider_time"></a> [time](#provider\_time) | ~> 0.9.1 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [openstack_objectstorage_container_v1.bucket](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/objectstorage_container_v1) | resource |
| [time_static.last_update](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/static) | resource |
| [openstack_identity_auth_scope_v3.current](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/data-sources/identity_auth_scope_v3) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_customer"></a> [customer](#input\_customer) | Customer applied to this instance | `string` | `""` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | Environment applied to this instance | `string` | `""` | no |
| <a name="input_name"></a> [name](#input\_name) | Name applied to this instance | `string` | `""` | no |
| <a name="input_ovh_write_user"></a> [ovh\_write\_user](#input\_ovh\_write\_user) | OVH user name who will have write access to the bucket | `string` | n/a | yes |
| <a name="input_region"></a> [region](#input\_region) | OVH region | `string` | `"GRA"` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Tags applied to this instance | `map(string)` | <pre>{<br> "ManagedBy": "terraform"<br>}</pre> | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_bucket"></a> [bucket](#output\_bucket) | n/a |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
18 changes: 18 additions & 0 deletions ovh/bucket/bucket.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
data "openstack_identity_auth_scope_v3" "current" {
name = "current"
}

resource "openstack_objectstorage_container_v1" "bucket" {
name = var.name
region = var.region
metadata = local.interpolated_tags
content_type = "application/json"
container_read = join(":", [
data.openstack_identity_auth_scope_v3.current.project_id,
var.ovh_write_user,
])
container_write = join(":", [
data.openstack_identity_auth_scope_v3.current.project_id,
var.ovh_write_user,
])
}
16 changes: 16 additions & 0 deletions ovh/bucket/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
locals {
# tflint-ignore: terraform_unused_declarations
interpolated_tags = merge({
"Name" = var.name,
"Customer" = var.customer,
"Environment" = var.environment,
"ManagedBy" = "Terraform",
"LastModifiedAt" = time_static.last_update.rfc3339,
},
var.tags
)
s3_region = lower(element(regex("(.*)[[:digit:]]?$", var.region), 0))
}

resource "time_static" "last_update" {
}
8 changes: 8 additions & 0 deletions ovh/bucket/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
output "bucket" {
value = {
"url" = "s3://${openstack_objectstorage_container_v1.bucket.name}",
"endpoint_url" = "https://s3.${local.s3_region}.cloud.ovh.net"
"region" = local.s3_region,
"name" = openstack_objectstorage_container_v1.bucket.name,
}
}
20 changes: 20 additions & 0 deletions ovh/bucket/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# NOTE: you might want to override this files with your own if you are using terragrunt
# and are using more module to compose your stack

terraform {
required_version = "~> 1.3"
required_providers {
time = {
source = "hashicorp/time"
version = "~> 0.9.1"
}
ovh = {
source = "ovh/ovh"
version = "~> 0.26.0"
}
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.49.0"
}
}
}
42 changes: 42 additions & 0 deletions ovh/bucket/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
variable "name" {
description = "Name applied to this instance"
type = string
default = ""
}

variable "customer" {
description = "Customer applied to this instance"
type = string
default = ""
}

variable "environment" {
description = "Environment applied to this instance"
type = string
default = ""
}

variable "tags" {
description = "Tags applied to this instance"
type = map(string)
default = {
"ManagedBy" = "terraform"
}
}

# bellow are specific modules variables
variable "region" {
type = string
description = "OVH region"
default = "GRA"
}

# variable "ovh_service_name" {
# description = "OVH service name"
# type = string
# }

variable "ovh_write_user" {
description = "OVH user name who will have write access to the bucket"
type = string
}
5 changes: 5 additions & 0 deletions ovh/kube-managed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.terraform
.terraform.lock.hcl
terraform.tfvars
terraform.tfstate
terraform.tfstate.*
Empty file added ovh/kube-managed/.tflint.hcl
Empty file.
55 changes: 55 additions & 0 deletions ovh/kube-managed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# OVH Kubernetes Managed Cluster

Create an OVH managed Kubernetes cluster

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.3 |
| <a name="requirement_openstack"></a> [openstack](#requirement\_openstack) | ~> 1.49.0 |
| <a name="requirement_ovh"></a> [ovh](#requirement\_ovh) | ~> 0.24.0 |
| <a name="requirement_time"></a> [time](#requirement\_time) | ~> 0.9.1 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_ovh"></a> [ovh](#provider\_ovh) | ~> 0.24.0 |
| <a name="provider_time"></a> [time](#provider\_time) | ~> 0.9.1 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [ovh_cloud_project_kube.k8s](https://registry.terraform.io/providers/ovh/ovh/latest/docs/resources/cloud_project_kube) | resource |
| [time_static.last_update](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/static) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cloud_project_id"></a> [cloud\_project\_id](#input\_cloud\_project\_id) | Cloud project ID for this cluster | `string` | n/a | yes |
| <a name="input_customer"></a> [customer](#input\_customer) | Customer for the current deployment | `string` | `""` | no |
| <a name="input_default_vrack_gateway"></a> [default\_vrack\_gateway](#input\_default\_vrack\_gateway) | Default vrack gateway for nodes egress | `string` | `""` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | Environment for the current deployment | `string` | `""` | no |
| <a name="input_k8s_version"></a> [k8s\_version](#input\_k8s\_version) | The kubernetes version for this cluster | `string` | `""` | no |
| <a name="input_name"></a> [name](#input\_name) | Name applied to this instance | `string` | `""` | no |
| <a name="input_private_network_id"></a> [private\_network\_id](#input\_private\_network\_id) | Private network ID for the nodes of this cluster | `string` | `""` | no |
| <a name="input_private_network_routing_as_default"></a> [private\_network\_routing\_as\_default](#input\_private\_network\_routing\_as\_default) | Private network routing used as default if true | `bool` | `false` | no |
| <a name="input_region"></a> [region](#input\_region) | Region applied to this cluster | `string` | `""` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Default tags to add to resources | `map(any)` | `{}` | no |
| <a name="input_update_policy"></a> [update\_policy](#input\_update\_policy) | Update policy for this cluster | `string` | `"ALWAYS_UPDATE"` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_id"></a> [id](#output\_id) | n/a |
| <a name="output_kubeconfig"></a> [kubeconfig](#output\_kubeconfig) | n/a |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
14 changes: 14 additions & 0 deletions ovh/kube-managed/kube.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource "ovh_cloud_project_kube" "k8s" {
name = var.name
service_name = var.cloud_project_id
region = var.region
version = var.k8s_version
private_network_id = var.private_network_id

private_network_configuration {
default_vrack_gateway = var.default_vrack_gateway
private_network_routing_as_default = var.private_network_routing_as_default
}

update_policy = var.update_policy
}
15 changes: 15 additions & 0 deletions ovh/kube-managed/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
locals {
# tflint-ignore: terraform_unused_declarations
interpolated_tags = merge({
"Name" = var.name,
"Customer" = var.customer,
"Environment" = var.environment,
"ManagedBy" = "Terraform",
"LastModifiedAt" = time_static.last_update.rfc3339,
},
var.tags
)
}

resource "time_static" "last_update" {
}
8 changes: 8 additions & 0 deletions ovh/kube-managed/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
output "id" {
value = ovh_cloud_project_kube.k8s.id
}

output "kubeconfig" {
sensitive = true
value = ovh_cloud_project_kube.k8s.kubeconfig
}
17 changes: 17 additions & 0 deletions ovh/kube-managed/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
terraform {
required_version = "~> 1.3"
required_providers {
time = {
source = "hashicorp/time"
version = "~> 0.9.1"
}
ovh = {
source = "ovh/ovh"
version = "~> 0.24.0"
}
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.49.0"
}
}
}
66 changes: 66 additions & 0 deletions ovh/kube-managed/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
variable "name" {
description = "Name applied to this instance"
type = string
default = ""
}

variable "customer" {
description = "Customer for the current deployment"
type = string
default = ""
}

variable "environment" {
description = "Environment for the current deployment"
type = string
default = ""
}

variable "tags" {
description = "Default tags to add to resources"
type = map(any)
default = {}
}

# bellow are specific modules variables
variable "cloud_project_id" {
description = "Cloud project ID for this cluster"
type = string
}

variable "region" {
description = "Region applied to this cluster"
type = string
default = ""
}

variable "k8s_version" {
description = "The kubernetes version for this cluster"
type = string
default = ""
}

variable "private_network_id" {
description = "Private network ID for the nodes of this cluster"
type = string
default = ""
}

variable "default_vrack_gateway" {
description = "Default vrack gateway for nodes egress"
type = string
default = ""
}

variable "private_network_routing_as_default" {
description = "Private network routing used as default if true"
type = bool
default = false
}

# one of [ALWAYS_UPDATE, MINIMAL_DOWNTIME, NEVER_UPDATE]
variable "update_policy" {
description = "Update policy for this cluster"
type = string
default = "ALWAYS_UPDATE"
}
5 changes: 5 additions & 0 deletions ovh/kube-nodepool/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.terraform
.terraform.lock.hcl
terraform.tfvars
terraform.tfstate
terraform.tfstate.*
Loading

0 comments on commit f13f1da

Please sign in to comment.