From e81b0a57589196ab529d69c27adb4f44f88cbe8a Mon Sep 17 00:00:00 2001 From: Anmol Nagpal Date: Thu, 3 Sep 2020 17:51:37 +0530 Subject: [PATCH] add new variable --- README.md | 43 +++++++++++++------------------------------ README.yaml | 2 +- _example/example.tf | 2 +- main.tf | 2 +- varaibles.tf | 11 +++++++++-- 5 files changed, 25 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 7d11840..7d44bd2 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,11 @@ -

-

Terraform AWS Keypair

-

+

Terraform module for generating or importing an SSH public key file into AWS.

@@ -38,30 +36,19 @@
-We eat, drink, sleep and most importantly love **DevOps**. We are working towards stratergies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure. - -This module is basically combination of [Terraform open source](https://www.terraform.io/) and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself. - -We have [*fifty plus terraform modules*][terraform_modules]. A few of them are comepleted and are available for open source usage while a few others are in progress. - ## Prerequisites -This module has a few dependencies: +This module has a few dependencies: -- [Terraform 0.12](https://learn.hashicorp.com/terraform/getting-started/install.html) -- [Go](https://golang.org/doc/install) -- [github.com/stretchr/testify/assert](https://github.com/stretchr/testify) -- [github.com/gruntwork-io/terratest/modules/terraform](https://github.com/gruntwork-io/terratest) -## Examples **IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/terraform-aws-keypair/releases). @@ -70,7 +57,7 @@ This module has a few dependencies: Here is an example of how you can use this module in your inventory structure: ```hcl module "keypair" { - source = "git::https://github.com/clouddrove/terraform-aws-keypair.git?ref=tags/0.12.2" + source = "git::https://github.com/clouddrove/terraform-aws-keypair.git?ref=tags/0.12.3" key = "~/.ssh/id_rsa.pub" key_name = "devops" enable_key_pair = true @@ -79,13 +66,17 @@ Here is an example of how you can use this module in your inventory structure: + + + ## Inputs | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| enable_key_pair | A boolean flag to enable/disable key pair. | bool | `true` | no | -| key_name | Name (e.g. `it-admin` or `devops`). | string | `` | no | -| key_path | Name (e.g. `~/.ssh/id_rsa.pub` or `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQ`). | string | `` | no | +| enable\_key\_pair | A boolean flag to enable/disable key pair. | bool | `"true"` | no | +| key\_name | Name \(e.g. `it-admin` or `devops`\). | string | `""` | no | +| key\_path | Name \(e.g. `~/.ssh/id\_rsa.pub`\). | string | `""` | no | +| public\_key | Name \(e.g. `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQ`\). | string | `""` | no | ## Outputs @@ -95,21 +86,13 @@ Here is an example of how you can use this module in your inventory structure: -## Testing - -In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system. - -You need to run the following command in the testing folder: -```hcl - go test -run Test -``` -## Feedback +## Feedback If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-aws-keypair/issues), or feel free to drop us an email at [hello@clouddrove.com](mailto:hello@clouddrove.com). -If you have found it worth your time, go ahead and give us a * on [our GitHub](https://github.com/clouddrove/terraform-aws-keypair)! +If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-aws-keypair)! ## About us @@ -124,4 +107,4 @@ At [CloudDrove][website], we offer expert guidance, implementation support and s [linkedin]: https://cpco.io/linkedin [twitter]: https://twitter.com/clouddrove/ [email]: https://clouddrove.com/contact-us.html - [terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language= \ No newline at end of file + [terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language= diff --git a/README.yaml b/README.yaml index 22b88d1..e794cc9 100644 --- a/README.yaml +++ b/README.yaml @@ -36,7 +36,7 @@ usage : |- Here is an example of how you can use this module in your inventory structure: ```hcl module "keypair" { - source = "git::https://github.com/clouddrove/terraform-aws-keypair.git?ref=tags/0.12.2" + source = "git::https://github.com/clouddrove/terraform-aws-keypair.git?ref=tags/0.12.3" key = "~/.ssh/id_rsa.pub" key_name = "devops" enable_key_pair = true diff --git a/_example/example.tf b/_example/example.tf index 329a261..3ca1c01 100644 --- a/_example/example.tf +++ b/_example/example.tf @@ -3,7 +3,7 @@ provider "aws" { } module "keypair" { - source = "git::https://github.com/clouddrove/terraform-aws-keypair.git?ref=tags/0.12.2" + source = "./../" key_path = "~/.ssh/id_rsa.pub" key_name = "devops" diff --git a/main.tf b/main.tf index 2b6d021..5301c54 100644 --- a/main.tf +++ b/main.tf @@ -8,5 +8,5 @@ resource "aws_key_pair" "default" { count = var.enable_key_pair == true ? 1 : 0 key_name = var.key_name - public_key = file(var.key_path) + public_key = var.public_key == "" ? file(var.key_path) : var.public_key } \ No newline at end of file diff --git a/varaibles.tf b/varaibles.tf index 28000c2..59487c6 100644 --- a/varaibles.tf +++ b/varaibles.tf @@ -1,15 +1,22 @@ -variable "key_path" { +variable "public_key" { type = string default = "" - description = "Name (e.g. `~/.ssh/id_rsa.pub` or `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQ`)." + description = "Name (e.g. `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQ`)." +} +variable "key_path" { + type = string + default = "" + description = "Name (e.g. `~/.ssh/id_rsa.pub`)." } + variable "key_name" { type = string default = "" description = "Name (e.g. `it-admin` or `devops`)." } + variable "enable_key_pair" { type = bool default = true