-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprovider.go
52 lines (47 loc) · 1.25 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
)
// provider.go
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"directory_path": {
Type: schema.TypeString,
Required: true,
Description: "The path to the directory where secrets should be saved.",
},
"aws_profile": {
Type: schema.TypeString,
Required: true,
Description: "AWS profile to use for secrets",
},
},
ResourcesMap: map[string]*schema.Resource{
"parameters-manager_secrets": resourceSecrets(),
"parameters-manager_parameters": resourceParameters(),
},
ConfigureFunc: providerConfigure,
}
}
// providerConfigure returns the configuration for the provider.
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := Config{
DirectoryPath: d.Get("directory_path").(string),
AwsProfile: d.Get("aws_profile").(string),
}
return &config, nil
}
// Config struct holds provider configuration.
type Config struct {
DirectoryPath string
AwsProfile string
}
func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: func() *schema.Provider {
return Provider()
},
})
}