详细的错误是:
Error: only lowercase alphanumeric characters and hyphens allowed in "cluster_identifier"
on ../rds_cluster/main.tf line 6, in resource "aws_rds_cluster" "mysql-cluster":
6: cluster_identifier = var.identifier
从 terraform 创建 rds_cluster 时出现上述错误。我的 main.tf 文件有以下代码:
provider "aws"{
region = var.region
}
resource "aws_rds_cluster" "mysql-cluster" {
cluster_identifier = var.identifier
availability_zones = var.azs
database_name = var.db_name
master_username = var.username
master_password = var.password
}
variable.tf 文件是:
variable "region"{
default = "us-east-1"
}
variable "identifier" {
default = "aurora-cluster"
}
variable "db_name" {
default = "mydb"
}
variable "username" {}
variable "password" {}
variable "azs" {}
调用这个“rds_cluster”的模块文件是:
provider "aws"{
region = "us-east-1"
}
data "aws_availability_zones" "azs" {
}
data "aws_secretsmanager_secret_version" "creds" {
secret_id = "db-creds"
}
module "mysql_aurora_instances" {
source = "../rds_instance/"
my_count = 2
identifier = "aurora-cluster"
cluster_identifier = "mysql_aurora_cluster"
instance_class = "db.t2.micro"
engine = "aurora-mysql"
engine_version = "5.7"
}
module "mysql_aurora_cluster" {
source = "../rds_cluster/"
identifier = "mysql_aurora_cluster"
azs = data.aws_availability_zones.azs.names
db_name = "my_db"
username = "demo"
password = data.aws_secretsmanager_secret_version.creds.secret_id
}
注意事项:
- 我正在使用 terraform 0.14
- 当我执行 terraform validate 时,我得到“成功!配置有效。”
- 但是,当我执行 terraform plan 时,出现上述错误