Skip to content

Commit

Permalink
feat: add tofu to allow k8s secrets to be generated in terraform and …
Browse files Browse the repository at this point in the history
…pushed to 1pass (#76)
  • Loading branch information
zackpollard authored Jul 11, 2024
1 parent 19b7d7f commit c92d7c4
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
43 changes: 43 additions & 0 deletions deployment/modules/1password/account/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions deployment/modules/1password/account/config.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
terraform {
backend "pg" {
schema_name = "prod_1password_account"
}
required_version = "~> 1.7"

required_providers {
onepassword = {
source = "1Password/onepassword"
version = "~> 2.0"
}
random = {
source = "hashicorp/random"
version = "3.6.2"
}
}
}
41 changes: 41 additions & 0 deletions deployment/modules/1password/account/k8s-secrets.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
data "onepassword_vault" "opentofu" {
name = "OpenTofu"
}

data "onepassword_vault" "kubernetes" {
name = "Kubernetes"
}

resource "random_password" "example_k8s_password_gen_string_2" {
length = 20
special = true
override_special = "!@#$%^&*()_+"
}

resource "onepassword_item" "example_k8s_password_gen" {
vault = data.onepassword_vault.kubernetes.uuid
title = "example-terraform-k8s-password-gen"
category = "password"
password_recipe {
length = 40
symbols = true
letters = true
digits = true
}

section {
label = "Example custom section for terraform k8s vault item"

field {
label = "string-field"
type = "STRING"
value = "example"
}

field {
label = "string-field-generated"
type = "STRING"
value = random_password.example_k8s_password_gen_string_2.result
}
}
}
11 changes: 11 additions & 0 deletions deployment/modules/1password/account/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
terraform {
source = "."

extra_arguments custom_vars {
commands = get_terraform_commands_that_need_vars()
}
}

include "root" {
path = find_in_parent_folders("root.hcl")
}

0 comments on commit c92d7c4

Please sign in to comment.