cloudposse/terraform-aws-efs-backup

parameter value for parameter name myKeyPair does not exist

p1t3r opened this issue · 1 comments

p1t3r commented

Hi,

I have got following the errors applying (terraform apply):

module.efs_backup.aws_cloudformation_stack.datapipeline: 1 error(s) occurred: aws_cloudformation_stack.datapipeline: ROLLBACK_COMPLETE: ["Parameter validation failed: parameter value for parameter name myKeyPair does not exist. Rollback requested by user."]

I have used the following code:

main.tf

module "efs_backup" {
source = "git::https://github.com/cloudposse/terraform-aws-efs-backup.git?ref=master"

name = "${var.name}"
stage = "${var.stage}"
namespace = "${var.namespace}"
vpc_id = "${var.vpc_id}"
efs_mount_target_id = "${var.efs_mount_target_id}"
use_ip_address = "false"
noncurrent_version_expiration_days = "${var.noncurrent_version_expiration_days}"
ssh_key_pair = "${var.ssh_key_pair}"
datapipeline_config = "${var.datapipeline_config}"
modify_security_group = "true"
}

output "efs_backup_security_group" {
value = "${module.efs_backup.security_group_id}"

terraform.tfvars

namespace = "namespace"

stage = "stage"

name = "efs-backup"

region = "eu-central-1"

vpc_id = "vpc-0123456"

efs_mount_target_id = "fsmt-0123456"

#use_ip_address = "false"

#modify_security_group = "false"

noncurrent_version_expiration_days = "35"

ssh_key_pair = ""

#datapipeline_config = "${map("instance_type", "t2.micro", "email", "", "period", "24 hours", "timeout", "60 Minutes")}"

attributes = []

tags = {}

delimiter = "-"

variables.tf

variable "name" {
type = "string"
}

variable "namespace" {
type = "string"
}

variable "stage" {
type = "string"
}

variable "region" {
type = "string"
default = ""
description = "(Optional) AWS Region. If not specified, will be derived from 'aws_region' data source"
}

variable "vpc_id" {
type = "string"
}

variable "use_ip_address" {
default = "false"
}

variable "datapipeline_config" {
type = "map"

default = {
instance_type = "t2.micro"
email = "mail@mail.com"
period = "24 hours"
timeout = "60 Minutes"
}
}

variable "efs_mount_target_id" {
type = "string"
description = "EFS Mount Target ID (e.g. fsmt-279bfc62)"
}

variable "modify_security_group" {
default = "false"
}

variable "ssh_key_pair" {
type = "string"
}

variable "noncurrent_version_expiration_days" {
default = "35"
}

variable "delimiter" {
type = "string"
default = "-"
description = "Delimiter to be used between name, namespace, stage, etc."
}

variable "attributes" {
type = "list"
default = []
description = "Additional attributes (e.g. efs-backup)"
}

variable "tags" {
type = "map"
default = {}
description = "Additional tags (e.g. map('BusinessUnit,XYZ)"
}

I have set the SSH Public Key in this way:

ssh_key_pair = "ssh-rsa ABCDEF123456"
but got error applying:
module.efs_backup.aws_cloudformation_stack.datapipeline: 1 error(s) occurred: aws_cloudformation_stack.datapipeline: ROLLBACK_COMPLETE: ["Parameter validation failed: parameter value ssh-rsa ABCDDEF123456 for parameter name myKeyPair does not exist. Rollback requested by user."]
then I set the variable to "", but then came the following error:
module.efs_backup.aws_cloudformation_stack.datapipeline: 1 error(s) occurred: aws_cloudformation_stack.datapipeline: ROLLBACK_COMPLETE: ["Parameter validation failed: parameter value for parameter name myKeyPair does not exist. Rollback requested by user."]

But according to documentation, this variable is optional so actually the second solution should work..

Do you have an idea how to solve it?

Thanks in advance!

p1t3r commented

OK, I have solved this one also. But I think it needs to be better documented. Nevertheless, it still looks like a bug since the SSH key is mandatory, although README says otherwise..

My solution was to use a key name from EC2 Console -> Network & Security -> Key Pairs -> one of the key pair name. I think it could be great if it would be explicitly said in the documentation what kind of SSH Key is exactly needed (and where to get it from) ;-)