我写了一个地形模块,可以创建多个云存储桶。它运行良好,但在创建输出方面存在问题。
主.tf
resource "google_storage_bucket" "buckets" {
name = var.name_bucket
project = var.project_id
输出.tf
output "bucket_name" {
value = google_storage_bucket.buckets.name
}
output "self_link" {
value = google_storage_bucket.buckets.self_link
}
output "url" {
value = google_storage_bucket.buckets.url
}
output "lifecycle_rule" {
value = local.lifecycle_rules
}
iam.tf
resource "google_storage_bucket_iam_member" "object_viewer" {
for_each = toset(var.object_viewers)
member = each.key
bucket = google_storage_bucket.buckets.name
role = "roles/storage.objectViewer"
}
我能够为用户提供objectviewer角色。
然后我用下面的代码调用上面的模块
主.tf
module "s3bucks-cloud-storage" {
for_each = local.s3bucks-buckets
.
.
.
}
输出.tf
output "names" {
description = "Bucket names."
value = module.s3bucks-cloud-storage.bucket_name
}
错误
错误:不支持的属性
在outputs.tf第4行,在输出“names”中:
4:值=模块.s3bucks-cloud-storage.bucket_name
module.s3bucks-cloud-storage是具有3个属性的对象
此对象没有名为“bucket_name”的属性。
我想我已经使用了正确的语法来生成输出,但不确定为什么会出现这个错误。我想输出我在主模块中使用的所有值