如何在“ final_snapshot_identifier”中使用函数。 “ aws_db_instance”
我是Terraform的新手。我想使用Terraform构建RDS(MySQL),并制作其快照名称包含时间戳。我该如何编码才能意识到这一点?
我检查了有关 timestamp()
函数的官方文件(),但是页面没有清楚地提及 in
.tf timestamp()
>文件。
代码
resource "aws_db_instance" "db-dev" {
identifier = "db-dev"
allocated_storage = 30
storage_type = "gp2"
engine = "mysql"
engine_version = "8.0.27"
instance_class = "db.t3.micro"
db_name = "test"
username = "admin"
password = "admin"
port = 3306
publicly_accessible = false
availability_zone = "${var.az_1_private}"
security_group_names = []
vpc_security_group_ids = ["${aws_security_group.sg-1-dev.id}"]
db_subnet_group_name = "db-dev-subnet"
parameter_group_name = "db-dev-parameter"
multi_az = false
backup_retention_period = 0
backup_window = "04:30-05:00"
maintenance_window = "wed:01:00-wed:03:00"
final_snapshot_identifier = "db-dev-${timestamp()}"
}
错误消息
Error: invalid value for final_snapshot_identifier (must only contain alphanumeric characters and hyphens)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
时间戳返回一个UTC时间戳字符串,例如
2022-05-02T05:20:12Z
,其中包括时间戳时间部分的结肠。不允许结肠名称中。
您可以使用
formatdate
任何仅包括字母数字&的格式连字符。例如,这应该有效:
timestamp returns a UTC timestamp string like
2022-05-02T05:20:12Z
which includes colons for the time part of the timestamp.Colons are not permitted to be in snapshot names.
You can use the
formatdate
function to format the timestamp to any format that only includes alphanumeric & hyphen characters.For example, this should work: