/
getSecret.go
214 lines (189 loc) · 8.35 KB
/
getSecret.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package generic
import (
"context"
"reflect"
"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// ## Example Usage
//
// ### Generic secret
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-vault/sdk/v6/go/vault/generic"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := generic.LookupSecret(ctx, &generic.LookupSecretArgs{
// Path: "secret/rundeck_auth",
// }, nil)
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
func LookupSecret(ctx *pulumi.Context, args *LookupSecretArgs, opts ...pulumi.InvokeOption) (*LookupSecretResult, error) {
opts = internal.PkgInvokeDefaultOpts(opts)
var rv LookupSecretResult
err := ctx.Invoke("vault:generic/getSecret:getSecret", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getSecret.
type LookupSecretArgs struct {
// The namespace of the target resource.
// The value should not contain leading or trailing forward slashes.
// The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault/index.html#namespace).
// *Available only for Vault Enterprise*.
Namespace *string `pulumi:"namespace"`
// The full logical path from which to request data.
// To read data from the "generic" secret backend mounted in Vault by
// default, this should be prefixed with `secret/`. Reading from other backends
// with this data source is possible; consult each backend's documentation
// to see which endpoints support the `GET` method.
Path string `pulumi:"path"`
// The version of the secret to read. This is used by the
// Vault KV secrets engine - version 2 to indicate which version of the secret
// to read.
Version *int `pulumi:"version"`
// If set to true, stores `leaseStartTime` in the TF state.
// Note that storing the `leaseStartTime` in the TF state will cause a persistent drift
// on every `pulumi preview` and will require a `pulumi up`.
WithLeaseStartTime *bool `pulumi:"withLeaseStartTime"`
}
// A collection of values returned by getSecret.
type LookupSecretResult struct {
// A mapping whose keys are the top-level data keys returned from
// Vault and whose values are the corresponding values. This map can only
// represent string data, so any non-string values returned from Vault are
// serialized as JSON.
Data map[string]interface{} `pulumi:"data"`
// A string containing the full data payload retrieved from
// Vault, serialized in JSON format.
DataJson string `pulumi:"dataJson"`
// The provider-assigned unique ID for this managed resource.
Id string `pulumi:"id"`
// The duration of the secret lease, in seconds relative
// to the time the data was requested. Once this time has passed any plan
// generated with this data may fail to apply.
LeaseDuration int `pulumi:"leaseDuration"`
// The lease identifier assigned by Vault, if any.
LeaseId string `pulumi:"leaseId"`
LeaseRenewable bool `pulumi:"leaseRenewable"`
LeaseStartTime string `pulumi:"leaseStartTime"`
Namespace *string `pulumi:"namespace"`
Path string `pulumi:"path"`
Version *int `pulumi:"version"`
WithLeaseStartTime *bool `pulumi:"withLeaseStartTime"`
}
func LookupSecretOutput(ctx *pulumi.Context, args LookupSecretOutputArgs, opts ...pulumi.InvokeOption) LookupSecretResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (LookupSecretResult, error) {
args := v.(LookupSecretArgs)
r, err := LookupSecret(ctx, &args, opts...)
var s LookupSecretResult
if r != nil {
s = *r
}
return s, err
}).(LookupSecretResultOutput)
}
// A collection of arguments for invoking getSecret.
type LookupSecretOutputArgs struct {
// The namespace of the target resource.
// The value should not contain leading or trailing forward slashes.
// The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault/index.html#namespace).
// *Available only for Vault Enterprise*.
Namespace pulumi.StringPtrInput `pulumi:"namespace"`
// The full logical path from which to request data.
// To read data from the "generic" secret backend mounted in Vault by
// default, this should be prefixed with `secret/`. Reading from other backends
// with this data source is possible; consult each backend's documentation
// to see which endpoints support the `GET` method.
Path pulumi.StringInput `pulumi:"path"`
// The version of the secret to read. This is used by the
// Vault KV secrets engine - version 2 to indicate which version of the secret
// to read.
Version pulumi.IntPtrInput `pulumi:"version"`
// If set to true, stores `leaseStartTime` in the TF state.
// Note that storing the `leaseStartTime` in the TF state will cause a persistent drift
// on every `pulumi preview` and will require a `pulumi up`.
WithLeaseStartTime pulumi.BoolPtrInput `pulumi:"withLeaseStartTime"`
}
func (LookupSecretOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*LookupSecretArgs)(nil)).Elem()
}
// A collection of values returned by getSecret.
type LookupSecretResultOutput struct{ *pulumi.OutputState }
func (LookupSecretResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*LookupSecretResult)(nil)).Elem()
}
func (o LookupSecretResultOutput) ToLookupSecretResultOutput() LookupSecretResultOutput {
return o
}
func (o LookupSecretResultOutput) ToLookupSecretResultOutputWithContext(ctx context.Context) LookupSecretResultOutput {
return o
}
// A mapping whose keys are the top-level data keys returned from
// Vault and whose values are the corresponding values. This map can only
// represent string data, so any non-string values returned from Vault are
// serialized as JSON.
func (o LookupSecretResultOutput) Data() pulumi.MapOutput {
return o.ApplyT(func(v LookupSecretResult) map[string]interface{} { return v.Data }).(pulumi.MapOutput)
}
// A string containing the full data payload retrieved from
// Vault, serialized in JSON format.
func (o LookupSecretResultOutput) DataJson() pulumi.StringOutput {
return o.ApplyT(func(v LookupSecretResult) string { return v.DataJson }).(pulumi.StringOutput)
}
// The provider-assigned unique ID for this managed resource.
func (o LookupSecretResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v LookupSecretResult) string { return v.Id }).(pulumi.StringOutput)
}
// The duration of the secret lease, in seconds relative
// to the time the data was requested. Once this time has passed any plan
// generated with this data may fail to apply.
func (o LookupSecretResultOutput) LeaseDuration() pulumi.IntOutput {
return o.ApplyT(func(v LookupSecretResult) int { return v.LeaseDuration }).(pulumi.IntOutput)
}
// The lease identifier assigned by Vault, if any.
func (o LookupSecretResultOutput) LeaseId() pulumi.StringOutput {
return o.ApplyT(func(v LookupSecretResult) string { return v.LeaseId }).(pulumi.StringOutput)
}
func (o LookupSecretResultOutput) LeaseRenewable() pulumi.BoolOutput {
return o.ApplyT(func(v LookupSecretResult) bool { return v.LeaseRenewable }).(pulumi.BoolOutput)
}
func (o LookupSecretResultOutput) LeaseStartTime() pulumi.StringOutput {
return o.ApplyT(func(v LookupSecretResult) string { return v.LeaseStartTime }).(pulumi.StringOutput)
}
func (o LookupSecretResultOutput) Namespace() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupSecretResult) *string { return v.Namespace }).(pulumi.StringPtrOutput)
}
func (o LookupSecretResultOutput) Path() pulumi.StringOutput {
return o.ApplyT(func(v LookupSecretResult) string { return v.Path }).(pulumi.StringOutput)
}
func (o LookupSecretResultOutput) Version() pulumi.IntPtrOutput {
return o.ApplyT(func(v LookupSecretResult) *int { return v.Version }).(pulumi.IntPtrOutput)
}
func (o LookupSecretResultOutput) WithLeaseStartTime() pulumi.BoolPtrOutput {
return o.ApplyT(func(v LookupSecretResult) *bool { return v.WithLeaseStartTime }).(pulumi.BoolPtrOutput)
}
func init() {
pulumi.RegisterOutputType(LookupSecretResultOutput{})
}