config name randomiser a bit more randomer.

This commit is contained in:
Greyscale 2024-11-23 20:01:56 +01:00
parent fa3c0ac16f
commit 15b530eee6
Signed by: grey
GPG key ID: DDB392AE64B32D89
3 changed files with 10 additions and 2 deletions

View file

@ -1,3 +1,7 @@
resource "random_id" "randomiser" {
byte_length = 2
}
resource "docker_config" "config" { resource "docker_config" "config" {
name = local.config_name name = local.config_name
data = base64encode(var.value) data = base64encode(var.value)

View file

@ -6,8 +6,8 @@ locals {
// I will share that into 20 bytes for the stack name, remaining bytes for the config name // I will share that into 20 bytes for the stack name, remaining bytes for the config name
config_name = join("-", [ config_name = join("-", [
substr(var.stack_name, 0, 20), substr(var.stack_name, 0, 20),
substr(local.file_name, 0, 64 - 1 - 7 - 2 - 20), substr(local.file_name, 0, 64 - 20 - 1 - (random_id.randomiser.byte_length * 2) - 1),
substr(sha1(var.value), 0, 7) random_id.randomiser.hex
]) ])
// define config labels // define config labels

View file

@ -10,6 +10,10 @@ terraform {
source = "hashicorp/local" source = "hashicorp/local"
version = "~>2.1" version = "~>2.1"
} }
random = {
source = "hashicorp/random"
version = "~>3.3"
}
} }
} }