根據此https://www.terraform.io/docs/configuration/resources.html您可以有resource
和name
。例如。Terraform>資源>名稱 - 無效或未知密鑰
resource "aws_db_instance" "timeout_example" {
allocated_storage = 10
engine = "mysql"
engine_version = "5.6.17"
instance_class = "db.t1.micro"
name = "mydb"
# ...
timeouts {
create = "60m"
delete = "2h"
}
}
但我的樣本tf
文件:
provider "aws" {
access_key = "<access key>"
secret_key = "<secret key>"
region = "us-east-1"
}
resource "aws_instance" "web" {
ami = "ami-0d729a60"
instance_type = "t2.micro"
subnet_id = "<subnet-id>"
name = "web"
}
給我* aws_instance.web: : invalid or unknown key: name
。
任何想法爲什麼?
我沒有在鏈接到的文檔中的metaparameters中看到'name'。 –
正如馬特所言,這不是每個資源上的元參數之一,只是該特定資源的一個參數。如果你想命名一個EC2實例,你需要設置'Name'標籤 – ydaetskcoR