/
provider.go
284 lines (251 loc) · 12.5 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
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
// 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 postgresql
import (
"context"
"reflect"
"github.com/pulumi/pulumi-postgresql/sdk/v3/go/postgresql/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// The provider type for the postgresql package. By default, resources use package-wide configuration
// settings, however an explicit `Provider` instance may be created and passed during resource
// construction to achieve fine-grained programmatic control over provider settings. See the
// [documentation](https://www.pulumi.com/docs/reference/programming-model/#providers) for more information.
type Provider struct {
pulumi.ProviderResourceState
// AWS profile to use for IAM auth
AwsRdsIamProfile pulumi.StringPtrOutput `pulumi:"awsRdsIamProfile"`
// AWS region to use for IAM auth
AwsRdsIamRegion pulumi.StringPtrOutput `pulumi:"awsRdsIamRegion"`
// MS Azure tenant ID (see:
// https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config.html)
AzureTenantId pulumi.StringPtrOutput `pulumi:"azureTenantId"`
// The name of the database to connect to in order to conenct to (defaults to `postgres`).
Database pulumi.StringPtrOutput `pulumi:"database"`
// Database username associated to the connected user (for user name maps)
DatabaseUsername pulumi.StringPtrOutput `pulumi:"databaseUsername"`
// Specify the expected version of PostgreSQL.
ExpectedVersion pulumi.StringPtrOutput `pulumi:"expectedVersion"`
// Name of PostgreSQL server address to connect to
Host pulumi.StringPtrOutput `pulumi:"host"`
// Password to be used if the PostgreSQL server demands password authentication
Password pulumi.StringPtrOutput `pulumi:"password"`
Scheme pulumi.StringPtrOutput `pulumi:"scheme"`
// Deprecated: Rename PostgreSQL provider `ssl_mode` attribute to `sslmode`
SslMode pulumi.StringPtrOutput `pulumi:"sslMode"`
// This option determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the
// PostgreSQL server
Sslmode pulumi.StringPtrOutput `pulumi:"sslmode"`
// The SSL server root certificate file path. The file must contain PEM encoded data.
Sslrootcert pulumi.StringPtrOutput `pulumi:"sslrootcert"`
// PostgreSQL user name to connect as
Username pulumi.StringPtrOutput `pulumi:"username"`
}
// NewProvider registers a new resource with the given unique name, arguments, and options.
func NewProvider(ctx *pulumi.Context,
name string, args *ProviderArgs, opts ...pulumi.ResourceOption) (*Provider, error) {
if args == nil {
args = &ProviderArgs{}
}
if args.ConnectTimeout == nil {
if d := internal.GetEnvOrDefault(180, internal.ParseEnvInt, "PGCONNECT_TIMEOUT"); d != nil {
args.ConnectTimeout = pulumi.IntPtr(d.(int))
}
}
if args.Sslmode == nil {
if d := internal.GetEnvOrDefault(nil, nil, "PGSSLMODE"); d != nil {
args.Sslmode = pulumi.StringPtr(d.(string))
}
}
if args.Password != nil {
args.Password = pulumi.ToSecret(args.Password).(pulumi.StringPtrInput)
}
secrets := pulumi.AdditionalSecretOutputs([]string{
"password",
})
opts = append(opts, secrets)
opts = internal.PkgResourceDefaultOpts(opts)
var resource Provider
err := ctx.RegisterResource("pulumi:providers:postgresql", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
type providerArgs struct {
// Use rds_iam instead of password authentication (see:
// https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html)
AwsRdsIamAuth *bool `pulumi:"awsRdsIamAuth"`
// AWS profile to use for IAM auth
AwsRdsIamProfile *string `pulumi:"awsRdsIamProfile"`
// AWS region to use for IAM auth
AwsRdsIamRegion *string `pulumi:"awsRdsIamRegion"`
// Use MS Azure identity OAuth token (see:
// https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-configure-sign-in-azure-ad-authentication)
AzureIdentityAuth *bool `pulumi:"azureIdentityAuth"`
// MS Azure tenant ID (see:
// https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config.html)
AzureTenantId *string `pulumi:"azureTenantId"`
// SSL client certificate if required by the database.
Clientcert *ProviderClientcert `pulumi:"clientcert"`
// Maximum wait for connection, in seconds. Zero or not specified means wait indefinitely.
ConnectTimeout *int `pulumi:"connectTimeout"`
// The name of the database to connect to in order to conenct to (defaults to `postgres`).
Database *string `pulumi:"database"`
// Database username associated to the connected user (for user name maps)
DatabaseUsername *string `pulumi:"databaseUsername"`
// Specify the expected version of PostgreSQL.
ExpectedVersion *string `pulumi:"expectedVersion"`
// Name of PostgreSQL server address to connect to
Host *string `pulumi:"host"`
// Maximum number of connections to establish to the database. Zero means unlimited.
MaxConnections *int `pulumi:"maxConnections"`
// Password to be used if the PostgreSQL server demands password authentication
Password *string `pulumi:"password"`
// The PostgreSQL port number to connect to at the server host, or socket file name extension for Unix-domain connections
Port *int `pulumi:"port"`
Scheme *string `pulumi:"scheme"`
// Deprecated: Rename PostgreSQL provider `ssl_mode` attribute to `sslmode`
SslMode *string `pulumi:"sslMode"`
// This option determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the
// PostgreSQL server
Sslmode *string `pulumi:"sslmode"`
// The SSL server root certificate file path. The file must contain PEM encoded data.
Sslrootcert *string `pulumi:"sslrootcert"`
// Specify if the user to connect as is a Postgres superuser or not.If not, some feature might be disabled (e.g.:
// Refreshing state password from Postgres)
Superuser *bool `pulumi:"superuser"`
// PostgreSQL user name to connect as
Username *string `pulumi:"username"`
}
// The set of arguments for constructing a Provider resource.
type ProviderArgs struct {
// Use rds_iam instead of password authentication (see:
// https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html)
AwsRdsIamAuth pulumi.BoolPtrInput
// AWS profile to use for IAM auth
AwsRdsIamProfile pulumi.StringPtrInput
// AWS region to use for IAM auth
AwsRdsIamRegion pulumi.StringPtrInput
// Use MS Azure identity OAuth token (see:
// https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-configure-sign-in-azure-ad-authentication)
AzureIdentityAuth pulumi.BoolPtrInput
// MS Azure tenant ID (see:
// https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config.html)
AzureTenantId pulumi.StringPtrInput
// SSL client certificate if required by the database.
Clientcert ProviderClientcertPtrInput
// Maximum wait for connection, in seconds. Zero or not specified means wait indefinitely.
ConnectTimeout pulumi.IntPtrInput
// The name of the database to connect to in order to conenct to (defaults to `postgres`).
Database pulumi.StringPtrInput
// Database username associated to the connected user (for user name maps)
DatabaseUsername pulumi.StringPtrInput
// Specify the expected version of PostgreSQL.
ExpectedVersion pulumi.StringPtrInput
// Name of PostgreSQL server address to connect to
Host pulumi.StringPtrInput
// Maximum number of connections to establish to the database. Zero means unlimited.
MaxConnections pulumi.IntPtrInput
// Password to be used if the PostgreSQL server demands password authentication
Password pulumi.StringPtrInput
// The PostgreSQL port number to connect to at the server host, or socket file name extension for Unix-domain connections
Port pulumi.IntPtrInput
Scheme pulumi.StringPtrInput
// Deprecated: Rename PostgreSQL provider `ssl_mode` attribute to `sslmode`
SslMode pulumi.StringPtrInput
// This option determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the
// PostgreSQL server
Sslmode pulumi.StringPtrInput
// The SSL server root certificate file path. The file must contain PEM encoded data.
Sslrootcert pulumi.StringPtrInput
// Specify if the user to connect as is a Postgres superuser or not.If not, some feature might be disabled (e.g.:
// Refreshing state password from Postgres)
Superuser pulumi.BoolPtrInput
// PostgreSQL user name to connect as
Username pulumi.StringPtrInput
}
func (ProviderArgs) ElementType() reflect.Type {
return reflect.TypeOf((*providerArgs)(nil)).Elem()
}
type ProviderInput interface {
pulumi.Input
ToProviderOutput() ProviderOutput
ToProviderOutputWithContext(ctx context.Context) ProviderOutput
}
func (*Provider) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil)).Elem()
}
func (i *Provider) ToProviderOutput() ProviderOutput {
return i.ToProviderOutputWithContext(context.Background())
}
func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput)
}
type ProviderOutput struct{ *pulumi.OutputState }
func (ProviderOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil)).Elem()
}
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
return o
}
func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) ProviderOutput {
return o
}
// AWS profile to use for IAM auth
func (o ProviderOutput) AwsRdsIamProfile() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.AwsRdsIamProfile }).(pulumi.StringPtrOutput)
}
// AWS region to use for IAM auth
func (o ProviderOutput) AwsRdsIamRegion() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.AwsRdsIamRegion }).(pulumi.StringPtrOutput)
}
// MS Azure tenant ID (see:
// https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config.html)
func (o ProviderOutput) AzureTenantId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.AzureTenantId }).(pulumi.StringPtrOutput)
}
// The name of the database to connect to in order to conenct to (defaults to `postgres`).
func (o ProviderOutput) Database() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.Database }).(pulumi.StringPtrOutput)
}
// Database username associated to the connected user (for user name maps)
func (o ProviderOutput) DatabaseUsername() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.DatabaseUsername }).(pulumi.StringPtrOutput)
}
// Specify the expected version of PostgreSQL.
func (o ProviderOutput) ExpectedVersion() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.ExpectedVersion }).(pulumi.StringPtrOutput)
}
// Name of PostgreSQL server address to connect to
func (o ProviderOutput) Host() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.Host }).(pulumi.StringPtrOutput)
}
// Password to be used if the PostgreSQL server demands password authentication
func (o ProviderOutput) Password() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.Password }).(pulumi.StringPtrOutput)
}
func (o ProviderOutput) Scheme() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.Scheme }).(pulumi.StringPtrOutput)
}
// Deprecated: Rename PostgreSQL provider `ssl_mode` attribute to `sslmode`
func (o ProviderOutput) SslMode() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.SslMode }).(pulumi.StringPtrOutput)
}
// This option determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the
// PostgreSQL server
func (o ProviderOutput) Sslmode() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.Sslmode }).(pulumi.StringPtrOutput)
}
// The SSL server root certificate file path. The file must contain PEM encoded data.
func (o ProviderOutput) Sslrootcert() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.Sslrootcert }).(pulumi.StringPtrOutput)
}
// PostgreSQL user name to connect as
func (o ProviderOutput) Username() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.Username }).(pulumi.StringPtrOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{})
pulumi.RegisterOutputType(ProviderOutput{})
}