Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Data source data.boundary_user #468

Merged
merged 19 commits into from
Oct 17, 2023
Merged
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
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
drewmullen marked this conversation as resolved.
Show resolved Hide resolved
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch a test function",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"args": [
"-test.v",
"-test.run",
"^${selectedText}$"
],
"showLog": true,
"envFile": "${workspaceFolder}/.vscode/private.env"
}
]
}
3 changes: 3 additions & 0 deletions .vscode/private.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TF_ACC=1
TF_LOG=INFO
GOFLAGS='-mod=readonly'
56 changes: 33 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
![](boundary.png)

Terraform Provider Boundary
==================
# Terraform Provider Boundary

Available in the [Terraform Registry](https://registry.terraform.io/providers/hashicorp/boundary/latest).

Requirements
------------
## Requirements

- [Terraform](https://www.terraform.io/downloads.html) >= 0.12.x
- [Go](https://golang.org/doc/install) >= 1.20

Building The Provider
---------------------
## Building The Provider

1. Clone the repository
1. Enter the repository directory
Expand All @@ -22,32 +19,30 @@ You'll need to ensure that your Terraform file contains the information necessar

```hcl
terraform {
required_providers {
boundary = {
source = "localhost/providers/boundary"
version = "0.0.1"
}
}
required_providers {
boundary = {
source = "localhost/providers/boundary"
version = "0.0.1"
}
}
}
```

Adding Dependencies
---------------------
## Adding Dependencies

This provider uses [Go modules](https://github.com/golang/go/wiki/Modules).
Please see the Go documentation for the most up to date information about using Go modules.

To add a new dependency `github.com/author/dependency` to your Terraform provider:

```
```shell
go get github.com/author/dependency
go mod tidy
```

Then commit the changes to `go.mod` and `go.sum`.

Developing the Provider
---------------------------
## Developing the Provider

If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above).

Expand All @@ -72,17 +67,32 @@ $ make testacc
For more details on the docker image and troubleshooting see the
[boundary testing doc](https://github.com/hashicorp/boundary/blob/main/CONTRIBUTING.md#testing).

Generating Docs
----------------------
## Debugging the provider

If you're using vscode, this provider has delve debugging baked into the [.vscode](https://github.com/hashicorp/terraform-provider-boundary/tree/main/.vscode) directory. To debug you can find instructions [here.](https://dev.to/drewmullen/vscode-terraform-provider-development-setup-debugging-6bn#usage)

## Generating Docs

This provider uses the [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs/) tool to generate documentation. Each resource and data source requires a [templates](https://github.com/hashicorp/terraform-provider-boundary/tree/main/templates) and [examples](https://github.com/hashicorp/terraform-provider-boundary/tree/main/examples) then you execute a binary generate the docs which are placed in [./docs](https://github.com/hashicorp/terraform-provider-boundary/tree/main/docs).

### New Resources & Data Sources (documentation templates)

If you're adding a new resource or a data source, you must include a documentation template for your new R/DS in [./templates](https://github.com/hashicorp/terraform-provider-boundary/tree/main/templates) directory. This provider uses the [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs/) tool to generate documentation. For full details see the link.

### Documentation Examples for Resources & Data Sources

Examples are required for all resources and data sources. This provider uses the [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs/) tool to generate documentation. To add examples, add a new file to the [./examples](https://github.com/hashicorp/terraform-provider-boundary/tree/main/examples) directory or update the existing files. Next make sure the corresponding template in [./templates](https://github.com/hashicorp/terraform-provider-boundary/tree/main/templates) directory references this example.

### Generating

From the root of the repo run:

```
```shell
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
```

Using the provider
----------------------
## Using the provider

Please see our detailed docs for individual resource usage. Below is a complex example using the Boundary provider to configure all resource types available:

```hcl
Expand Down Expand Up @@ -140,7 +150,7 @@ resource "boundary_user" "users" {
scope_id = boundary_scope.corp.id
}

// organization level group for readonly users
// organization level group for readonly users
resource "boundary_group" "readonly" {
name = "readonly"
description = "Organization group for readonly users"
Expand Down
6 changes: 3 additions & 3 deletions docs/data-sources/scope.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "boundary_scope Data Source - terraform-provider-boundary"
subcategory: ""
description: |-
Expand All @@ -9,18 +8,19 @@ description: |-
# boundary_scope (Data Source)

The scope data source allows you to discover an existing Boundary scope by name.
Please note that the Global scope will always have an id of "global", and does not need to be discovered with this data source.

## Example Usage

```terraform
# Retrieve the ID of a Boundary project
data "boundary_scope" "org" {
name = "SecOps"
name = "SecOps"
parent_scope_id = "global"
}

data "boundary_scope" "project" {
name = "2111"
name = "2111"
parent_scope_id = data.boundary_scope.id
}
```
Expand Down
64 changes: 64 additions & 0 deletions docs/data-sources/user.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
page_title: "boundary_user Data Source - terraform-provider-boundary"
subcategory: ""
description: |-
The user data source allows you to find a Boundary user.
---

# boundary_user (Data Source)

The user data source allows you to find a Boundary user.

## Example Usage

```terraform
# Retrieve a user from the global scope

data "boundary_user" "global_scope_admin" {
name = "admin"
}

# User from a org scope

data "boundary_user" "org_user" {
name = "username"
scope_id = data.boundary_scope.org.id
}

data "boundary_scope" "org" {
name = "my-org"
parent_scope_id = data.boundary_scope.org.id
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The username to search for.

### Optional

- `scope_id` (String) The scope ID in which the resource is created. Defaults `global` if unset.

### Read-Only

- `account_ids` (Set of String) Account ID's to associate with this user resource.
- `authorized_actions` (List of String) A list of actions that the worker is entitled to perform.
- `description` (String) The user description.
- `id` (String) The ID of the user.
- `login_name` (String) Login name for user.
- `primary_account_id` (String) Primary account ID.
- `scope` (List of Object) (see [below for nested schema](#nestedatt--scope))

<a id="nestedatt--scope"></a>
### Nested Schema for `scope`

Read-Only:

- `description` (String)
- `id` (String)
- `name` (String)
- `parent_scope_id` (String)
- `type` (String)
6 changes: 3 additions & 3 deletions examples/data-sources/boundary_scope/data-source.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Retrieve the ID of a Boundary project
data "boundary_scope" "org" {
name = "SecOps"
name = "SecOps"
parent_scope_id = "global"
}

data "boundary_scope" "project" {
name = "2111"
name = "2111"
parent_scope_id = data.boundary_scope.id
}
}
17 changes: 17 additions & 0 deletions examples/data-sources/boundary_user/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Retrieve a user from the global scope

data "boundary_user" "global_scope_admin" {
name = "admin"
}

# User from a org scope

data "boundary_user" "org_user" {
name = "username"
scope_id = data.boundary_scope.org.id
}

data "boundary_scope" "org" {
name = "my-org"
parent_scope_id = data.boundary_scope.org.id
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/hashicorp/terraform-provider-boundary
go 1.21

require (
github.com/YakDriver/regexache v0.23.0
github.com/hashicorp/boundary v0.13.1-0.20231012004550-1ed0a13004b9
github.com/hashicorp/boundary/api v0.0.41
github.com/hashicorp/boundary/sdk v0.0.37
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEV
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 h1:KLq8BE0KwCL+mmXnjLWEAOYO+2l2AE4YMmqG1ZpZHBs=
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/YakDriver/regexache v0.23.0 h1:kv3j4XKhbx/vqUilSBgizXDUXHvvH1KdYekdmGwz4C4=
github.com/YakDriver/regexache v0.23.0/go.mod h1:K4BZ3MYKAqSFbYWqmbsG+OzYUDyJjnMEr27DJEsVG3U=
github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ=
github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ const (
internalForceUpdateKey = "internal_force_update"
// workerFilter is used for common "worker_filter" resource attribute
WorkerFilterKey = "worker_filter"
// common User arguments
LoginNameKey = "login_name"
PrimaryAccountID = "primary_account_id"
ScopeKey = "scope"
ParentScopeId = "parent_scope_id"
)
Loading
Loading