Skip to content

Commit

Permalink
bug(kms): Add support for all Boundary supported KMSes
Browse files Browse the repository at this point in the history
After moving to go-kms-wrapping V2, the Boundary Terraform Provider
did not load all KMS plugins resulting in an error when trying to
create a wrapper for any type other than aead:

    Error: error reading wrappers from "recovery_kms_hcl":
    Error configuring kms: plugin is nil
  • Loading branch information
louisruch committed Jun 1, 2022
1 parent 9acb1b6 commit 3176a33
Show file tree
Hide file tree
Showing 28 changed files with 2,429 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ website/vendor

# Keep windows files with windows line endings
*.winfile eol=crlf

# Compilation outputs
/plugins/kms/assets/boundary-plugin*
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## Next

### Bug Fixes

* After moving to go-kms-wrapping V2, the Boundary Terraform Provider
did not load all KMS plugins resulting in an error when trying to
create a wrapper for any type other than 'aead':

Error: error reading wrappers from "recovery_kms_hcl":
Error configuring kms: plugin is nil
([Issue](https://github.com/hashicorp/terraform-provider-boundary/issues/209)),
([PR](https://github.com/hashicorp/terraform-provider-boundary/pull/70)).


## 1.0.7 (May 16, 2022)

### Deprecations/Changes
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ install-go: ~/.go/bin/go
./ci/goinstall.sh

dev:
./scripts/plugins.sh
mkdir -p $(INSTALL_PATH)
go build -o $(INSTALL_PATH)/terraform-provider-boundary main.go

dev-no-plugins:
mkdir -p $(INSTALL_PATH)
go build -o $(INSTALL_PATH)/terraform-provider-boundary main.go

Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (

"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/authmethods"
kms_plugin_assets "github.com/hashicorp/boundary/plugins/kms"
"github.com/hashicorp/boundary/sdk/wrapper"
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
"github.com/hashicorp/go-secure-stdlib/configutil/v2"
"github.com/hashicorp/go-secure-stdlib/pluginutil/v2"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-boundary/plugins/kms"
)

func init() {
Expand Down
6 changes: 6 additions & 0 deletions plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Boundary External Plugins Modules

The Go modules under `plugins` are not intended to be used directly. They are
here purely to allow compilation of the various plugins Boundary supports
without pulling the dependencies (and any clashes, and any init behavior)
directly into Boundary.
21 changes: 21 additions & 0 deletions plugins/kms/assets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package kms_plugin_assets

import (
"embed"
"io/fs"
)

const contentDir = "assets"

// content is our static web server content.
//go:embed assets
var content embed.FS

func FileSystem() fs.FS {
// Remove the root
f, err := fs.Sub(content, contentDir)
if err != nil {
panic(err)
}
return f
}
3 changes: 3 additions & 0 deletions plugins/kms/assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains assets for kms plugins. This file in particular exists
so that the Go embed package does not throw errors when importing this module
outside of the main tree.
14 changes: 14 additions & 0 deletions plugins/kms/builtin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package kms_plugin_assets

import (
"github.com/hashicorp/go-kms-wrapping/v2/aead"
"github.com/hashicorp/go-secure-stdlib/pluginutil/v2"
)

func BuiltinKmsPlugins() map[string]pluginutil.InmemCreationFunc {
return map[string]pluginutil.InmemCreationFunc{
"aead": func() (interface{}, error) {
return aead.NewWrapper(), nil
},
}
}
3 changes: 3 additions & 0 deletions plugins/kms/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package kms_plugin_assets

const KmsPluginPrefix = "boundary-plugin-kms-"
40 changes: 40 additions & 0 deletions plugins/kms/mains/alicloudkms/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module github.com/hashicorp/boundary/plugins/kms/mains/alicloudkms

go 1.17

require (
github.com/hashicorp/go-kms-wrapping/plugin/v2 v2.0.0
github.com/hashicorp/go-kms-wrapping/wrappers/alicloudkms/v2 v2.0.1
)

require (
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1499 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/hashicorp/go-hclog v1.1.0 // indirect
github.com/hashicorp/go-kms-wrapping/v2 v2.0.0 // indirect
github.com/hashicorp/go-plugin v1.4.3 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.9 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/stretchr/testify v1.7.0 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220114231437-d2e6a121cae0 // indirect
google.golang.org/grpc v1.44.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
Loading

0 comments on commit 3176a33

Please sign in to comment.