From 198267009f3fba1f1bcd1742e18f7c3736d2fb80 Mon Sep 17 00:00:00 2001 From: rachit89 <115970922+rachit89@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:14:08 +0530 Subject: [PATCH 1/7] Add files via upload Upgrade the version in versions.tf --- main.tf | 2 +- variables.tf | 22 ++++++++++++++++++++++ version.tf | 6 +++--- versions.tf | 14 ++++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 versions.tf diff --git a/main.tf b/main.tf index a937119..4a9a35f 100644 --- a/main.tf +++ b/main.tf @@ -2,7 +2,7 @@ module "key_pair" { source = "terraform-aws-modules/key-pair/aws" version = "2.0.0" key_name = var.key_name - create_private_key = true + create_private_key = var.create_private_key } diff --git a/variables.tf b/variables.tf index af191a3..0210b82 100644 --- a/variables.tf +++ b/variables.tf @@ -1,3 +1,19 @@ +variable "additional_tags" { + description = "Additional tags to be applied to AWS resources" + type = map(string) + default = { + Owner = "organization_name" + Expires = "Never" + Department = "Engineering" + } +} + +variable "aws_region" { + description = "Name of the AWS region where S3 bucket is to be created." + default = "us-east-1" + type = string +} + variable "key_name" { description = "Specifies the name to be assigned to the key pair that will be generated." default = "" @@ -15,3 +31,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 +} \ No newline at end of file diff --git a/version.tf b/version.tf index c2da4bc..de7b9db 100644 --- a/version.tf +++ b/version.tf @@ -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" } } -} +} \ No newline at end of file diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..0c19e8c --- /dev/null +++ b/versions.tf @@ -0,0 +1,14 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.0.0" + } + tls = { + source = "hashicorp/tls" + version = ">= 4.0.3" + } + } +} From b3370ffc49b01e1ac18fe3ca956e7780ecdedd4d Mon Sep 17 00:00:00 2001 From: rachit89 <115970922+rachit89@users.noreply.github.com> Date: Mon, 1 Apr 2024 13:01:23 +0530 Subject: [PATCH 2/7] Update variables.tf removing default values of tags. --- variables.tf | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/variables.tf b/variables.tf index 0210b82..247dee0 100644 --- a/variables.tf +++ b/variables.tf @@ -1,11 +1,7 @@ variable "additional_tags" { description = "Additional tags to be applied to AWS resources" type = map(string) - default = { - Owner = "organization_name" - Expires = "Never" - Department = "Engineering" - } + default = {} } variable "aws_region" { @@ -36,4 +32,4 @@ variable "create_private_key" { description = "Whether to create the private key or not." default = true type = bool -} \ No newline at end of file +} From 44aa64aaf23d09ce46bddc0d02759b447ec48a68 Mon Sep 17 00:00:00 2001 From: rachit89 Date: Mon, 1 Apr 2024 13:04:51 +0530 Subject: [PATCH 3/7] Modified readme for updated versions of AWS tls hashicorp. --- README.md | 9 ++++++--- examples/complete/README.md | 4 ++-- examples/complete/provider.tf | 2 +- examples/complete/versions.tf | 4 ++-- main.tf | 2 +- variables.tf | 18 ++++++++++++++++++ version.tf | 4 ++-- 7 files changed, 32 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7e36f9e..74a8003 100644 --- a/README.md +++ b/README.md @@ -43,14 +43,14 @@ The required IAM permissions to create resources from this module can be found [ | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 4.21 | -| [tls](#requirement\_tls) | >= 3.4 | +| [aws](#requirement\_aws) | >= 5.0.0 | +| [tls](#requirement\_tls) | >= 4.0.3 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 4.21 | +| [aws](#provider\_aws) | >= 5.0.0 | ## Modules @@ -68,6 +68,9 @@ The required IAM permissions to create resources from this module can be found [ | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [additional\_tags](#input\_additional\_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 | | [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 | diff --git a/examples/complete/README.md b/examples/complete/README.md index 64dc23a..458ce3f 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -21,8 +21,8 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 4.21 | -| [tls](#requirement\_tls) | >= 3.4 | +| [aws](#requirement\_aws) | >= 5.0.0 | +| [tls](#requirement\_tls) | >= 4.0.3 | ## Providers diff --git a/examples/complete/provider.tf b/examples/complete/provider.tf index c7c13b7..369af88 100644 --- a/examples/complete/provider.tf +++ b/examples/complete/provider.tf @@ -3,4 +3,4 @@ provider "aws" { default_tags { tags = local.additional_tags } -} \ No newline at end of file +} diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index c2da4bc..0c19e8c 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -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" } } } diff --git a/main.tf b/main.tf index a937119..4a9a35f 100644 --- a/main.tf +++ b/main.tf @@ -2,7 +2,7 @@ module "key_pair" { source = "terraform-aws-modules/key-pair/aws" version = "2.0.0" key_name = var.key_name - create_private_key = true + create_private_key = var.create_private_key } diff --git a/variables.tf b/variables.tf index af191a3..247dee0 100644 --- a/variables.tf +++ b/variables.tf @@ -1,3 +1,15 @@ +variable "additional_tags" { + description = "Additional tags to be applied to AWS resources" + type = map(string) + default = {} +} + +variable "aws_region" { + description = "Name of the AWS region where S3 bucket is to be created." + default = "us-east-1" + type = string +} + variable "key_name" { description = "Specifies the name to be assigned to the key pair that will be generated." default = "" @@ -15,3 +27,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 index c2da4bc..0c19e8c 100644 --- a/version.tf +++ b/version.tf @@ -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" } } } From db5f4b6ef86138ab8e9fbc4747fe8d3375d66c5f Mon Sep 17 00:00:00 2001 From: rachit89 Date: Tue, 2 Apr 2024 15:03:12 +0530 Subject: [PATCH 4/7] Changed name of variable key_name to key_pair_name. --- README.md | 2 +- examples/complete/README.md | 2 +- examples/complete/main.tf | 2 +- main.tf | 2 +- variables.tf | 2 +- version.tf | 2 +- versions.tf | 14 -------------- 7 files changed, 6 insertions(+), 20 deletions(-) delete mode 100644 versions.tf diff --git a/README.md b/README.md index 74a8003..ad3f43f 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ The required IAM permissions to create resources from this module can be found [ | [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 | ## Outputs diff --git a/examples/complete/README.md b/examples/complete/README.md index 458ce3f..dd63621 100644 --- 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 index 89fe4f2..61b865e 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -11,7 +11,7 @@ locals { module "key_pair" { source = "squareops/keypair/aws" - key_name = format("%s-%s-kp", local.environment, local.name) + 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 } diff --git a/main.tf b/main.tf index 4a9a35f..685e097 100644 --- a/main.tf +++ b/main.tf @@ -1,7 +1,7 @@ module "key_pair" { source = "terraform-aws-modules/key-pair/aws" version = "2.0.0" - key_name = var.key_name + key_name = var.key_pair_name create_private_key = var.create_private_key } diff --git a/variables.tf b/variables.tf index 247dee0..d66ad12 100644 --- a/variables.tf +++ b/variables.tf @@ -10,7 +10,7 @@ variable "aws_region" { type = string } -variable "key_name" { +variable "key_pair_name" { description = "Specifies the name to be assigned to the key pair that will be generated." default = "" type = string diff --git a/version.tf b/version.tf index de7b9db..0c19e8c 100644 --- a/version.tf +++ b/version.tf @@ -11,4 +11,4 @@ terraform { version = ">= 4.0.3" } } -} \ No newline at end of file +} diff --git a/versions.tf b/versions.tf deleted file mode 100644 index 0c19e8c..0000000 --- a/versions.tf +++ /dev/null @@ -1,14 +0,0 @@ -terraform { - required_version = ">= 1.0" - - required_providers { - aws = { - source = "hashicorp/aws" - version = ">= 5.0.0" - } - tls = { - source = "hashicorp/tls" - version = ">= 4.0.3" - } - } -} From ac866a090003df91392eb732e9aec99fac615e1b Mon Sep 17 00:00:00 2001 From: rachit89 Date: Tue, 2 Apr 2024 15:17:00 +0530 Subject: [PATCH 5/7] Added tags variable & updated Readme. --- README.md | 3 ++- examples/complete/main.tf | 6 +++++- examples/complete/provider.tf | 2 +- main.tf | 5 +---- variables.tf | 11 ++++++++++- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ad3f43f..d299f77 100644 --- a/README.md +++ b/README.md @@ -68,12 +68,13 @@ The required IAM permissions to create resources from this module can be found [ | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [additional\_tags](#input\_additional\_tags) | Additional tags to be applied to AWS resources | `map(string)` | `{}` | no | +| [additional\_tags](#input\_additional\_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\_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": ""
}
| no | ## Outputs diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 61b865e..d857e92 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -1,7 +1,11 @@ locals { name = "key" - region = "us-east-2" + aws_region = "us-east-2" environment = "prod" + tags = { + Environment = "stg" + Name = "key_pair" + } additional_tags = { Owner = "organization_name" Expires = "Never" diff --git a/examples/complete/provider.tf b/examples/complete/provider.tf index 369af88..755056e 100644 --- a/examples/complete/provider.tf +++ b/examples/complete/provider.tf @@ -1,5 +1,5 @@ provider "aws" { - region = local.region + region = local.aws_region default_tags { tags = local.additional_tags } diff --git a/main.tf b/main.tf index 685e097..d1ce582 100644 --- a/main.tf +++ b/main.tf @@ -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 } diff --git a/variables.tf b/variables.tf index d66ad12..aaeadfe 100644 --- a/variables.tf +++ b/variables.tf @@ -1,9 +1,18 @@ variable "additional_tags" { - description = "Additional tags to be applied to AWS resources" + 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" From d0a3abcdec1f353f99999426aafd0d90f9776cfe Mon Sep 17 00:00:00 2001 From: rachit89 Date: Mon, 22 Apr 2024 11:53:09 +0530 Subject: [PATCH 6/7] Update --- .gitignore | 0 .pre-commit-config.yaml | 0 .tflint.hcl | 0 IAM.md | 0 LICENSE | 0 README.md | 2 +- examples/complete/README.md | 0 examples/complete/main.tf | 4 ++-- examples/complete/outputs.tf | 0 examples/complete/provider.tf | 2 +- examples/complete/versions.tf | 0 main.tf | 0 outputs.tf | 0 variables.tf | 2 +- version.tf | 0 15 files changed, 5 insertions(+), 5 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 d299f77..b390ffe --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ The required IAM permissions to create resources from this module can be found [ | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [additional\_tags](#input\_additional\_tags) | Additional tags to be applied to AWS resources. | `map(string)` | `{}` | no | +| [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 | diff --git a/examples/complete/README.md b/examples/complete/README.md old mode 100644 new mode 100755 diff --git a/examples/complete/main.tf b/examples/complete/main.tf old mode 100644 new mode 100755 index d857e92..5ed64c8 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -6,7 +6,7 @@ locals { Environment = "stg" Name = "key_pair" } - additional_tags = { + additional_aws_tags = { Owner = "organization_name" Expires = "Never" Department = "Engineering" @@ -14,7 +14,7 @@ locals { } module "key_pair" { - source = "squareops/keypair/aws" + 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 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 755056e..9cc09d7 --- a/examples/complete/provider.tf +++ b/examples/complete/provider.tf @@ -1,6 +1,6 @@ provider "aws" { region = local.aws_region default_tags { - tags = local.additional_tags + tags = local.additional_aws_tags } } 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 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 aaeadfe..6eb4a52 --- a/variables.tf +++ b/variables.tf @@ -1,4 +1,4 @@ -variable "additional_tags" { +variable "additional_aws_tags" { description = "Additional tags to be applied to AWS resources." type = map(string) default = {} diff --git a/version.tf b/version.tf old mode 100644 new mode 100755 From 9d96c2efddb199248a74d1b9a26fb652d0436384 Mon Sep 17 00:00:00 2001 From: rachit89 <115970922+rachit89@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:24:21 +0530 Subject: [PATCH 7/7] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b390ffe..0e333f4 100755 --- 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.