Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ Install terraform-docs
choco install terraform-docs
```

## 1.2 MacOS

Terraform Guide

- Install [Terraform](https://www.terraform.io/downloads.html)

### Homebrew and Tfenv

- Install [Homebrew](https://brew.sh/)
- Install [TFENV](https://github.com/tfutils/tfenv)

Example:

```bash
brew install tfenv
tfenv install 0.12.29
tfenv use 0.12.29
terraform -v
```

# 2. Instructions

Expand Down
6 changes: 6 additions & 0 deletions environments/dev/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ provider "aws" {
region = var.region
}

module "key_pairs" {
source = "../../modules/key_pairs"

key_pairs = [var.gitlab_key_name, var.gitaly_key_name, var.praefect_key_name, var.bastion_key_name]
}

module "network" {
source = "../../modules/network"

Expand Down
6 changes: 6 additions & 0 deletions environments/dev_gitaly_cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ provider "aws" {
region = var.region
}

module "key_pairs" {
source = "../../modules/key_pairs"

key_pairs = [var.gitlab_key_name, var.gitaly_key_name, var.praefect_key_name, var.bastion_key_name]
}

module "network" {
source = "../../modules/network"

Expand Down
6 changes: 6 additions & 0 deletions environments/prod/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ provider "aws" {
region = var.region
}

module "key_pairs" {
source = "../../modules/key_pairs"

key_pairs = [var.gitlab_key_name, var.gitaly_key_name, var.praefect_key_name, var.bastion_key_name]
}

module "network" {
source = "../../modules/network"

Expand Down
16 changes: 16 additions & 0 deletions modules/key_pairs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Key Pairs Module

Creates Key Pairs on AWS

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| key_pairs | List of Key_Pairs to create | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| private_keys | List of all private keys |
| public_keys | List of all public keys |
15 changes: 15 additions & 0 deletions modules/key_pairs/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* # Key Pairs module
**/

resource "tls_private_key" "this" {
count = length(var.key_pairs)
algorithm = "RSA"
}

resource "aws_key_pair" "this" {
count = length(var.key_pairs)

key_name = var.key_pairs[count.index]
public_key = tls_private_key.this[count.index].public_key_openssh
}
8 changes: 8 additions & 0 deletions modules/key_pairs/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

output "private_keys" {
value = [tls_private_key.this.*.private_key_pem]
}

output "public_keys" {
value = [tls_private_key.this.*.public_key_pem]
}
4 changes: 4 additions & 0 deletions modules/key_pairs/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variable "key_pairs" {
description = "List of Gitlab key_pairs to create"
type = list(string)
}