Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #127 from secrethub/fix/dir-docs
Browse files Browse the repository at this point in the history
 Add docs for dir resource and datasource
  • Loading branch information
florisvdg authored Feb 16, 2021
2 parents d0ae963 + 61a1635 commit 9079b2f
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 4 deletions.
17 changes: 17 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ jobs:
- image: golangci/golangci-lint:v1.27.0-alpine
steps:
- checkout
- restore_cache:
keys:
- go-modules-{{ checksum "go.mod" }}
- run: go mod download
- save_cache:
key: go-modules-{{ checksum "go.mod" }}
paths:
- /go/pkg/mod
- restore_cache:
keys:
- golangci-lint-{{ .Branch }}
- golangci-lint-develop
- run: golangci-lint run
- save_cache:
key: golangci-lint-{{ .Branch }}
paths:
- ~/.cache/golangci-lint
- ~/.cache/go-build
build:
docker:
- image: circleci/golang:1.13
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ linters:
- unconvert
disable-all: true
exclude-use-defaults: false
run:
timeout: 5m
30 changes: 30 additions & 0 deletions docs/data-sources/dir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
layout: "secrethub"
page_title: "secrethub_dir"
sidebar_current: "docs-secrethub-datasource-dir"
description: |-
Read a directory
---

# secrethub_dir Data Source

Use this data source to read a directory already in SecretHub.

## Example Usage

```terraform
data "secrethub_dir" "db" {
path = "company/project/${var.environment}/db"
}
resource "secrethub_secret" "db_password" {
path = "${data.secrethub_dir.db.path}/password"
generate {
length = 32
}
}
```

## Argument Reference

* `path` - (Required) The path of the directory.
6 changes: 5 additions & 1 deletion docs/resources/access-rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ This resource allows you to create and manage access rules, to give users and/or
## Example Usage

```terraform
data "secrethub_dir" "demo" {
path = "workspace/demo"
}
resource "secrethub_access_rule" "demo_app" {
account_name = secrethub_service_aws.demo_app.id
dir = "workspace/demo"
dir = data.secrethub_dir.demo.path
permission = "read"
}
```
Expand Down
46 changes: 46 additions & 0 deletions docs/resources/dir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
layout: "secrethub"
page_title: "secrethub_dir"
sidebar_current: "docs-secrethub-resource-dir"
description: |-
Creates a directory at a given path.
---

# secrethub_dir Resource

This resource allows you to create a directory at a given path.

## Example Usage

```terraform
data "secrethub_dir" "project" {
path = "company/project"
}
resource "secrethub_dir" "environment" {
path = "${data.secrethub_dir.project.path}/${var.environment}"
}
resource "secrethub_dir" "database" {
path = "${secrethub_dir.environment.path}/db"
}
resource "secrethub_secret" "db_user" {
path = "${secrethub_dir.database.path}/username"
value = "db_user"
}
resource "secrethub_secret" "db_password" {
path = "${secrethub_dir.database.path}/password"
generate {
length = 32
}
}
```

## Argument Reference

The following arguments are supported:

* `path` - (Required) The path of the directory.
* `force_destroy` - (Optional) Whether to allow deleting this directory if it's not empty. When set to `false`, you'll get an error when trying to delete the directory if it still contains directories or secrets.
18 changes: 15 additions & 3 deletions docs/resources/secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,25 @@ This resource allows you to write secrets at a given path, if the path already e
To write a secret:

```terraform
data "secrethub_dir" "repo" {
path = "company/repo"
}
resource "secrethub_secret" "ssh_key" {
path = "company/repo/ssh_key"
path = "${data.secrethub_dir.repo.path}/ssh_key"
value = file("/path/to/ssh/key")
}
```

To generate a new, 20 characters long secret made of alphanumeric characters:

```terraform
data "secrethub_dir" "repo" {
path = "company/repo"
}
resource "secrethub_secret" "db_password" {
path = "company/repo/db_password"
path = "${data.secrethub_dir.repo.path}/db_password"
generate {
length = 20
Expand All @@ -36,8 +44,12 @@ resource "secrethub_secret" "db_password" {
To generate a new secret made of lowercase letters and symbols, with minimum 5 symbols:

```terraform
data "secrethub_dir" "repo" {
path = "company/repo"
}
resource "secrethub_secret" "db_password" {
path = "company/repo/db_password"
path = "${data.secrethub_dir.repo.path}/db_password"
generate {
length = 20
Expand Down

0 comments on commit 9079b2f

Please sign in to comment.