Skip to content

Commit

Permalink
add new variable
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolnagpal committed Sep 3, 2020
1 parent 2cfc565 commit e81b0a5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 35 deletions.
43 changes: 13 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<!-- This file was automatically generated by the `geine`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->

<p align="center"> <img src="https://user-images.githubusercontent.com/50652676/62349836-882fef80-b51e-11e9-99e3-7b974309c7e3.png" width="100" height="100"></p>


<h1 align="center">
Terraform AWS Keypair
</h1>

<p align="center" style="font-size: 1.2rem;">
<p align="center" style="font-size: 1.2rem;">
Terraform module for generating or importing an SSH public key file into AWS.
</p>

Expand Down Expand Up @@ -38,30 +36,19 @@
<hr>


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 <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> 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).

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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 [[email protected]](mailto:[email protected]).

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

Expand All @@ -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=
[terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language=
2 changes: 1 addition & 1 deletion README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion _example/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
11 changes: 9 additions & 2 deletions varaibles.tf
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit e81b0a5

Please sign in to comment.