From 5e8b4d78856949e4c42c3340555dbc25811a9da2 Mon Sep 17 00:00:00 2001 From: ankush-sqops Date: Fri, 19 Jul 2024 17:56:16 +0530 Subject: [PATCH] Release 1.0.3 (#9) --- .gitignore | 0 .pre-commit-config.yaml | 0 .tflint.hcl | 0 IAM.md | 0 LICENSE | 0 README.md | 16 +++++++++++----- examples/complete/README.md | 2 +- examples/complete/main.tf | 15 ++++++++++++--- examples/complete/outputs.tf | 0 examples/complete/provider.tf | 6 +++--- examples/complete/versions.tf | 0 main.tf | 15 +++++++-------- outputs.tf | 0 variables.tf | 30 +++++++++++++++++++++++++++++- version.tf | 0 15 files changed, 63 insertions(+), 21 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .pre-commit-config.yaml mode change 100644 => 100755 .tflint.hcl mode change 100644 => 100755 IAM.md mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 examples/complete/README.md mode change 100644 => 100755 examples/complete/main.tf mode change 100644 => 100755 examples/complete/outputs.tf mode change 100644 => 100755 examples/complete/provider.tf mode change 100644 => 100755 examples/complete/versions.tf mode change 100644 => 100755 main.tf mode change 100644 => 100755 outputs.tf mode change 100644 => 100755 variables.tf mode change 100644 => 100755 version.tf diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml old mode 100644 new mode 100755 diff --git a/.tflint.hcl b/.tflint.hcl old mode 100644 new mode 100755 diff --git a/IAM.md b/IAM.md old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 7e36f9e..2534086 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # AWS EC2 Keypair -![squareops_avatar] - -[squareops_avatar]: https://squareops.com/wp-content/uploads/2022/12/squareops-logo.png + + + + + ### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
@@ -56,7 +58,7 @@ The required IAM permissions to create resources from this module can be found [ | Name | Source | Version | |------|--------|---------| -| [key\_pair](#module\_key\_pair) | terraform-aws-modules/key-pair/aws | 2.0.0 | +| [key\_pair](#module\_key\_pair) | terraform-aws-modules/key-pair/aws | 2.0.3 | ## Resources @@ -68,9 +70,13 @@ The required IAM permissions to create resources from this module can be found [ | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [additional\_aws\_tags](#input\_additional\_aws\_tags) | Additional tags to be applied to AWS resources. | `map(string)` | `{}` | no | +| [aws\_region](#input\_aws\_region) | Name of the AWS region where S3 bucket is to be created. | `string` | `"us-east-1"` | no | +| [create\_private\_key](#input\_create\_private\_key) | Whether to create the private key or not. | `bool` | `true` | no | | [environment](#input\_environment) | Specifies the identifier for the environment where the key pair will be used. | `string` | `""` | no | -| [key\_name](#input\_key\_name) | Specifies the name to be assigned to the key pair that will be generated. | `string` | `""` | no | +| [key\_pair\_name](#input\_key\_pair\_name) | Specifies the name to be assigned to the key pair that will be generated. | `string` | `""` | no | | [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 | +| [tags](#input\_tags) | Tags to be applied to AWS resources. | `map(string)` |
{
"Environment": "",
"Name": "",
"cost": ""
}
| no | ## Outputs diff --git a/examples/complete/README.md b/examples/complete/README.md old mode 100644 new mode 100755 index 64dc23a..2943dcc --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -32,7 +32,7 @@ No providers. | Name | Source | Version | |------|--------|---------| -| [key\_pair](#module\_key\_pair) | squareops/keypair/aws | n/a | +| [key\_pair](#module\_key\_pair) | ../../ | n/a | ## Resources diff --git a/examples/complete/main.tf b/examples/complete/main.tf old mode 100644 new mode 100755 index 89fe4f2..2323961 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -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 } diff --git a/examples/complete/outputs.tf b/examples/complete/outputs.tf old mode 100644 new mode 100755 diff --git a/examples/complete/provider.tf b/examples/complete/provider.tf old mode 100644 new mode 100755 index c7c13b7..9cc09d7 --- a/examples/complete/provider.tf +++ b/examples/complete/provider.tf @@ -1,6 +1,6 @@ provider "aws" { - region = local.region + region = local.aws_region default_tags { - tags = local.additional_tags + tags = local.additional_aws_tags } -} \ No newline at end of file +} diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf old mode 100644 new mode 100755 diff --git a/main.tf b/main.tf old mode 100644 new mode 100755 index a937119..fd928ff --- a/main.tf +++ b/main.tf @@ -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 } diff --git a/outputs.tf b/outputs.tf old mode 100644 new mode 100755 diff --git a/variables.tf b/variables.tf old mode 100644 new mode 100755 index af191a3..f15a941 --- a/variables.tf +++ b/variables.tf @@ -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 @@ -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 +} diff --git a/version.tf b/version.tf old mode 100644 new mode 100755