Amazon web services Terraform中的关键文件
每当我将Amazon web services Terraform中的关键文件,amazon-web-services,terraform,Amazon Web Services,Terraform,每当我将key\u name添加到我的amazon资源时,我永远无法实际连接到生成的实例: provider "aws" { "region" = "us-east-1" "access_key" = "**" "secret_key" = "****" } resource "aws_instance" "api_server" { ami = "ami-013f1e6b" instance_type = "t2.micro" "key_nam
key\u name
添加到我的amazon资源时,我永远无法实际连接到生成的实例:
provider "aws" {
"region" = "us-east-1"
"access_key" = "**"
"secret_key" = "****"
}
resource "aws_instance" "api_server" {
ami = "ami-013f1e6b"
instance_type = "t2.micro"
"key_name" = "po"
tags {
Name = "API_Server"
}
}
output "API IP" {
value = "${aws_instance.api_server.public_ip}"
}
当我这样做的时候
ssh-i~/Downloads/po.pembitnami@IP
我只是在我的终端上写了一个空行,好像我输入了一个错误的IP。但是,通过检查Amazon控制台,我可以看到该实例正在运行。我的Terraform上也没有任何错误。默认情况下,不允许所有网络访问。您需要通过设置安全组来明确允许网络访问
provider "aws" {
"region" = "us-east-1"
"access_key" = "**"
"secret_key" = "****"
}
resource "aws_instance" "api_server" {
ami = "ami-013f1e6b"
instance_type = "t2.micro"
key_name = "po"
security_groups = ["${aws_security_group.api_server.id}"]
tags {
Name = "API_Server"
}
}
resource "aws_security_group" "api_server" {
name = "api_server"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["XXX.XXX.XXX.XXX/32"] // Allow SSH from your global IP
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
output "API IP" {
value = "${aws_instance.api_server.public_ip}"
}