Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions k8s/helm-template/.tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugin "terraform" {
enabled = true
preset = "recommended"
}
1 change: 1 addition & 0 deletions k8s/helm-template/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform 1.3.1
58 changes: 58 additions & 0 deletions k8s/helm-template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# helm template

Generates kubernetes YAML manifests through helm

<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.3 |
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.17.0, < 3.0.0 |
| <a name="requirement_time"></a> [time](#requirement\_time) | ~> 0.9.1 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_helm"></a> [helm](#provider\_helm) | >= 2.17.0, < 3.0.0 |
| <a name="provider_time"></a> [time](#provider\_time) | ~> 0.9.1 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [time_static.last_update](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/static) | resource |
| [helm_template.main](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/data-sources/template) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_atomic"></a> [atomic](#input\_atomic) | Atomic deployment | `bool` | `false` | no |
| <a name="input_chart"></a> [chart](#input\_chart) | Chart to use for the current deployment | `string` | `""` | no |
| <a name="input_chart_version"></a> [chart\_version](#input\_chart\_version) | Version of the chart to use for the current deployment | `string` | `""` | no |
| <a name="input_create_namespace"></a> [create\_namespace](#input\_create\_namespace) | Create namespace | `bool` | `true` | no |
| <a name="input_customer"></a> [customer](#input\_customer) | Customer for the current deployment | `string` | `""` | no |
| <a name="input_kubeconfig_context"></a> [kubeconfig\_context](#input\_kubeconfig\_context) | Kubeconfig context to use for the current deployment | `string` | `null` | no |
| <a name="input_kubeconfig_paths"></a> [kubeconfig\_paths](#input\_kubeconfig\_paths) | List of kubeconfig paths to use for the current deployment | `list(string)` | `[]` | no |
| <a name="input_name"></a> [name](#input\_name) | The name of the helm release | `string` | n/a | yes |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace to use for the current deployment | `string` | `""` | no |
| <a name="input_repository"></a> [repository](#input\_repository) | Repository to use for the current deployment | `string` | `""` | no |
| <a name="input_sets"></a> [sets](#input\_sets) | List of sets to use for the current deployment | `list(map(string))` | `[]` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Default tags to add to resources | `map(any)` | `{}` | no |
| <a name="input_values"></a> [values](#input\_values) | List of values to use for the current deployment | `list(string)` | `[]` | no |
| <a name="input_wait"></a> [wait](#input\_wait) | Wait for deployment to complete | `bool` | `true` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_manifest"></a> [manifest](#output\_manifest) | Rendered Kubernetes manifests generated by Helm |
| <a name="output_name"></a> [name](#output\_name) | The name of the helm release |
| <a name="output_namespace"></a> [namespace](#output\_namespace) | The namespace of the helm release |
<!-- END_TF_DOCS -->
21 changes: 21 additions & 0 deletions k8s/helm-template/helm-template.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
data "helm_template" "main" {
name = var.name
repository = var.repository
chart = var.chart
version = var.chart_version
namespace = var.namespace
atomic = var.atomic
create_namespace = var.create_namespace
wait = var.wait
Comment thread
fredleger marked this conversation as resolved.

values = var.values

dynamic "set" {
for_each = var.sets
content {
name = set.value["name"]
value = set.value["value"]
}
}

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

resource "time_static" "last_update" {
}
15 changes: 15 additions & 0 deletions k8s/helm-template/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "name" {
description = "The name of the helm release"
value = data.helm_template.main.name
}

output "namespace" {
description = "The namespace of the helm release"
value = data.helm_template.main.namespace
}

output "manifest" {
description = "Rendered Kubernetes manifests generated by Helm"
sensitive = true
value = data.helm_template.main.manifest
}
Comment thread
Copilot marked this conversation as resolved.
20 changes: 20 additions & 0 deletions k8s/helm-template/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
terraform {
required_version = "~> 1.3"
required_providers {
helm = {
source = "hashicorp/helm",
version = ">= 2.17.0, < 3.0.0"
}
time = {
source = "hashicorp/time",
version = "~> 0.9.1"
}
}
}

provider "helm" {
kubernetes {
config_paths = var.kubeconfig_paths
config_context = var.kubeconfig_context
}
}
83 changes: 83 additions & 0 deletions k8s/helm-template/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
variable "name" {
description = "The name of the helm release"
type = string
}

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

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

# module specific variables
variable "kubeconfig_paths" {
description = "List of kubeconfig paths to use for the current deployment"
type = list(string)
default = []
}

variable "kubeconfig_context" {
description = "Kubeconfig context to use for the current deployment"
type = string
default = null
}

variable "repository" {
description = "Repository to use for the current deployment"
type = string
default = ""
}

variable "chart" {
description = "Chart to use for the current deployment"
type = string
default = ""
}

variable "chart_version" {
description = "Version of the chart to use for the current deployment"
type = string
default = ""
}

variable "namespace" {
description = "Namespace to use for the current deployment"
type = string
default = ""
}

variable "sets" {
description = "List of sets to use for the current deployment"
type = list(map(string))
default = []
}

variable "values" {
description = "List of values to use for the current deployment"
type = list(string)
default = []
}

variable "atomic" {
description = "Atomic deployment"
type = bool
default = false
}

variable "create_namespace" {
description = "Create namespace"
type = bool
default = true
}

variable "wait" {
description = "Wait for deployment to complete"
type = bool
default = true
}
Comment thread
fredleger marked this conversation as resolved.
Loading