/
projectIpWhitelist.go
421 lines (361 loc) · 16.6 KB
/
projectIpWhitelist.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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package mongodbatlas
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// `ProjectIpWhitelist` provides an IP Whitelist entry resource. The whitelist grants access from IPs, CIDRs or AWS Security Groups (if VPC Peering is enabled) to clusters within the Project.
//
// > **IMPORTANT:**
// Recently we have made changes to modernize the terminology we use in Atlas. The term “Whitelist” has been deprecated in favor of “Access List”. The Project IP whitelist resource has been deprecated and will be disabled in June 2021. Please move to using the [Project IP Access List](https://tf-registry.herokuapp.com/providers/mongodb/mongodbatlas/latest/docs/resources/project_ip_access_list) resource before June 2021.
//
// > **NOTE:** Groups and projects are synonymous terms. You may find `groupId` in the official documentation.ß
//
// > **IMPORTANT:**
// When you remove an entry from the whitelist, existing connections from the removed address(es) may remain open for a variable amount of time. How much time passes before Atlas closes the connection depends on several factors, including how the connection was established, the particular behavior of the application or driver using the address, and the connection protocol (e.g., TCP or UDP). This is particularly important to consider when changing an existing IP address or CIDR block as they cannot be updated via the Provider (comments can however), hence a change will force the destruction and recreation of entries.
//
// ## Example Usage
// ### Using CIDR Block
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-mongodbatlas/sdk/go/mongodbatlas"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := mongodbatlas.NewProjectIpWhitelist(ctx, "test", &mongodbatlas.ProjectIpWhitelistArgs{
// CidrBlock: pulumi.String("1.2.3.4/32"),
// Comment: pulumi.String("cidr block for tf acc testing"),
// ProjectId: pulumi.String("<PROJECT-ID>"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// ### Using IP Address
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-mongodbatlas/sdk/go/mongodbatlas"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := mongodbatlas.NewProjectIpWhitelist(ctx, "test", &mongodbatlas.ProjectIpWhitelistArgs{
// Comment: pulumi.String("ip address for tf acc testing"),
// IpAddress: pulumi.String("2.3.4.5"),
// ProjectId: pulumi.String("<PROJECT-ID>"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// ### Using an AWS Security Group
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-mongodbatlas/sdk/go/mongodbatlas"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// testNetworkContainer, err := mongodbatlas.NewNetworkContainer(ctx, "testNetworkContainer", &mongodbatlas.NetworkContainerArgs{
// ProjectId: pulumi.String("<PROJECT-ID>"),
// AtlasCidrBlock: pulumi.String("192.168.208.0/21"),
// ProviderName: pulumi.String("AWS"),
// RegionName: pulumi.String("US_EAST_1"),
// })
// if err != nil {
// return err
// }
// _, err = mongodbatlas.NewNetworkPeering(ctx, "testNetworkPeering", &mongodbatlas.NetworkPeeringArgs{
// ProjectId: pulumi.String("<PROJECT-ID>"),
// ContainerId: testNetworkContainer.ContainerId,
// AccepterRegionName: pulumi.String("us-east-1"),
// ProviderName: pulumi.String("AWS"),
// RouteTableCidrBlock: pulumi.String("172.31.0.0/16"),
// VpcId: pulumi.String("vpc-0d93d6f69f1578bd8"),
// AwsAccountId: pulumi.String("232589400519"),
// })
// if err != nil {
// return err
// }
// _, err = mongodbatlas.NewProjectIpWhitelist(ctx, "testProjectIpWhitelist", &mongodbatlas.ProjectIpWhitelistArgs{
// ProjectId: pulumi.String("<PROJECT-ID>"),
// AwsSecurityGroup: pulumi.String("sg-0026348ec11780bd1"),
// Comment: pulumi.String("TestAcc for awsSecurityGroup"),
// }, pulumi.DependsOn([]pulumi.Resource{
// "mongodbatlas_network_peering.test",
// }))
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// > **IMPORTANT:** In order to use AWS Security Group(s) VPC Peering must be enabled like above example.
//
// ## Import
//
// IP Whitelist entries can be imported using the `project_id` and `cidr_block` or `ip_address`, e.g.
//
// ```sh
// $ pulumi import mongodbatlas:index/projectIpWhitelist:ProjectIpWhitelist test 5d0f1f74cf09a29120e123cd-10.242.88.0/21
// ```
//
// For more information see[MongoDB Atlas API Reference.](https://docs.atlas.mongodb.com/reference/api/whitelist/)
type ProjectIpWhitelist struct {
pulumi.CustomResourceState
// ID of the whitelisted AWS security group. Mutually exclusive with `cidrBlock` and `ipAddress`.
AwsSecurityGroup pulumi.StringOutput `pulumi:"awsSecurityGroup"`
// Whitelist entry in Classless Inter-Domain Routing (CIDR) notation. Mutually exclusive with `awsSecurityGroup` and `ipAddress`.
CidrBlock pulumi.StringOutput `pulumi:"cidrBlock"`
// Comment to add to the whitelist entry.
Comment pulumi.StringOutput `pulumi:"comment"`
// Whitelisted IP address. Mutually exclusive with `awsSecurityGroup` and `cidrBlock`.
IpAddress pulumi.StringOutput `pulumi:"ipAddress"`
// The ID of the project in which to add the whitelist entry.
ProjectId pulumi.StringOutput `pulumi:"projectId"`
}
// NewProjectIpWhitelist registers a new resource with the given unique name, arguments, and options.
func NewProjectIpWhitelist(ctx *pulumi.Context,
name string, args *ProjectIpWhitelistArgs, opts ...pulumi.ResourceOption) (*ProjectIpWhitelist, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.ProjectId == nil {
return nil, errors.New("invalid value for required argument 'ProjectId'")
}
var resource ProjectIpWhitelist
err := ctx.RegisterResource("mongodbatlas:index/projectIpWhitelist:ProjectIpWhitelist", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetProjectIpWhitelist gets an existing ProjectIpWhitelist resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetProjectIpWhitelist(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ProjectIpWhitelistState, opts ...pulumi.ResourceOption) (*ProjectIpWhitelist, error) {
var resource ProjectIpWhitelist
err := ctx.ReadResource("mongodbatlas:index/projectIpWhitelist:ProjectIpWhitelist", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ProjectIpWhitelist resources.
type projectIpWhitelistState struct {
// ID of the whitelisted AWS security group. Mutually exclusive with `cidrBlock` and `ipAddress`.
AwsSecurityGroup *string `pulumi:"awsSecurityGroup"`
// Whitelist entry in Classless Inter-Domain Routing (CIDR) notation. Mutually exclusive with `awsSecurityGroup` and `ipAddress`.
CidrBlock *string `pulumi:"cidrBlock"`
// Comment to add to the whitelist entry.
Comment *string `pulumi:"comment"`
// Whitelisted IP address. Mutually exclusive with `awsSecurityGroup` and `cidrBlock`.
IpAddress *string `pulumi:"ipAddress"`
// The ID of the project in which to add the whitelist entry.
ProjectId *string `pulumi:"projectId"`
}
type ProjectIpWhitelistState struct {
// ID of the whitelisted AWS security group. Mutually exclusive with `cidrBlock` and `ipAddress`.
AwsSecurityGroup pulumi.StringPtrInput
// Whitelist entry in Classless Inter-Domain Routing (CIDR) notation. Mutually exclusive with `awsSecurityGroup` and `ipAddress`.
CidrBlock pulumi.StringPtrInput
// Comment to add to the whitelist entry.
Comment pulumi.StringPtrInput
// Whitelisted IP address. Mutually exclusive with `awsSecurityGroup` and `cidrBlock`.
IpAddress pulumi.StringPtrInput
// The ID of the project in which to add the whitelist entry.
ProjectId pulumi.StringPtrInput
}
func (ProjectIpWhitelistState) ElementType() reflect.Type {
return reflect.TypeOf((*projectIpWhitelistState)(nil)).Elem()
}
type projectIpWhitelistArgs struct {
// ID of the whitelisted AWS security group. Mutually exclusive with `cidrBlock` and `ipAddress`.
AwsSecurityGroup *string `pulumi:"awsSecurityGroup"`
// Whitelist entry in Classless Inter-Domain Routing (CIDR) notation. Mutually exclusive with `awsSecurityGroup` and `ipAddress`.
CidrBlock *string `pulumi:"cidrBlock"`
// Comment to add to the whitelist entry.
Comment *string `pulumi:"comment"`
// Whitelisted IP address. Mutually exclusive with `awsSecurityGroup` and `cidrBlock`.
IpAddress *string `pulumi:"ipAddress"`
// The ID of the project in which to add the whitelist entry.
ProjectId string `pulumi:"projectId"`
}
// The set of arguments for constructing a ProjectIpWhitelist resource.
type ProjectIpWhitelistArgs struct {
// ID of the whitelisted AWS security group. Mutually exclusive with `cidrBlock` and `ipAddress`.
AwsSecurityGroup pulumi.StringPtrInput
// Whitelist entry in Classless Inter-Domain Routing (CIDR) notation. Mutually exclusive with `awsSecurityGroup` and `ipAddress`.
CidrBlock pulumi.StringPtrInput
// Comment to add to the whitelist entry.
Comment pulumi.StringPtrInput
// Whitelisted IP address. Mutually exclusive with `awsSecurityGroup` and `cidrBlock`.
IpAddress pulumi.StringPtrInput
// The ID of the project in which to add the whitelist entry.
ProjectId pulumi.StringInput
}
func (ProjectIpWhitelistArgs) ElementType() reflect.Type {
return reflect.TypeOf((*projectIpWhitelistArgs)(nil)).Elem()
}
type ProjectIpWhitelistInput interface {
pulumi.Input
ToProjectIpWhitelistOutput() ProjectIpWhitelistOutput
ToProjectIpWhitelistOutputWithContext(ctx context.Context) ProjectIpWhitelistOutput
}
func (*ProjectIpWhitelist) ElementType() reflect.Type {
return reflect.TypeOf((*ProjectIpWhitelist)(nil))
}
func (i *ProjectIpWhitelist) ToProjectIpWhitelistOutput() ProjectIpWhitelistOutput {
return i.ToProjectIpWhitelistOutputWithContext(context.Background())
}
func (i *ProjectIpWhitelist) ToProjectIpWhitelistOutputWithContext(ctx context.Context) ProjectIpWhitelistOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectIpWhitelistOutput)
}
func (i *ProjectIpWhitelist) ToProjectIpWhitelistPtrOutput() ProjectIpWhitelistPtrOutput {
return i.ToProjectIpWhitelistPtrOutputWithContext(context.Background())
}
func (i *ProjectIpWhitelist) ToProjectIpWhitelistPtrOutputWithContext(ctx context.Context) ProjectIpWhitelistPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectIpWhitelistPtrOutput)
}
type ProjectIpWhitelistPtrInput interface {
pulumi.Input
ToProjectIpWhitelistPtrOutput() ProjectIpWhitelistPtrOutput
ToProjectIpWhitelistPtrOutputWithContext(ctx context.Context) ProjectIpWhitelistPtrOutput
}
type projectIpWhitelistPtrType ProjectIpWhitelistArgs
func (*projectIpWhitelistPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**ProjectIpWhitelist)(nil))
}
func (i *projectIpWhitelistPtrType) ToProjectIpWhitelistPtrOutput() ProjectIpWhitelistPtrOutput {
return i.ToProjectIpWhitelistPtrOutputWithContext(context.Background())
}
func (i *projectIpWhitelistPtrType) ToProjectIpWhitelistPtrOutputWithContext(ctx context.Context) ProjectIpWhitelistPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectIpWhitelistPtrOutput)
}
// ProjectIpWhitelistArrayInput is an input type that accepts ProjectIpWhitelistArray and ProjectIpWhitelistArrayOutput values.
// You can construct a concrete instance of `ProjectIpWhitelistArrayInput` via:
//
// ProjectIpWhitelistArray{ ProjectIpWhitelistArgs{...} }
type ProjectIpWhitelistArrayInput interface {
pulumi.Input
ToProjectIpWhitelistArrayOutput() ProjectIpWhitelistArrayOutput
ToProjectIpWhitelistArrayOutputWithContext(context.Context) ProjectIpWhitelistArrayOutput
}
type ProjectIpWhitelistArray []ProjectIpWhitelistInput
func (ProjectIpWhitelistArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*ProjectIpWhitelist)(nil))
}
func (i ProjectIpWhitelistArray) ToProjectIpWhitelistArrayOutput() ProjectIpWhitelistArrayOutput {
return i.ToProjectIpWhitelistArrayOutputWithContext(context.Background())
}
func (i ProjectIpWhitelistArray) ToProjectIpWhitelistArrayOutputWithContext(ctx context.Context) ProjectIpWhitelistArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectIpWhitelistArrayOutput)
}
// ProjectIpWhitelistMapInput is an input type that accepts ProjectIpWhitelistMap and ProjectIpWhitelistMapOutput values.
// You can construct a concrete instance of `ProjectIpWhitelistMapInput` via:
//
// ProjectIpWhitelistMap{ "key": ProjectIpWhitelistArgs{...} }
type ProjectIpWhitelistMapInput interface {
pulumi.Input
ToProjectIpWhitelistMapOutput() ProjectIpWhitelistMapOutput
ToProjectIpWhitelistMapOutputWithContext(context.Context) ProjectIpWhitelistMapOutput
}
type ProjectIpWhitelistMap map[string]ProjectIpWhitelistInput
func (ProjectIpWhitelistMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*ProjectIpWhitelist)(nil))
}
func (i ProjectIpWhitelistMap) ToProjectIpWhitelistMapOutput() ProjectIpWhitelistMapOutput {
return i.ToProjectIpWhitelistMapOutputWithContext(context.Background())
}
func (i ProjectIpWhitelistMap) ToProjectIpWhitelistMapOutputWithContext(ctx context.Context) ProjectIpWhitelistMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectIpWhitelistMapOutput)
}
type ProjectIpWhitelistOutput struct {
*pulumi.OutputState
}
func (ProjectIpWhitelistOutput) ElementType() reflect.Type {
return reflect.TypeOf((*ProjectIpWhitelist)(nil))
}
func (o ProjectIpWhitelistOutput) ToProjectIpWhitelistOutput() ProjectIpWhitelistOutput {
return o
}
func (o ProjectIpWhitelistOutput) ToProjectIpWhitelistOutputWithContext(ctx context.Context) ProjectIpWhitelistOutput {
return o
}
func (o ProjectIpWhitelistOutput) ToProjectIpWhitelistPtrOutput() ProjectIpWhitelistPtrOutput {
return o.ToProjectIpWhitelistPtrOutputWithContext(context.Background())
}
func (o ProjectIpWhitelistOutput) ToProjectIpWhitelistPtrOutputWithContext(ctx context.Context) ProjectIpWhitelistPtrOutput {
return o.ApplyT(func(v ProjectIpWhitelist) *ProjectIpWhitelist {
return &v
}).(ProjectIpWhitelistPtrOutput)
}
type ProjectIpWhitelistPtrOutput struct {
*pulumi.OutputState
}
func (ProjectIpWhitelistPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ProjectIpWhitelist)(nil))
}
func (o ProjectIpWhitelistPtrOutput) ToProjectIpWhitelistPtrOutput() ProjectIpWhitelistPtrOutput {
return o
}
func (o ProjectIpWhitelistPtrOutput) ToProjectIpWhitelistPtrOutputWithContext(ctx context.Context) ProjectIpWhitelistPtrOutput {
return o
}
type ProjectIpWhitelistArrayOutput struct{ *pulumi.OutputState }
func (ProjectIpWhitelistArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]ProjectIpWhitelist)(nil))
}
func (o ProjectIpWhitelistArrayOutput) ToProjectIpWhitelistArrayOutput() ProjectIpWhitelistArrayOutput {
return o
}
func (o ProjectIpWhitelistArrayOutput) ToProjectIpWhitelistArrayOutputWithContext(ctx context.Context) ProjectIpWhitelistArrayOutput {
return o
}
func (o ProjectIpWhitelistArrayOutput) Index(i pulumi.IntInput) ProjectIpWhitelistOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) ProjectIpWhitelist {
return vs[0].([]ProjectIpWhitelist)[vs[1].(int)]
}).(ProjectIpWhitelistOutput)
}
type ProjectIpWhitelistMapOutput struct{ *pulumi.OutputState }
func (ProjectIpWhitelistMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]ProjectIpWhitelist)(nil))
}
func (o ProjectIpWhitelistMapOutput) ToProjectIpWhitelistMapOutput() ProjectIpWhitelistMapOutput {
return o
}
func (o ProjectIpWhitelistMapOutput) ToProjectIpWhitelistMapOutputWithContext(ctx context.Context) ProjectIpWhitelistMapOutput {
return o
}
func (o ProjectIpWhitelistMapOutput) MapIndex(k pulumi.StringInput) ProjectIpWhitelistOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) ProjectIpWhitelist {
return vs[0].(map[string]ProjectIpWhitelist)[vs[1].(string)]
}).(ProjectIpWhitelistOutput)
}
func init() {
pulumi.RegisterOutputType(ProjectIpWhitelistOutput{})
pulumi.RegisterOutputType(ProjectIpWhitelistPtrOutput{})
pulumi.RegisterOutputType(ProjectIpWhitelistArrayOutput{})
pulumi.RegisterOutputType(ProjectIpWhitelistMapOutput{})
}