Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .pre-commit-config.yaml
100644 → 100755
Empty file.
Empty file modified .tflint.hcl
100644 → 100755
Empty file.
Empty file modified IAM.md
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
20 changes: 13 additions & 7 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# AWS EC2 Keypair
![squareops_avatar]

[squareops_avatar]: https://squareops.com/wp-content/uploads/2022/12/squareops-logo.png
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://squareops.com/wp-content/uploads/2020/05/Squareops-png-white.png1-3.png">
<source media="(prefers-color-scheme: light)" srcset="https://squareops.com/wp-content/uploads/2021/09/Squareops-png-1-1.png">
<img src="https://squareops.com/wp-content/uploads/2021/09/Squareops-png-1-1.png">
</picture>

### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
<br>
Expand Down Expand Up @@ -43,14 +45,14 @@ The required IAM permissions to create resources from this module can be found [
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.21 |
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | >= 3.4 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0.0 |
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | >= 4.0.3 |

## Providers

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

## Modules

Expand All @@ -68,9 +70,13 @@ The required IAM permissions to create resources from this module can be found [

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_additional_aws_tags"></a> [additional\_aws\_tags](#input\_additional\_aws\_tags) | Additional tags to be applied to AWS resources. | `map(string)` | `{}` | no |
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | Name of the AWS region where S3 bucket is to be created. | `string` | `"us-east-1"` | no |
| <a name="input_create_private_key"></a> [create\_private\_key](#input\_create\_private\_key) | Whether to create the private key or not. | `bool` | `true` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | Specifies the identifier for the environment where the key pair will be used. | `string` | `""` | no |
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | Specifies the name to be assigned to the key pair that will be generated. | `string` | `""` | no |
| <a name="input_key_pair_name"></a> [key\_pair\_name](#input\_key\_pair\_name) | Specifies the name to be assigned to the key pair that will be generated. | `string` | `""` | no |
| <a name="input_ssm_parameter_path"></a> [ssm\_parameter\_path](#input\_ssm\_parameter\_path) | Specifies the SSM parameter name that will be used to store the generated key pair. | `string` | `"/example/ssm"` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Tags to be applied to AWS resources. | `map(string)` | <pre>{<br> "Environment": "",<br> "Name": ""<br>}</pre> | no |

## Outputs

Expand Down
6 changes: 3 additions & 3 deletions examples/complete/README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Note that this example may create resources which cost money. Run `terraform des
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.21 |
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | >= 3.4 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0.0 |
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | >= 4.0.3 |

## Providers

Expand All @@ -32,7 +32,7 @@ No providers.

| Name | Source | Version |
|------|--------|---------|
| <a name="module_key_pair"></a> [key\_pair](#module\_key\_pair) | squareops/keypair/aws | n/a |
| <a name="module_key_pair"></a> [key\_pair](#module\_key\_pair) | ../../ | n/a |

## Resources

Expand Down
12 changes: 8 additions & 4 deletions examples/complete/main.tf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
locals {
name = "key"
region = "us-east-2"
aws_region = "us-east-2"
environment = "prod"
additional_tags = {
tags = {
Environment = "stg"
Name = "key_pair"
}
additional_aws_tags = {
Owner = "organization_name"
Expires = "Never"
Department = "Engineering"
}
}

module "key_pair" {
source = "squareops/keypair/aws"
key_name = format("%s-%s-kp", local.environment, local.name)
source = "../../"
key_pair_name = format("%s-%s-kp", local.environment, local.name)
environment = local.environment
ssm_parameter_path = format("%s-%s-ssm", local.environment, local.name) #SSM parameter secret name
}
Empty file modified examples/complete/outputs.tf
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions examples/complete/provider.tf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
provider "aws" {
region = local.region
region = local.aws_region
default_tags {
tags = local.additional_tags
tags = local.additional_aws_tags
}
}
}
4 changes: 2 additions & 2 deletions examples/complete/versions.tf
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.21"
version = ">= 5.0.0"
}
tls = {
source = "hashicorp/tls"
version = ">= 3.4"
version = ">= 4.0.3"
}
}
}
9 changes: 3 additions & 6 deletions main.tf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module "key_pair" {
source = "terraform-aws-modules/key-pair/aws"
version = "2.0.0"
key_name = var.key_name
create_private_key = true
key_name = var.key_pair_name
create_private_key = var.create_private_key
}


Expand All @@ -11,8 +11,5 @@ resource "aws_ssm_parameter" "ssm_ec2_keypair" {
description = "Stores the private key of ec2 key pair"
type = "SecureString"
value = module.key_pair.private_key_pem
tags = {
Environment = var.environment
Name = var.ssm_parameter_path
}
tags = var.tags
}
Empty file modified outputs.tf
100644 → 100755
Empty file.
29 changes: 28 additions & 1 deletion variables.tf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
variable "key_name" {
variable "additional_aws_tags" {
description = "Additional tags to be applied to AWS resources."
type = map(string)
default = {}
}

variable "tags" {
description = "Tags to be applied to AWS resources."
type = map(string)
default = {
Environment = ""
Name = ""
}
}

variable "aws_region" {
description = "Name of the AWS region where S3 bucket is to be created."
default = "us-east-1"
type = string
}

variable "key_pair_name" {
description = "Specifies the name to be assigned to the key pair that will be generated."
default = ""
type = string
Expand All @@ -15,3 +36,9 @@ variable "ssm_parameter_path" {
default = "/example/ssm"
type = string
}

variable "create_private_key" {
description = "Whether to create the private key or not."
default = true
type = bool
}
4 changes: 2 additions & 2 deletions version.tf
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.21"
version = ">= 5.0.0"
}
tls = {
source = "hashicorp/tls"
version = ">= 3.4"
version = ">= 4.0.3"
}
}
}