I created a terraform configuration to launch an EC2 instance. My configuration is
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" } }
It provisioned an EC2 instance with a root volume and one additional EBS volume. I already have downloaded the specified key pair and did chmod 400 permission task. Now when I try to SSH into the instance it gives me Permission Denied (Public Key) error.
Why is this? Did I miss to specify any configuration in the terraform script?