-
Notifications
You must be signed in to change notification settings - Fork 151
/
vpcPeeringConnectionAccepter.go
438 lines (378 loc) · 18.9 KB
/
vpcPeeringConnectionAccepter.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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
// *** 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 ec2
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a resource to manage the accepter's side of a VPC Peering Connection.
//
// When a cross-account (requester's AWS account differs from the accepter's AWS account) or an inter-region
// VPC Peering Connection is created, a VPC Peering Connection resource is automatically created in the
// accepter's account.
// The requester can use the `ec2.VpcPeeringConnection` resource to manage its side of the connection
// and the accepter can use the `ec2.VpcPeeringConnectionAccepter` resource to "adopt" its side of the
// connection into management.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws"
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/providers"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := providers.Newaws(ctx, "peer", &providers.awsArgs{
// Region: pulumi.String("us-west-2"),
// })
// if err != nil {
// return err
// }
// main, err := ec2.NewVpc(ctx, "main", &ec2.VpcArgs{
// CidrBlock: pulumi.String("10.0.0.0/16"),
// })
// if err != nil {
// return err
// }
// peerVpc, err := ec2.NewVpc(ctx, "peerVpc", &ec2.VpcArgs{
// CidrBlock: pulumi.String("10.1.0.0/16"),
// }, pulumi.Provider(aws.Peer))
// if err != nil {
// return err
// }
// peerCallerIdentity, err := aws.GetCallerIdentity(ctx, nil, nil)
// if err != nil {
// return err
// }
// peerVpcPeeringConnection, err := ec2.NewVpcPeeringConnection(ctx, "peerVpcPeeringConnection", &ec2.VpcPeeringConnectionArgs{
// VpcId: main.ID(),
// PeerVpcId: peerVpc.ID(),
// PeerOwnerId: pulumi.String(peerCallerIdentity.AccountId),
// PeerRegion: pulumi.String("us-west-2"),
// AutoAccept: pulumi.Bool(false),
// Tags: pulumi.StringMap{
// "Side": pulumi.String("Requester"),
// },
// })
// if err != nil {
// return err
// }
// _, err = ec2.NewVpcPeeringConnectionAccepter(ctx, "peerVpcPeeringConnectionAccepter", &ec2.VpcPeeringConnectionAccepterArgs{
// VpcPeeringConnectionId: peerVpcPeeringConnection.ID(),
// AutoAccept: pulumi.Bool(true),
// Tags: pulumi.StringMap{
// "Side": pulumi.String("Accepter"),
// },
// }, pulumi.Provider(aws.Peer))
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// VPC Peering Connection Accepters can be imported by using the Peering Connection ID, e.g.
//
// ```sh
// $ pulumi import aws:ec2/vpcPeeringConnectionAccepter:VpcPeeringConnectionAccepter example pcx-12345678
// ```
//
// Certain resource arguments, like `auto_accept`, do not have an EC2 API method for reading the information after peering connection creation. If the argument is set in the provider configuration on an imported resource, this provder will always show a difference. To workaround this behavior, either omit the argument from the configuration or use [`ignoreChanges`](https://www.pulumi.com/docs/intro/concepts/programming-model/#ignorechanges) to hide the difference, e.g. terraform resource "aws_vpc_peering_connection_accepter" "example" {
//
// # ... other configuration ...
//
// # There is no AWS EC2 API for reading auto_accept
//
// lifecycle {
//
// ignore_changes = [auto_accept]
//
// } }
type VpcPeeringConnectionAccepter struct {
pulumi.CustomResourceState
// The status of the VPC Peering Connection request.
AcceptStatus pulumi.StringOutput `pulumi:"acceptStatus"`
// A configuration block that describes [VPC Peering Connection]
// (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the accepter VPC.
Accepter VpcPeeringConnectionAccepterAccepterOutput `pulumi:"accepter"`
// Whether or not to accept the peering request. Defaults to `false`.
AutoAccept pulumi.BoolPtrOutput `pulumi:"autoAccept"`
// The AWS account ID of the owner of the requester VPC.
PeerOwnerId pulumi.StringOutput `pulumi:"peerOwnerId"`
// The region of the accepter VPC.
PeerRegion pulumi.StringOutput `pulumi:"peerRegion"`
// The ID of the requester VPC.
PeerVpcId pulumi.StringOutput `pulumi:"peerVpcId"`
// A configuration block that describes [VPC Peering Connection]
// (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the requester VPC.
Requester VpcPeeringConnectionAccepterRequesterOutput `pulumi:"requester"`
// A map of tags to assign to the resource.
Tags pulumi.StringMapOutput `pulumi:"tags"`
// The ID of the accepter VPC.
VpcId pulumi.StringOutput `pulumi:"vpcId"`
// The VPC Peering Connection ID to manage.
VpcPeeringConnectionId pulumi.StringOutput `pulumi:"vpcPeeringConnectionId"`
}
// NewVpcPeeringConnectionAccepter registers a new resource with the given unique name, arguments, and options.
func NewVpcPeeringConnectionAccepter(ctx *pulumi.Context,
name string, args *VpcPeeringConnectionAccepterArgs, opts ...pulumi.ResourceOption) (*VpcPeeringConnectionAccepter, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.VpcPeeringConnectionId == nil {
return nil, errors.New("invalid value for required argument 'VpcPeeringConnectionId'")
}
var resource VpcPeeringConnectionAccepter
err := ctx.RegisterResource("aws:ec2/vpcPeeringConnectionAccepter:VpcPeeringConnectionAccepter", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetVpcPeeringConnectionAccepter gets an existing VpcPeeringConnectionAccepter 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 GetVpcPeeringConnectionAccepter(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *VpcPeeringConnectionAccepterState, opts ...pulumi.ResourceOption) (*VpcPeeringConnectionAccepter, error) {
var resource VpcPeeringConnectionAccepter
err := ctx.ReadResource("aws:ec2/vpcPeeringConnectionAccepter:VpcPeeringConnectionAccepter", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering VpcPeeringConnectionAccepter resources.
type vpcPeeringConnectionAccepterState struct {
// The status of the VPC Peering Connection request.
AcceptStatus *string `pulumi:"acceptStatus"`
// A configuration block that describes [VPC Peering Connection]
// (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the accepter VPC.
Accepter *VpcPeeringConnectionAccepterAccepter `pulumi:"accepter"`
// Whether or not to accept the peering request. Defaults to `false`.
AutoAccept *bool `pulumi:"autoAccept"`
// The AWS account ID of the owner of the requester VPC.
PeerOwnerId *string `pulumi:"peerOwnerId"`
// The region of the accepter VPC.
PeerRegion *string `pulumi:"peerRegion"`
// The ID of the requester VPC.
PeerVpcId *string `pulumi:"peerVpcId"`
// A configuration block that describes [VPC Peering Connection]
// (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the requester VPC.
Requester *VpcPeeringConnectionAccepterRequester `pulumi:"requester"`
// A map of tags to assign to the resource.
Tags map[string]string `pulumi:"tags"`
// The ID of the accepter VPC.
VpcId *string `pulumi:"vpcId"`
// The VPC Peering Connection ID to manage.
VpcPeeringConnectionId *string `pulumi:"vpcPeeringConnectionId"`
}
type VpcPeeringConnectionAccepterState struct {
// The status of the VPC Peering Connection request.
AcceptStatus pulumi.StringPtrInput
// A configuration block that describes [VPC Peering Connection]
// (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the accepter VPC.
Accepter VpcPeeringConnectionAccepterAccepterPtrInput
// Whether or not to accept the peering request. Defaults to `false`.
AutoAccept pulumi.BoolPtrInput
// The AWS account ID of the owner of the requester VPC.
PeerOwnerId pulumi.StringPtrInput
// The region of the accepter VPC.
PeerRegion pulumi.StringPtrInput
// The ID of the requester VPC.
PeerVpcId pulumi.StringPtrInput
// A configuration block that describes [VPC Peering Connection]
// (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the requester VPC.
Requester VpcPeeringConnectionAccepterRequesterPtrInput
// A map of tags to assign to the resource.
Tags pulumi.StringMapInput
// The ID of the accepter VPC.
VpcId pulumi.StringPtrInput
// The VPC Peering Connection ID to manage.
VpcPeeringConnectionId pulumi.StringPtrInput
}
func (VpcPeeringConnectionAccepterState) ElementType() reflect.Type {
return reflect.TypeOf((*vpcPeeringConnectionAccepterState)(nil)).Elem()
}
type vpcPeeringConnectionAccepterArgs struct {
// A configuration block that describes [VPC Peering Connection]
// (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the accepter VPC.
Accepter *VpcPeeringConnectionAccepterAccepter `pulumi:"accepter"`
// Whether or not to accept the peering request. Defaults to `false`.
AutoAccept *bool `pulumi:"autoAccept"`
// A configuration block that describes [VPC Peering Connection]
// (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the requester VPC.
Requester *VpcPeeringConnectionAccepterRequester `pulumi:"requester"`
// A map of tags to assign to the resource.
Tags map[string]string `pulumi:"tags"`
// The VPC Peering Connection ID to manage.
VpcPeeringConnectionId string `pulumi:"vpcPeeringConnectionId"`
}
// The set of arguments for constructing a VpcPeeringConnectionAccepter resource.
type VpcPeeringConnectionAccepterArgs struct {
// A configuration block that describes [VPC Peering Connection]
// (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the accepter VPC.
Accepter VpcPeeringConnectionAccepterAccepterPtrInput
// Whether or not to accept the peering request. Defaults to `false`.
AutoAccept pulumi.BoolPtrInput
// A configuration block that describes [VPC Peering Connection]
// (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the requester VPC.
Requester VpcPeeringConnectionAccepterRequesterPtrInput
// A map of tags to assign to the resource.
Tags pulumi.StringMapInput
// The VPC Peering Connection ID to manage.
VpcPeeringConnectionId pulumi.StringInput
}
func (VpcPeeringConnectionAccepterArgs) ElementType() reflect.Type {
return reflect.TypeOf((*vpcPeeringConnectionAccepterArgs)(nil)).Elem()
}
type VpcPeeringConnectionAccepterInput interface {
pulumi.Input
ToVpcPeeringConnectionAccepterOutput() VpcPeeringConnectionAccepterOutput
ToVpcPeeringConnectionAccepterOutputWithContext(ctx context.Context) VpcPeeringConnectionAccepterOutput
}
func (*VpcPeeringConnectionAccepter) ElementType() reflect.Type {
return reflect.TypeOf((*VpcPeeringConnectionAccepter)(nil))
}
func (i *VpcPeeringConnectionAccepter) ToVpcPeeringConnectionAccepterOutput() VpcPeeringConnectionAccepterOutput {
return i.ToVpcPeeringConnectionAccepterOutputWithContext(context.Background())
}
func (i *VpcPeeringConnectionAccepter) ToVpcPeeringConnectionAccepterOutputWithContext(ctx context.Context) VpcPeeringConnectionAccepterOutput {
return pulumi.ToOutputWithContext(ctx, i).(VpcPeeringConnectionAccepterOutput)
}
func (i *VpcPeeringConnectionAccepter) ToVpcPeeringConnectionAccepterPtrOutput() VpcPeeringConnectionAccepterPtrOutput {
return i.ToVpcPeeringConnectionAccepterPtrOutputWithContext(context.Background())
}
func (i *VpcPeeringConnectionAccepter) ToVpcPeeringConnectionAccepterPtrOutputWithContext(ctx context.Context) VpcPeeringConnectionAccepterPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(VpcPeeringConnectionAccepterPtrOutput)
}
type VpcPeeringConnectionAccepterPtrInput interface {
pulumi.Input
ToVpcPeeringConnectionAccepterPtrOutput() VpcPeeringConnectionAccepterPtrOutput
ToVpcPeeringConnectionAccepterPtrOutputWithContext(ctx context.Context) VpcPeeringConnectionAccepterPtrOutput
}
type vpcPeeringConnectionAccepterPtrType VpcPeeringConnectionAccepterArgs
func (*vpcPeeringConnectionAccepterPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**VpcPeeringConnectionAccepter)(nil))
}
func (i *vpcPeeringConnectionAccepterPtrType) ToVpcPeeringConnectionAccepterPtrOutput() VpcPeeringConnectionAccepterPtrOutput {
return i.ToVpcPeeringConnectionAccepterPtrOutputWithContext(context.Background())
}
func (i *vpcPeeringConnectionAccepterPtrType) ToVpcPeeringConnectionAccepterPtrOutputWithContext(ctx context.Context) VpcPeeringConnectionAccepterPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(VpcPeeringConnectionAccepterPtrOutput)
}
// VpcPeeringConnectionAccepterArrayInput is an input type that accepts VpcPeeringConnectionAccepterArray and VpcPeeringConnectionAccepterArrayOutput values.
// You can construct a concrete instance of `VpcPeeringConnectionAccepterArrayInput` via:
//
// VpcPeeringConnectionAccepterArray{ VpcPeeringConnectionAccepterArgs{...} }
type VpcPeeringConnectionAccepterArrayInput interface {
pulumi.Input
ToVpcPeeringConnectionAccepterArrayOutput() VpcPeeringConnectionAccepterArrayOutput
ToVpcPeeringConnectionAccepterArrayOutputWithContext(context.Context) VpcPeeringConnectionAccepterArrayOutput
}
type VpcPeeringConnectionAccepterArray []VpcPeeringConnectionAccepterInput
func (VpcPeeringConnectionAccepterArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*VpcPeeringConnectionAccepter)(nil))
}
func (i VpcPeeringConnectionAccepterArray) ToVpcPeeringConnectionAccepterArrayOutput() VpcPeeringConnectionAccepterArrayOutput {
return i.ToVpcPeeringConnectionAccepterArrayOutputWithContext(context.Background())
}
func (i VpcPeeringConnectionAccepterArray) ToVpcPeeringConnectionAccepterArrayOutputWithContext(ctx context.Context) VpcPeeringConnectionAccepterArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(VpcPeeringConnectionAccepterArrayOutput)
}
// VpcPeeringConnectionAccepterMapInput is an input type that accepts VpcPeeringConnectionAccepterMap and VpcPeeringConnectionAccepterMapOutput values.
// You can construct a concrete instance of `VpcPeeringConnectionAccepterMapInput` via:
//
// VpcPeeringConnectionAccepterMap{ "key": VpcPeeringConnectionAccepterArgs{...} }
type VpcPeeringConnectionAccepterMapInput interface {
pulumi.Input
ToVpcPeeringConnectionAccepterMapOutput() VpcPeeringConnectionAccepterMapOutput
ToVpcPeeringConnectionAccepterMapOutputWithContext(context.Context) VpcPeeringConnectionAccepterMapOutput
}
type VpcPeeringConnectionAccepterMap map[string]VpcPeeringConnectionAccepterInput
func (VpcPeeringConnectionAccepterMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*VpcPeeringConnectionAccepter)(nil))
}
func (i VpcPeeringConnectionAccepterMap) ToVpcPeeringConnectionAccepterMapOutput() VpcPeeringConnectionAccepterMapOutput {
return i.ToVpcPeeringConnectionAccepterMapOutputWithContext(context.Background())
}
func (i VpcPeeringConnectionAccepterMap) ToVpcPeeringConnectionAccepterMapOutputWithContext(ctx context.Context) VpcPeeringConnectionAccepterMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(VpcPeeringConnectionAccepterMapOutput)
}
type VpcPeeringConnectionAccepterOutput struct {
*pulumi.OutputState
}
func (VpcPeeringConnectionAccepterOutput) ElementType() reflect.Type {
return reflect.TypeOf((*VpcPeeringConnectionAccepter)(nil))
}
func (o VpcPeeringConnectionAccepterOutput) ToVpcPeeringConnectionAccepterOutput() VpcPeeringConnectionAccepterOutput {
return o
}
func (o VpcPeeringConnectionAccepterOutput) ToVpcPeeringConnectionAccepterOutputWithContext(ctx context.Context) VpcPeeringConnectionAccepterOutput {
return o
}
func (o VpcPeeringConnectionAccepterOutput) ToVpcPeeringConnectionAccepterPtrOutput() VpcPeeringConnectionAccepterPtrOutput {
return o.ToVpcPeeringConnectionAccepterPtrOutputWithContext(context.Background())
}
func (o VpcPeeringConnectionAccepterOutput) ToVpcPeeringConnectionAccepterPtrOutputWithContext(ctx context.Context) VpcPeeringConnectionAccepterPtrOutput {
return o.ApplyT(func(v VpcPeeringConnectionAccepter) *VpcPeeringConnectionAccepter {
return &v
}).(VpcPeeringConnectionAccepterPtrOutput)
}
type VpcPeeringConnectionAccepterPtrOutput struct {
*pulumi.OutputState
}
func (VpcPeeringConnectionAccepterPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**VpcPeeringConnectionAccepter)(nil))
}
func (o VpcPeeringConnectionAccepterPtrOutput) ToVpcPeeringConnectionAccepterPtrOutput() VpcPeeringConnectionAccepterPtrOutput {
return o
}
func (o VpcPeeringConnectionAccepterPtrOutput) ToVpcPeeringConnectionAccepterPtrOutputWithContext(ctx context.Context) VpcPeeringConnectionAccepterPtrOutput {
return o
}
type VpcPeeringConnectionAccepterArrayOutput struct{ *pulumi.OutputState }
func (VpcPeeringConnectionAccepterArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]VpcPeeringConnectionAccepter)(nil))
}
func (o VpcPeeringConnectionAccepterArrayOutput) ToVpcPeeringConnectionAccepterArrayOutput() VpcPeeringConnectionAccepterArrayOutput {
return o
}
func (o VpcPeeringConnectionAccepterArrayOutput) ToVpcPeeringConnectionAccepterArrayOutputWithContext(ctx context.Context) VpcPeeringConnectionAccepterArrayOutput {
return o
}
func (o VpcPeeringConnectionAccepterArrayOutput) Index(i pulumi.IntInput) VpcPeeringConnectionAccepterOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) VpcPeeringConnectionAccepter {
return vs[0].([]VpcPeeringConnectionAccepter)[vs[1].(int)]
}).(VpcPeeringConnectionAccepterOutput)
}
type VpcPeeringConnectionAccepterMapOutput struct{ *pulumi.OutputState }
func (VpcPeeringConnectionAccepterMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]VpcPeeringConnectionAccepter)(nil))
}
func (o VpcPeeringConnectionAccepterMapOutput) ToVpcPeeringConnectionAccepterMapOutput() VpcPeeringConnectionAccepterMapOutput {
return o
}
func (o VpcPeeringConnectionAccepterMapOutput) ToVpcPeeringConnectionAccepterMapOutputWithContext(ctx context.Context) VpcPeeringConnectionAccepterMapOutput {
return o
}
func (o VpcPeeringConnectionAccepterMapOutput) MapIndex(k pulumi.StringInput) VpcPeeringConnectionAccepterOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) VpcPeeringConnectionAccepter {
return vs[0].(map[string]VpcPeeringConnectionAccepter)[vs[1].(string)]
}).(VpcPeeringConnectionAccepterOutput)
}
func init() {
pulumi.RegisterOutputType(VpcPeeringConnectionAccepterOutput{})
pulumi.RegisterOutputType(VpcPeeringConnectionAccepterPtrOutput{})
pulumi.RegisterOutputType(VpcPeeringConnectionAccepterArrayOutput{})
pulumi.RegisterOutputType(VpcPeeringConnectionAccepterMapOutput{})
}