gpt4 book ai didi

azure - 寻找为资源添加后缀以使其名称独一无二的技术

转载 作者:行者123 更新时间:2023-12-02 07:56:31 25 4
gpt4 key购买 nike

我正在创建一些 Azure 资源(例如存储帐户),它们的名称在 Azure 中必须是唯一的。

Terraform 脚本中是否有任何技术允许将随机字符串添加到资源末尾,以便它们的名称在 Azure 中变得唯一?

处理此要求的常见模式是什么?

最佳答案

当然可以,您可以创建资源 random_string 并在名称中使用:

resource "random_string" "random" {
length = 16
special = true
override_special = "/@£$"
}

resource "aws_ecr_repository" "foo" {
name = "bar-${random_string.random.result}"
...
}

https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string

关于azure - 寻找为资源添加后缀以使其名称独一无二的技术,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64600862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com