Terraform Module for creating and managing Harness Services
This module handle the creation and managment of Services by leveraging the Harness Terraform provider
Note: These modules require a minimum of Terraform Version 1.2.0 to support the Input Validations and Precondition Lifecycle hooks leveraged in the code.
Note: The list of supported Terraform Versions is based on the most recent of each release which has been tested against this module.
- v1.2.9
- v1.3.9
- v1.4.0
- v1.4.2
- v1.4.3
- v1.4.4
- v1.4.5
Note: Terraform version 1.4.1 will not work due to an issue with the Random provider
Note: Terraform Provider must be a minimum of 0.14.9 to support Account or Organization level Infrastructure definitions.
terraform {
required_providers {
harness = {
source = "harness/harness"
version = ">= 0.14"
}
time = {
source = "hashicorp/time"
version = "~> 0.9.1"
}
}
}
Note: When the identifier variable is not provided, the module will automatically format the identifier based on the provided resource name
Name | Description | Type | Default Value | Mandatory |
---|---|---|---|---|
name | [Required] (String) Name of the resource. | string | X | |
organization_id | [Optional] Provide an organization reference ID. Must exist before execution | string | X | |
project_id | [Optional] Provide an project reference ID. Must exist before execution | string | X | |
identifier | [Optional] Provide a custom identifier. More than 2 but less than 128 characters and can only include alphanumeric or '_' | string | null | |
description | [Optional] (String) Description of the resource. | string | Harness Services created via Terraform | |
yaml_file | [Optional] (String) File Path to yaml snippet to include. Must not be provided in conjuction with var.yaml_data. | string | null | One of yaml_file or yaml_data must be provided. |
yaml_data | [Optional] (String) Description of the resource. | string | null | One of yaml_file or yaml_data must be provided. |
yaml_render | [Optional] (Boolean) Determines if the pipeline data should be templatized or is a full pipeline reference file | bool | true | |
tags | [Optional] Provide a Map of Tags to associate with the project | map(any) | {} | |
global_tags | [Optional] Provide a Map of Tags to associate with the project and resources created | map(any) | {} |
Name | Description | Value |
---|---|---|
details | Details for the created Harness service | Map containing details of created service |
service_details | [Deprecated] Details for the created Harness service | Map containing details of created service |
module "services" {
source = "harness-community/delivery/harness//modules/services"
name = "test-service"
organization_id = "myorg"
project_id = "myproject"
yaml_data = <<EOT
serviceDefinition:
spec: {}
type: Ssh
EOT
}
module "services" {
source = "harness-community/delivery/harness//modules/services"
name = "test-service"
organization_id = "myorg"
project_id = "myproject"
yaml_file = "templates/test-service.yaml"
}
module "services" {
source = "harness-community/delivery/harness//modules/services"
name = "test-service"
organization_id = "myorg"
project_id = "myproject"
yaml_render = false
yaml_data = <<EOT
service:
name: test-service
identifier: test_service
description: Harness Service created via Terraform
serviceDefinition:
spec: {}
type: Ssh
EOT
}
variable "services_list" {
type = list(map())
default = [
{
name = "green"
organization_id = "myorg"
project_id = "myproject"
yaml_file = "templates/green-service.yaml"
},
{
name = "blue"
organization_id = "myorg"
project_id = "myproject"
yaml_file = "templates/blue-service.yaml"
},
{
name = "yellow"
organization_id = "myorg"
project_id = "myproject"
yaml_file = "templates/yellow-service.yaml"
}
]
}
variable "global_tags" {
type = map()
default = {
environment = "NonProd"
}
}
module "services" {
source = "harness-community/delivery/harness//modules/services"
for_each = { for service in var.services_list : service.name => service }
name = each.value.name
description = lookup(each.value, "description", "Harness Service Definition for ${each.value.name}")
organization_id = lookup(each.value, "organization_id", null)
project_id = lookup(each.value, "project_id", null)
yaml_render = lookup(each.value, "render", true)
yaml_file = lookup(each.value, "yaml_file", null)
yaml_data = lookup(each.value, "yaml_data", null)
tags = lookup(each.value, "tags", {})
global_tags = var.global_tags
}
A complete Contributors Guide can be found in this repository
Module is maintained by Harness, Inc
MIT License. See LICENSE for full details.