Skip to content

Commit

Permalink
Improve ssh-key module
Browse files Browse the repository at this point in the history
  • Loading branch information
posquit0 committed May 9, 2024
1 parent 13af5b2 commit aeb49a2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
7 changes: 4 additions & 3 deletions modules/ssh-key/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ This module creates following resources.

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.22 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.19.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.48.0 |

## Modules

Expand All @@ -35,7 +35,7 @@ This module creates following resources.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_name"></a> [name](#input\_name) | (Required) The name of the SSH key pair. | `string` | n/a | yes |
| <a name="input_public_key"></a> [public\_key](#input\_public\_key) | (Optional) The public key material. | `string` | n/a | yes |
| <a name="input_public_key"></a> [public\_key](#input\_public\_key) | (Required) The public key material. | `string` | n/a | yes |
| <a name="input_module_tags_enabled"></a> [module\_tags\_enabled](#input\_module\_tags\_enabled) | (Optional) Whether to create AWS Resource Tags for the module informations. | `bool` | `true` | no |
| <a name="input_resource_group_description"></a> [resource\_group\_description](#input\_resource\_group\_description) | (Optional) The description of Resource Group. | `string` | `"Managed by Terraform."` | no |
| <a name="input_resource_group_enabled"></a> [resource\_group\_enabled](#input\_resource\_group\_enabled) | (Optional) Whether to create Resource Group to find and group AWS resources which are created by this module. | `bool` | `true` | no |
Expand All @@ -50,5 +50,6 @@ This module creates following resources.
| <a name="output_fingerprint"></a> [fingerprint](#output\_fingerprint) | The MD5 public key fingerprint as specified in section 4 of RFC 4716. |
| <a name="output_id"></a> [id](#output\_id) | The ID of the SSH key pair. |
| <a name="output_name"></a> [name](#output\_name) | The name of the SSH key pair. |
| <a name="output_public_key"></a> [public\_key](#output\_public\_key) | The public key material. |
| <a name="output_type"></a> [type](#output\_type) | The type of the SSH key pair. |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
10 changes: 2 additions & 8 deletions modules/ssh-key/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,13 @@ locals {
} : {}
}

locals {
strategy = {
"CLUSTER" = "cluster"
"PARTITION" = "partition"
"SPREAD" = "spread"
}
}


###################################################
# SSH Key Pair for EC2 Instances
###################################################

# INFO: Not supported attributes
# - `key_name_prefix`
resource "aws_key_pair" "this" {
key_name = var.name
public_key = var.public_key
Expand Down
13 changes: 13 additions & 0 deletions modules/ssh-key/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ output "name" {
value = aws_key_pair.this.key_name
}

output "public_key" {
description = "The public key material."
value = aws_key_pair.this.public_key
}

output "fingerprint" {
description = "The MD5 public key fingerprint as specified in section 4 of RFC 4716."
value = aws_key_pair.this.fingerprint
Expand All @@ -22,3 +27,11 @@ output "type" {
description = "The type of the SSH key pair."
value = aws_key_pair.this.key_type
}

# output "debug" {
# value = {
# for k, v in aws_key_pair.this :
# k => v
# if !contains(["id", "key_name", "key_name_prefix", "arn", "key_pair_id", "fingerprint", "key_type", "public_key", "tags", "tags_all"], k)
# }
# }
2 changes: 1 addition & 1 deletion modules/ssh-key/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ variable "name" {
}

variable "public_key" {
description = "(Optional) The public key material."
description = "(Required) The public key material."
type = string
nullable = false
}
Expand Down
2 changes: 1 addition & 1 deletion modules/ssh-key/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.5"
required_version = ">= 1.6"

required_providers {
aws = {
Expand Down

0 comments on commit aeb49a2

Please sign in to comment.