如何在 terraform 中附加字符串和变量
How to append string and variable in terraform
如何在 terraform 中连接字符串和变量。我正在使用 terraform 版本 1.7
Name = "Test (Environment_Name)" where environment_name will be test,stage and prod.
resource "fusionauth_tenant" "tanant" {
name = "Test (Environment_name)"
email_configuration {
default_from_name = "FusionAuth [Environment_name]"
verification_email_template_id = fusionauth_email.verification_template.id
}
如何附加字符串和变量的示例。
settings.tf:
locals {
bucket_prefix = "test-bucket"
}
然后您想创建三个 S3 存储桶。
s3.tf:
resource "aws_s3_bucket" "a" {
bucket = "${local.bucket_prefix}-app"
}
//name = test-bucket-app
resource "aws_s3_bucket" "b" {
bucket = local.bucket_prefix
}
//name = test-bucket
resource "aws_s3_bucket" "c" {
bucket = "my-bucket"
}
//name = my-bucket
如果您想从 var
附加一个变量或从资源中获取一个名称,它将遵循相同的模式。永远是:
"${var.name.value}-my-string"
如何在 terraform 中连接字符串和变量。我正在使用 terraform 版本 1.7
Name = "Test (Environment_Name)" where environment_name will be test,stage and prod.
resource "fusionauth_tenant" "tanant" {
name = "Test (Environment_name)"
email_configuration {
default_from_name = "FusionAuth [Environment_name]"
verification_email_template_id = fusionauth_email.verification_template.id
}
如何附加字符串和变量的示例。
settings.tf:
locals {
bucket_prefix = "test-bucket"
}
然后您想创建三个 S3 存储桶。
s3.tf:
resource "aws_s3_bucket" "a" {
bucket = "${local.bucket_prefix}-app"
}
//name = test-bucket-app
resource "aws_s3_bucket" "b" {
bucket = local.bucket_prefix
}
//name = test-bucket
resource "aws_s3_bucket" "c" {
bucket = "my-bucket"
}
//name = my-bucket
如果您想从 var
附加一个变量或从资源中获取一个名称,它将遵循相同的模式。永远是:
"${var.name.value}-my-string"