Terraform module which creates EC2 key pair resource by Terraform AWS provider.
resource "tls_private_key" "this" {
algorithm = "RSA"
}
module "key_pair" {
source = "terraform-aws-modules/key-pair/aws"
key_name = "deployer-one"
public_key = tls_private_key.this.public_key_openssh
}
module "key_pair" {
source = "terraform-aws-modules/key-pair/aws"
key_name = "deployer-two"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]"
}
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
}
- Complete - Create EC2 key pair
Name | Version |
---|---|
terraform | >= 0.12.6 |
aws | >= 2.46 |
Name | Version |
---|---|
aws | >= 2.46 |
No modules.
Name | Type |
---|---|
aws_key_pair.this | resource |
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 |
tags | A map of tags to add to key pair resource. | map(string) |
{} |
no |
Name | Description |
---|---|
key_pair_fingerprint | The MD5 public key fingerprint as specified in section 4 of RFC 4716. |
key_pair_key_name | The key pair name. |
key_pair_key_pair_id | The key pair ID. |
Module is maintained by Anton Babenko with help from these awesome contributors.
Apache 2 Licensed. See LICENSE for full details.