Skip to content

Commit

Permalink
Release 1.0.3 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush-sqops authored Jul 19, 2024
1 parent bb56bc6 commit 5e8b4d7
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 21 deletions.
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.
16 changes: 11 additions & 5 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 @@ -56,7 +58,7 @@ The required IAM permissions to create resources from this module can be found [

| Name | Source | Version |
|------|--------|---------|
| <a name="module_key_pair"></a> [key\_pair](#module\_key\_pair) | terraform-aws-modules/key-pair/aws | 2.0.0 |
| <a name="module_key_pair"></a> [key\_pair](#module\_key\_pair) | terraform-aws-modules/key-pair/aws | 2.0.3 |

## Resources

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> "cost": ""<br>}</pre> | no |

## Outputs

Expand Down
2 changes: 1 addition & 1 deletion examples/complete/README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 12 additions & 3 deletions examples/complete/main.tf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
# Local Variables declaration
locals {
name = "key"
region = "us-east-2"
aws_region = "us-east-2"
environment = "prod"
additional_tags = {
tags = {
Environment = "stg"
Name = "key_pair"
cost = format("%s-%s-kp", local.environment, local.name)
}
additional_aws_tags = {
Owner = "organization_name"
Expires = "Never"
Department = "Engineering"
}
}

# Using "squareops/keypair/aws" module to generate an EC2 key pair and storing it in ssm parameter store.
module "key_pair" {
source = "squareops/keypair/aws"
key_name = format("%s-%s-kp", local.environment, local.name)
version = "1.0.2"
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
tags = local.tags
}
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
}
}
}
Empty file modified examples/complete/versions.tf
100644 → 100755
Empty file.
15 changes: 7 additions & 8 deletions main.tf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Module block for creating an EC2 key pair
module "key_pair" {
source = "terraform-aws-modules/key-pair/aws"
version = "2.0.0"
key_name = var.key_name
create_private_key = true
version = "2.0.3"
key_name = var.key_pair_name
create_private_key = var.create_private_key
tags = var.tags
}


# Resource block for storing the private key in AWS Systems Manager Parameter Store
resource "aws_ssm_parameter" "ssm_ec2_keypair" {
name = var.ssm_parameter_path
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.
30 changes: 29 additions & 1 deletion variables.tf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
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 = ""
cost = ""
}
}

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 +37,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
}
Empty file modified version.tf
100644 → 100755
Empty file.

0 comments on commit 5e8b4d7

Please sign in to comment.