Skip to content

Commit

Permalink
Merge pull request #21 from remerge/op-secrets-module
Browse files Browse the repository at this point in the history
Add op/secrets module
  • Loading branch information
hollow committed Dec 13, 2023
2 parents ca0cc22 + b1de7a2 commit 126a4e1
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 8 deletions.
3 changes: 1 addition & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
# Changes here will be overwritten by Copier
_commit: v2.2.0
_commit: v2.8.0
_src_path: gh:remerge/template
project_id: terraform-modules
project_license: apache-2.0
project_name: Terraform Modules
project_owner: core
project_type: terraform-module
run_workflows_for_all_branches: false
use_python: false
3 changes: 2 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
strict_env

# Loads a ".env" file into the current environment
dotenv_if_exists
dotenv_if_exists "${PWD}"/../.env
dotenv_if_exists "${PWD}"/.env

# Add local scripts to PATH
PATH_add "${PWD}/bin"
Expand Down
8 changes: 8 additions & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
self-hosted-runner:
labels:
- generic
- self-hosted
- nomad
- docker
- default
15 changes: 14 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ on:
push:
branches: [main, master]

permissions: read-all
permissions:
actions: none
checks: none
contents: read
deployments: none
discussions: none
id-token: none
issues: none
packages: none
pages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none

jobs:
pre-commit:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,6 @@ id_*
# only.
!*.tfvars
!*.tfvars.json

# Ignore direnv files
.direnv/
Expand Down
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:

# https://github.com/pre-commit/mirrors-prettier/tags
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.3"
rev: "v3.1.0"
hooks:
- id: prettier
exclude: "^project/"
Expand All @@ -47,7 +47,7 @@ repos:

# https://github.com/adrienverge/yamllint/tags
- repo: https://github.com/adrienverge/yamllint
rev: "v1.32.0"
rev: "v1.33.0"
hooks:
- id: yamllint
entry: yamllint --strict
Expand All @@ -74,7 +74,7 @@ repos:

# https://github.com/antonbabenko/pre-commit-terraform/tags
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: "v1.83.5"
rev: "v1.83.6"
hooks:
- id: terraform_fmt
name: terraform-fmt
Expand All @@ -83,7 +83,7 @@ repos:

# https://github.com/bridgecrewio/checkov/tags
- repo: https://github.com/bridgecrewio/checkov
rev: "3.0.21"
rev: "3.1.30"
hooks:
- id: checkov
name: checkov
Expand All @@ -100,3 +100,4 @@ repos:
rev: "v0.19.0"
hooks:
- id: woke-from-source
args: [--config=.woke.yaml]
1 change: 1 addition & 0 deletions .woke.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
15 changes: 15 additions & 0 deletions op/secrets/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
data "onepassword_vault" "secrets" {
name = "secrets"
}

resource "onepassword_item" "secrets" {
for_each = var.secrets
vault = data.onepassword_vault.secrets.id
title = "${var.prefix}_${each.key}"
category = "password"
password = each.value
tags = concat(var.tags, [
"prefix:${var.prefix}",
"workspace:${var.workspace}",
])
}
16 changes: 16 additions & 0 deletions op/secrets/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
variable "workspace" {
type = string
}

variable "prefix" {
type = string
}

variable "tags" {
type = list(string)
default = []
}

variable "secrets" {
type = map(string)
}
9 changes: 9 additions & 0 deletions op/secrets/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_providers {
# https://registry.terraform.io/providers/1Password/onepassword/latest
onepassword = {
source = "1Password/onepassword"
version = "~> 1.3"
}
}
}

0 comments on commit 126a4e1

Please sign in to comment.