我创建了一个terraform配置来启动EC2实例。我的配置是
resource "aws_volume_attachment" "ebs_att" {
device_name = "/dev/sdh"
volume_id = "${aws_ebs_volume.newVolume.id}"
instance_id = "${aws_instance.web.id}"
}
resource "aws_instance" "web" {
ami = "ami-2757f631"
instance_type = "t2.micro"
availability_zone = "us-east-1a"
vpc_security_group_ids=["${aws_security_group.instance.id}"]
key_name="KeyPairVirginia"
tags {
Name = "HelloWorld"
}
}
resource "aws_ebs_volume" "newVolume" {
availability_zone = "us-east-1a"
size = 4
encrypted=true
type="standard"
kms_key_id="arn:aws:kms:us-east-1:257844712457:key/${data.aws_kms_key.ebskey.id}"
tags {
Name = "HelloWorld"
}
}
它为一个EC2实例配置了一个根卷和一个额外的EBS卷。我已经下载了指定的密钥对并执行了chmod 400权限任务。现在,当我尝试SSH到实例时,它给了我权限被拒绝(公钥)错误。
这是为什么?我是否错过了在terraform脚本中指定任何配置?