github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/peeringConnectionOptions.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package ec2
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Provides a resource to manage VPC peering connection options.
    16  //
    17  // > **NOTE on VPC Peering Connections and VPC Peering Connection Options:** This provider provides
    18  // both a standalone VPC Peering Connection Options and a VPC Peering Connection
    19  // resource with `accepter` and `requester` attributes. Do not manage options for the same VPC peering
    20  // connection in both a VPC Peering Connection resource and a VPC Peering Connection Options resource.
    21  // Doing so will cause a conflict of options and will overwrite the options.
    22  // Using a VPC Peering Connection Options resource decouples management of the connection options from
    23  // management of the VPC Peering Connection and allows options to be set correctly in cross-region and
    24  // cross-account scenarios.
    25  //
    26  // ## Example Usage
    27  //
    28  // ### Basic Usage
    29  //
    30  // <!--Start PulumiCodeChooser -->
    31  // ```go
    32  // package main
    33  //
    34  // import (
    35  //
    36  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    37  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    38  //
    39  // )
    40  //
    41  //	func main() {
    42  //		pulumi.Run(func(ctx *pulumi.Context) error {
    43  //			foo, err := ec2.NewVpc(ctx, "foo", &ec2.VpcArgs{
    44  //				CidrBlock: pulumi.String("10.0.0.0/16"),
    45  //			})
    46  //			if err != nil {
    47  //				return err
    48  //			}
    49  //			bar, err := ec2.NewVpc(ctx, "bar", &ec2.VpcArgs{
    50  //				CidrBlock: pulumi.String("10.1.0.0/16"),
    51  //			})
    52  //			if err != nil {
    53  //				return err
    54  //			}
    55  //			fooVpcPeeringConnection, err := ec2.NewVpcPeeringConnection(ctx, "foo", &ec2.VpcPeeringConnectionArgs{
    56  //				VpcId:      foo.ID(),
    57  //				PeerVpcId:  bar.ID(),
    58  //				AutoAccept: pulumi.Bool(true),
    59  //			})
    60  //			if err != nil {
    61  //				return err
    62  //			}
    63  //			_, err = ec2.NewPeeringConnectionOptions(ctx, "foo", &ec2.PeeringConnectionOptionsArgs{
    64  //				VpcPeeringConnectionId: fooVpcPeeringConnection.ID(),
    65  //				Accepter: &ec2.PeeringConnectionOptionsAccepterArgs{
    66  //					AllowRemoteVpcDnsResolution: pulumi.Bool(true),
    67  //				},
    68  //			})
    69  //			if err != nil {
    70  //				return err
    71  //			}
    72  //			return nil
    73  //		})
    74  //	}
    75  //
    76  // ```
    77  // <!--End PulumiCodeChooser -->
    78  //
    79  // ### Cross-Account Usage
    80  //
    81  // <!--Start PulumiCodeChooser -->
    82  // ```go
    83  // package main
    84  //
    85  // import (
    86  //
    87  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    88  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    89  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    90  //
    91  // )
    92  //
    93  //	func main() {
    94  //		pulumi.Run(func(ctx *pulumi.Context) error {
    95  //			main, err := ec2.NewVpc(ctx, "main", &ec2.VpcArgs{
    96  //				CidrBlock:          pulumi.String("10.0.0.0/16"),
    97  //				EnableDnsSupport:   pulumi.Bool(true),
    98  //				EnableDnsHostnames: pulumi.Bool(true),
    99  //			})
   100  //			if err != nil {
   101  //				return err
   102  //			}
   103  //			peerVpc, err := ec2.NewVpc(ctx, "peer", &ec2.VpcArgs{
   104  //				CidrBlock:          pulumi.String("10.1.0.0/16"),
   105  //				EnableDnsSupport:   pulumi.Bool(true),
   106  //				EnableDnsHostnames: pulumi.Bool(true),
   107  //			})
   108  //			if err != nil {
   109  //				return err
   110  //			}
   111  //			peer, err := aws.GetCallerIdentity(ctx, nil, nil)
   112  //			if err != nil {
   113  //				return err
   114  //			}
   115  //			// Requester's side of the connection.
   116  //			peerVpcPeeringConnection, err := ec2.NewVpcPeeringConnection(ctx, "peer", &ec2.VpcPeeringConnectionArgs{
   117  //				VpcId:       main.ID(),
   118  //				PeerVpcId:   peerVpc.ID(),
   119  //				PeerOwnerId: pulumi.String(peer.AccountId),
   120  //				AutoAccept:  pulumi.Bool(false),
   121  //				Tags: pulumi.StringMap{
   122  //					"Side": pulumi.String("Requester"),
   123  //				},
   124  //			})
   125  //			if err != nil {
   126  //				return err
   127  //			}
   128  //			// Accepter's side of the connection.
   129  //			peerVpcPeeringConnectionAccepter, err := ec2.NewVpcPeeringConnectionAccepter(ctx, "peer", &ec2.VpcPeeringConnectionAccepterArgs{
   130  //				VpcPeeringConnectionId: peerVpcPeeringConnection.ID(),
   131  //				AutoAccept:             pulumi.Bool(true),
   132  //				Tags: pulumi.StringMap{
   133  //					"Side": pulumi.String("Accepter"),
   134  //				},
   135  //			})
   136  //			if err != nil {
   137  //				return err
   138  //			}
   139  //			_, err = ec2.NewPeeringConnectionOptions(ctx, "requester", &ec2.PeeringConnectionOptionsArgs{
   140  //				VpcPeeringConnectionId: peerVpcPeeringConnectionAccepter.ID(),
   141  //				Requester: &ec2.PeeringConnectionOptionsRequesterArgs{
   142  //					AllowRemoteVpcDnsResolution: pulumi.Bool(true),
   143  //				},
   144  //			})
   145  //			if err != nil {
   146  //				return err
   147  //			}
   148  //			_, err = ec2.NewPeeringConnectionOptions(ctx, "accepter", &ec2.PeeringConnectionOptionsArgs{
   149  //				VpcPeeringConnectionId: peerVpcPeeringConnectionAccepter.ID(),
   150  //				Accepter: &ec2.PeeringConnectionOptionsAccepterArgs{
   151  //					AllowRemoteVpcDnsResolution: pulumi.Bool(true),
   152  //				},
   153  //			})
   154  //			if err != nil {
   155  //				return err
   156  //			}
   157  //			return nil
   158  //		})
   159  //	}
   160  //
   161  // ```
   162  // <!--End PulumiCodeChooser -->
   163  //
   164  // ## Import
   165  //
   166  // Using `pulumi import`, import VPC Peering Connection Options using the VPC peering `id`. For example:
   167  //
   168  // ```sh
   169  // $ pulumi import aws:ec2/peeringConnectionOptions:PeeringConnectionOptions foo pcx-111aaa111
   170  // ```
   171  type PeeringConnectionOptions struct {
   172  	pulumi.CustomResourceState
   173  
   174  	// An optional configuration block that allows for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to be set for the VPC that acceptsthe peering connection (a maximum of one).
   175  	Accepter PeeringConnectionOptionsAccepterOutput `pulumi:"accepter"`
   176  	// A optional configuration block that allows for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to be set for the VPC that requeststhe peering connection (a maximum of one).
   177  	Requester PeeringConnectionOptionsRequesterOutput `pulumi:"requester"`
   178  	// The ID of the requester VPC peering connection.
   179  	VpcPeeringConnectionId pulumi.StringOutput `pulumi:"vpcPeeringConnectionId"`
   180  }
   181  
   182  // NewPeeringConnectionOptions registers a new resource with the given unique name, arguments, and options.
   183  func NewPeeringConnectionOptions(ctx *pulumi.Context,
   184  	name string, args *PeeringConnectionOptionsArgs, opts ...pulumi.ResourceOption) (*PeeringConnectionOptions, error) {
   185  	if args == nil {
   186  		return nil, errors.New("missing one or more required arguments")
   187  	}
   188  
   189  	if args.VpcPeeringConnectionId == nil {
   190  		return nil, errors.New("invalid value for required argument 'VpcPeeringConnectionId'")
   191  	}
   192  	opts = internal.PkgResourceDefaultOpts(opts)
   193  	var resource PeeringConnectionOptions
   194  	err := ctx.RegisterResource("aws:ec2/peeringConnectionOptions:PeeringConnectionOptions", name, args, &resource, opts...)
   195  	if err != nil {
   196  		return nil, err
   197  	}
   198  	return &resource, nil
   199  }
   200  
   201  // GetPeeringConnectionOptions gets an existing PeeringConnectionOptions resource's state with the given name, ID, and optional
   202  // state properties that are used to uniquely qualify the lookup (nil if not required).
   203  func GetPeeringConnectionOptions(ctx *pulumi.Context,
   204  	name string, id pulumi.IDInput, state *PeeringConnectionOptionsState, opts ...pulumi.ResourceOption) (*PeeringConnectionOptions, error) {
   205  	var resource PeeringConnectionOptions
   206  	err := ctx.ReadResource("aws:ec2/peeringConnectionOptions:PeeringConnectionOptions", name, id, state, &resource, opts...)
   207  	if err != nil {
   208  		return nil, err
   209  	}
   210  	return &resource, nil
   211  }
   212  
   213  // Input properties used for looking up and filtering PeeringConnectionOptions resources.
   214  type peeringConnectionOptionsState struct {
   215  	// An optional configuration block that allows for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to be set for the VPC that acceptsthe peering connection (a maximum of one).
   216  	Accepter *PeeringConnectionOptionsAccepter `pulumi:"accepter"`
   217  	// A optional configuration block that allows for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to be set for the VPC that requeststhe peering connection (a maximum of one).
   218  	Requester *PeeringConnectionOptionsRequester `pulumi:"requester"`
   219  	// The ID of the requester VPC peering connection.
   220  	VpcPeeringConnectionId *string `pulumi:"vpcPeeringConnectionId"`
   221  }
   222  
   223  type PeeringConnectionOptionsState struct {
   224  	// An optional configuration block that allows for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to be set for the VPC that acceptsthe peering connection (a maximum of one).
   225  	Accepter PeeringConnectionOptionsAccepterPtrInput
   226  	// A optional configuration block that allows for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to be set for the VPC that requeststhe peering connection (a maximum of one).
   227  	Requester PeeringConnectionOptionsRequesterPtrInput
   228  	// The ID of the requester VPC peering connection.
   229  	VpcPeeringConnectionId pulumi.StringPtrInput
   230  }
   231  
   232  func (PeeringConnectionOptionsState) ElementType() reflect.Type {
   233  	return reflect.TypeOf((*peeringConnectionOptionsState)(nil)).Elem()
   234  }
   235  
   236  type peeringConnectionOptionsArgs struct {
   237  	// An optional configuration block that allows for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to be set for the VPC that acceptsthe peering connection (a maximum of one).
   238  	Accepter *PeeringConnectionOptionsAccepter `pulumi:"accepter"`
   239  	// A optional configuration block that allows for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to be set for the VPC that requeststhe peering connection (a maximum of one).
   240  	Requester *PeeringConnectionOptionsRequester `pulumi:"requester"`
   241  	// The ID of the requester VPC peering connection.
   242  	VpcPeeringConnectionId string `pulumi:"vpcPeeringConnectionId"`
   243  }
   244  
   245  // The set of arguments for constructing a PeeringConnectionOptions resource.
   246  type PeeringConnectionOptionsArgs struct {
   247  	// An optional configuration block that allows for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to be set for the VPC that acceptsthe peering connection (a maximum of one).
   248  	Accepter PeeringConnectionOptionsAccepterPtrInput
   249  	// A optional configuration block that allows for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to be set for the VPC that requeststhe peering connection (a maximum of one).
   250  	Requester PeeringConnectionOptionsRequesterPtrInput
   251  	// The ID of the requester VPC peering connection.
   252  	VpcPeeringConnectionId pulumi.StringInput
   253  }
   254  
   255  func (PeeringConnectionOptionsArgs) ElementType() reflect.Type {
   256  	return reflect.TypeOf((*peeringConnectionOptionsArgs)(nil)).Elem()
   257  }
   258  
   259  type PeeringConnectionOptionsInput interface {
   260  	pulumi.Input
   261  
   262  	ToPeeringConnectionOptionsOutput() PeeringConnectionOptionsOutput
   263  	ToPeeringConnectionOptionsOutputWithContext(ctx context.Context) PeeringConnectionOptionsOutput
   264  }
   265  
   266  func (*PeeringConnectionOptions) ElementType() reflect.Type {
   267  	return reflect.TypeOf((**PeeringConnectionOptions)(nil)).Elem()
   268  }
   269  
   270  func (i *PeeringConnectionOptions) ToPeeringConnectionOptionsOutput() PeeringConnectionOptionsOutput {
   271  	return i.ToPeeringConnectionOptionsOutputWithContext(context.Background())
   272  }
   273  
   274  func (i *PeeringConnectionOptions) ToPeeringConnectionOptionsOutputWithContext(ctx context.Context) PeeringConnectionOptionsOutput {
   275  	return pulumi.ToOutputWithContext(ctx, i).(PeeringConnectionOptionsOutput)
   276  }
   277  
   278  // PeeringConnectionOptionsArrayInput is an input type that accepts PeeringConnectionOptionsArray and PeeringConnectionOptionsArrayOutput values.
   279  // You can construct a concrete instance of `PeeringConnectionOptionsArrayInput` via:
   280  //
   281  //	PeeringConnectionOptionsArray{ PeeringConnectionOptionsArgs{...} }
   282  type PeeringConnectionOptionsArrayInput interface {
   283  	pulumi.Input
   284  
   285  	ToPeeringConnectionOptionsArrayOutput() PeeringConnectionOptionsArrayOutput
   286  	ToPeeringConnectionOptionsArrayOutputWithContext(context.Context) PeeringConnectionOptionsArrayOutput
   287  }
   288  
   289  type PeeringConnectionOptionsArray []PeeringConnectionOptionsInput
   290  
   291  func (PeeringConnectionOptionsArray) ElementType() reflect.Type {
   292  	return reflect.TypeOf((*[]*PeeringConnectionOptions)(nil)).Elem()
   293  }
   294  
   295  func (i PeeringConnectionOptionsArray) ToPeeringConnectionOptionsArrayOutput() PeeringConnectionOptionsArrayOutput {
   296  	return i.ToPeeringConnectionOptionsArrayOutputWithContext(context.Background())
   297  }
   298  
   299  func (i PeeringConnectionOptionsArray) ToPeeringConnectionOptionsArrayOutputWithContext(ctx context.Context) PeeringConnectionOptionsArrayOutput {
   300  	return pulumi.ToOutputWithContext(ctx, i).(PeeringConnectionOptionsArrayOutput)
   301  }
   302  
   303  // PeeringConnectionOptionsMapInput is an input type that accepts PeeringConnectionOptionsMap and PeeringConnectionOptionsMapOutput values.
   304  // You can construct a concrete instance of `PeeringConnectionOptionsMapInput` via:
   305  //
   306  //	PeeringConnectionOptionsMap{ "key": PeeringConnectionOptionsArgs{...} }
   307  type PeeringConnectionOptionsMapInput interface {
   308  	pulumi.Input
   309  
   310  	ToPeeringConnectionOptionsMapOutput() PeeringConnectionOptionsMapOutput
   311  	ToPeeringConnectionOptionsMapOutputWithContext(context.Context) PeeringConnectionOptionsMapOutput
   312  }
   313  
   314  type PeeringConnectionOptionsMap map[string]PeeringConnectionOptionsInput
   315  
   316  func (PeeringConnectionOptionsMap) ElementType() reflect.Type {
   317  	return reflect.TypeOf((*map[string]*PeeringConnectionOptions)(nil)).Elem()
   318  }
   319  
   320  func (i PeeringConnectionOptionsMap) ToPeeringConnectionOptionsMapOutput() PeeringConnectionOptionsMapOutput {
   321  	return i.ToPeeringConnectionOptionsMapOutputWithContext(context.Background())
   322  }
   323  
   324  func (i PeeringConnectionOptionsMap) ToPeeringConnectionOptionsMapOutputWithContext(ctx context.Context) PeeringConnectionOptionsMapOutput {
   325  	return pulumi.ToOutputWithContext(ctx, i).(PeeringConnectionOptionsMapOutput)
   326  }
   327  
   328  type PeeringConnectionOptionsOutput struct{ *pulumi.OutputState }
   329  
   330  func (PeeringConnectionOptionsOutput) ElementType() reflect.Type {
   331  	return reflect.TypeOf((**PeeringConnectionOptions)(nil)).Elem()
   332  }
   333  
   334  func (o PeeringConnectionOptionsOutput) ToPeeringConnectionOptionsOutput() PeeringConnectionOptionsOutput {
   335  	return o
   336  }
   337  
   338  func (o PeeringConnectionOptionsOutput) ToPeeringConnectionOptionsOutputWithContext(ctx context.Context) PeeringConnectionOptionsOutput {
   339  	return o
   340  }
   341  
   342  // An optional configuration block that allows for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to be set for the VPC that acceptsthe peering connection (a maximum of one).
   343  func (o PeeringConnectionOptionsOutput) Accepter() PeeringConnectionOptionsAccepterOutput {
   344  	return o.ApplyT(func(v *PeeringConnectionOptions) PeeringConnectionOptionsAccepterOutput { return v.Accepter }).(PeeringConnectionOptionsAccepterOutput)
   345  }
   346  
   347  // A optional configuration block that allows for [VPC Peering Connection](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options to be set for the VPC that requeststhe peering connection (a maximum of one).
   348  func (o PeeringConnectionOptionsOutput) Requester() PeeringConnectionOptionsRequesterOutput {
   349  	return o.ApplyT(func(v *PeeringConnectionOptions) PeeringConnectionOptionsRequesterOutput { return v.Requester }).(PeeringConnectionOptionsRequesterOutput)
   350  }
   351  
   352  // The ID of the requester VPC peering connection.
   353  func (o PeeringConnectionOptionsOutput) VpcPeeringConnectionId() pulumi.StringOutput {
   354  	return o.ApplyT(func(v *PeeringConnectionOptions) pulumi.StringOutput { return v.VpcPeeringConnectionId }).(pulumi.StringOutput)
   355  }
   356  
   357  type PeeringConnectionOptionsArrayOutput struct{ *pulumi.OutputState }
   358  
   359  func (PeeringConnectionOptionsArrayOutput) ElementType() reflect.Type {
   360  	return reflect.TypeOf((*[]*PeeringConnectionOptions)(nil)).Elem()
   361  }
   362  
   363  func (o PeeringConnectionOptionsArrayOutput) ToPeeringConnectionOptionsArrayOutput() PeeringConnectionOptionsArrayOutput {
   364  	return o
   365  }
   366  
   367  func (o PeeringConnectionOptionsArrayOutput) ToPeeringConnectionOptionsArrayOutputWithContext(ctx context.Context) PeeringConnectionOptionsArrayOutput {
   368  	return o
   369  }
   370  
   371  func (o PeeringConnectionOptionsArrayOutput) Index(i pulumi.IntInput) PeeringConnectionOptionsOutput {
   372  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *PeeringConnectionOptions {
   373  		return vs[0].([]*PeeringConnectionOptions)[vs[1].(int)]
   374  	}).(PeeringConnectionOptionsOutput)
   375  }
   376  
   377  type PeeringConnectionOptionsMapOutput struct{ *pulumi.OutputState }
   378  
   379  func (PeeringConnectionOptionsMapOutput) ElementType() reflect.Type {
   380  	return reflect.TypeOf((*map[string]*PeeringConnectionOptions)(nil)).Elem()
   381  }
   382  
   383  func (o PeeringConnectionOptionsMapOutput) ToPeeringConnectionOptionsMapOutput() PeeringConnectionOptionsMapOutput {
   384  	return o
   385  }
   386  
   387  func (o PeeringConnectionOptionsMapOutput) ToPeeringConnectionOptionsMapOutputWithContext(ctx context.Context) PeeringConnectionOptionsMapOutput {
   388  	return o
   389  }
   390  
   391  func (o PeeringConnectionOptionsMapOutput) MapIndex(k pulumi.StringInput) PeeringConnectionOptionsOutput {
   392  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *PeeringConnectionOptions {
   393  		return vs[0].(map[string]*PeeringConnectionOptions)[vs[1].(string)]
   394  	}).(PeeringConnectionOptionsOutput)
   395  }
   396  
   397  func init() {
   398  	pulumi.RegisterInputType(reflect.TypeOf((*PeeringConnectionOptionsInput)(nil)).Elem(), &PeeringConnectionOptions{})
   399  	pulumi.RegisterInputType(reflect.TypeOf((*PeeringConnectionOptionsArrayInput)(nil)).Elem(), PeeringConnectionOptionsArray{})
   400  	pulumi.RegisterInputType(reflect.TypeOf((*PeeringConnectionOptionsMapInput)(nil)).Elem(), PeeringConnectionOptionsMap{})
   401  	pulumi.RegisterOutputType(PeeringConnectionOptionsOutput{})
   402  	pulumi.RegisterOutputType(PeeringConnectionOptionsArrayOutput{})
   403  	pulumi.RegisterOutputType(PeeringConnectionOptionsMapOutput{})
   404  }