小编Amr*_*ghx的帖子

Terraform 资源:执行应用时出现连接错误?

我正在尝试登录 terraform 将使用以下代码创建的 ec2 实例:

resource "aws_instance" "sess1" {
  ami           = "ami-c58c1dd3"
  instance_type = "t2.micro"
  key_name        = "logon"

      connection {
        host= self.public_ip
        user        = "ec2-user"
        private_key = file("/logon.pem")
     }
    
      provisioner "remote-exec" {
        inline = [
          "sudo yum install nginx -y",
          "sudo service nginx start"
        ]
      }
    }
Run Code Online (Sandbox Code Playgroud)

但这给了我一个错误:

PS C:\Users\Amritvir Singh\Documents\GitHub\AWS-Scribble\Terraform> terraform apply
provider.aws.region
  The region where AWS operations will take place. Examples
  are us-east-1, us-west-2, etc.

  Enter a value: us-east-1


Error: Invalid function argument

  on Session1.tf line 13, in …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services terraform terraform-provider-aws

5
推荐指数
1
解决办法
4822
查看次数