/terraform-aws-key-pair

Terraform module which creates EC2 key pair on AWS

Primary LanguageHCLOtherNOASSERTION

AWS Key Pair Terraform module

Terraform module which creates EC2 key pair resource by Terraform AWS provider.

This type of resources are supported:

Terraform versions

Only Terraform 0.12 is supported.

Usage

Private bucket with versioning enabled

module "key_pair" {
  source = "terraform-aws-modules/key-pair/aws"

  key_name   = "deployer"
  public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 email@example.com"

}

Conditional creation

Sometimes you need to have a way to create key pair conditionally but Terraform does not allow to use count inside module block, so the solution is to specify argument create_key_pair.

# This EC2 key pair will not be created
module "key_pair" {
  source = "terraform-aws-modules/key-pair/aws"

  create_key_pair = false
  # ... omitted
}

Examples:

Inputs

Name Description Type Default Required
create_key_pair Controls if key pair should be created bool "true" no
key_name The name for the key pair. string "null" no
key_name_prefix Creates a unique name beginning with the specified prefix. Conflicts with key_name. string "null" no
public_key The public key material. string "" no

Outputs

Name Description
this_key_pair_fingerprint The MD5 public key fingerprint as specified in section 4 of RFC 4716.
this_key_pair_key_name The key pair name.

Authors

Module managed by Anton Babenko.

License

Apache 2 Licensed. See LICENSE for full details.