From 91627b6326f3d85d69a3de08482cd98748640a4f Mon Sep 17 00:00:00 2001 From: miampf Date: Thu, 18 Apr 2024 17:11:50 +0200 Subject: [PATCH] openstack implementation --- cli/internal/cloudcmd/tfvars.go | 9 +++++++++ cli/internal/terraform/variables.go | 1 + terraform/infrastructure/openstack/main.tf | 2 +- terraform/infrastructure/openstack/variables.tf | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cli/internal/cloudcmd/tfvars.go b/cli/internal/cloudcmd/tfvars.go index 67640e2c0..f026282c6 100644 --- a/cli/internal/cloudcmd/tfvars.go +++ b/cli/internal/cloudcmd/tfvars.go @@ -264,6 +264,14 @@ func openStackTerraformVars(conf *config.Config, imageRef string) (*terraform.Op StateDiskType: group.StateDiskType, } } + + // since openstack does not support tags in the form of key = value, the tags will be converted + // to an array of "key=value" strings + tags := []string{} + for key, value := range conf.Tags { + tags = append(tags, fmt.Sprintf("%s=%s", key, value)) + } + return &terraform.OpenStackClusterVariables{ Name: conf.Name, Cloud: toPtr(conf.Provider.OpenStack.Cloud), @@ -275,6 +283,7 @@ func openStackTerraformVars(conf *config.Config, imageRef string) (*terraform.Op CustomEndpoint: conf.CustomEndpoint, InternalLoadBalancer: conf.InternalLoadBalancer, STACKITProjectID: conf.Provider.OpenStack.STACKITProjectID, + AdditionalTags: tags, }, nil } diff --git a/cli/internal/terraform/variables.go b/cli/internal/terraform/variables.go index 0b1fee089..f58a29f1f 100644 --- a/cli/internal/terraform/variables.go +++ b/cli/internal/terraform/variables.go @@ -303,6 +303,7 @@ type OpenStackClusterVariables struct { CustomEndpoint string `hcl:"custom_endpoint" cty:"custom_endpoint"` // InternalLoadBalancer is true if an internal load balancer should be created. InternalLoadBalancer bool `hcl:"internal_load_balancer" cty:"internal_load_balancer"` + AdditionalTags []string `hcl:"additional_tags" cty:"additional_tags"` } // GetCreateMAA gets the CreateMAA variable. diff --git a/terraform/infrastructure/openstack/main.tf b/terraform/infrastructure/openstack/main.tf index 9fc228bdc..4c429f4b4 100644 --- a/terraform/infrastructure/openstack/main.tf +++ b/terraform/infrastructure/openstack/main.tf @@ -46,7 +46,7 @@ locals { ]) cidr_vpc_subnet_nodes = "192.168.178.0/24" cidr_vpc_subnet_lbs = "192.168.177.0/24" - tags = ["constellation-uid-${local.uid}"] + tags = concat(["constellation-uid-${local.uid}"], var.additional_tags) identity_service = [ for entry in data.openstack_identity_auth_scope_v3.scope.service_catalog : entry if entry.type == "identity" diff --git a/terraform/infrastructure/openstack/variables.tf b/terraform/infrastructure/openstack/variables.tf index 98714a200..098fb6310 100644 --- a/terraform/infrastructure/openstack/variables.tf +++ b/terraform/infrastructure/openstack/variables.tf @@ -59,6 +59,11 @@ variable "floating_ip_pool_id" { description = "Pool (network name) to use for floating IPs." } +variable "additional_tags" { + type = list + description = "Additional tags that should be applied to created resources." +} + # STACKIT-specific variables variable "stackit_project_id" {