Skip to content

Commit 667315b

Browse files
Feat/adding vault init (#19)
* feat: we added vault-init-controller so now this config tf fetches the vault token from s3 * terraform-docs: automated action --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent d6032f9 commit 667315b

File tree

4 files changed

+52
-20
lines changed

4 files changed

+52
-20
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ No requirements.
4848

4949
| Name | Version |
5050
|------|---------|
51+
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
5152
| <a name="provider_vault"></a> [vault](#provider\_vault) | n/a |
5253

5354
## Modules
@@ -70,11 +71,17 @@ No modules.
7071
| [vault_policy.reader](https://registry.terraform.io/providers/hashicorp/vault/latest/docs/resources/policy) | resource |
7172
| [vault_policy.super_admin](https://registry.terraform.io/providers/hashicorp/vault/latest/docs/resources/policy) | resource |
7273
| [vault_policy.vault_backup](https://registry.terraform.io/providers/hashicorp/vault/latest/docs/resources/policy) | resource |
74+
| [aws_s3_object.vault_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/s3_object) | data source |
7375

7476
## Inputs
7577

7678
| Name | Description | Type | Default | Required |
7779
|------|-------------|------|---------|:--------:|
80+
| <a name="input_aws_access_key"></a> [aws\_access\_key](#input\_aws\_access\_key) | n/a | `string` | n/a | yes |
81+
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | n/a | `string` | n/a | yes |
82+
| <a name="input_aws_s3_bucket_name"></a> [aws\_s3\_bucket\_name](#input\_aws\_s3\_bucket\_name) | The name of the S3 bucket to create for the tenant. | `string` | n/a | yes |
83+
| <a name="input_aws_s3_key_vault_secret_file"></a> [aws\_s3\_key\_vault\_secret\_file](#input\_aws\_s3\_key\_vault\_secret\_file) | The full key path to the s3 bucket file that contains the vault access information. Do not include S3://BUCKET\_NAME/ in the path. | `string` | n/a | yes |
84+
| <a name="input_aws_secret_key"></a> [aws\_secret\_key](#input\_aws\_secret\_key) | n/a | `string` | n/a | yes |
7885
| <a name="input_captain_domain"></a> [captain\_domain](#input\_captain\_domain) | Captain Domain for the cluster | `string` | n/a | yes |
7986
| <a name="input_oidc_client_secret"></a> [oidc\_client\_secret](#input\_oidc\_client\_secret) | This is the dex client secret for the 'vault' ClientID | `string` | n/a | yes |
8087
| <a name="input_org_team_policy_mappings"></a> [org\_team\_policy\_mappings](#input\_org\_team\_policy\_mappings) | Each OIDC group should be in the format of GITHUB\_ORG\_NAME:GITHUB\_TEAM\_NAME and the policy name should be either 'reader' or 'editor' | <pre>list(object({<br> policy_name = string<br> oidc_groups = list(string)<br> }))</pre> | <pre>[<br> {<br> "oidc_groups": [<br> "example-org:team1",<br> "example-org:team2"<br> ],<br> "policy_name": "reader"<br> },<br> {<br> "oidc_groups": [<br> "example-org:team1",<br> "example-org:team3"<br> ],<br> "policy_name": "editor"<br> }<br>]</pre> | no |

main.tf

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,17 @@ resource "vault_jwt_auth_backend_role" "default" {
6262
}
6363

6464

65-
66-
65+
data "aws_s3_object" "vault_access" {
66+
bucket = var.aws_s3_bucket_name
67+
key = var.aws_s3_key_vault_secret_file
68+
}
6769

6870

6971
provider "vault" {
70-
address = jsondecode(file("../vault_access.json")).vault_address
71-
token = jsondecode(file("../vault_access.json")).root_token
72+
address = "https://127.0.0.1:8200"
73+
token = jsondecode(data.aws_s3_object.vault_access.body).root_token
7274
}
7375

74-
75-
76-
77-
78-
79-
8076
resource "vault_auth_backend" "kubernetes" {
8177
type = "kubernetes"
8278
}
@@ -114,4 +110,3 @@ resource "vault_kubernetes_auth_backend_role" "vault_backup" {
114110
token_ttl = 3600
115111
token_policies = [vault_policy.vault_backup.name]
116112
}
117-

providers.tf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
terraform {
2+
required_providers {
3+
4+
vault = {
5+
source = "hashicorp/vault"
6+
}
7+
8+
}
9+
}
10+
11+
variable "aws_region" {
12+
type = string
13+
}
14+
15+
variable "aws_access_key" {
16+
type = string
17+
}
18+
19+
variable "aws_secret_key" {
20+
type = string
21+
}
22+
23+
variable "aws_s3_bucket_name" {
24+
description = "The name of the S3 bucket to create for the tenant."
25+
type = string
26+
nullable = false
27+
}
28+
29+
variable "aws_s3_key_vault_secret_file" {
30+
description = "The full key path to the s3 bucket file that contains the vault access information. Do not include S3://BUCKET_NAME/ in the path."
31+
type = string
32+
nullable = false
33+
}
34+
35+
provider "aws" {
36+
region = var.aws_region
37+
access_key = var.aws_access_key
38+
secret_key = var.aws_secret_key
39+
}

versions.tf

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)