github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/mainRouteTableAssociation.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 for managing the main routing table of a VPC.
    16  //
    17  // > **NOTE:** **Do not** use both `ec2.DefaultRouteTable` to manage a default route table **and** `ec2.MainRouteTableAssociation` with the same VPC due to possible route conflicts. See ec2.DefaultRouteTable documentation for more details.
    18  // For more information, see the Amazon VPC User Guide on [Route Tables][aws-route-tables]. For information about managing normal route tables in Pulumi, see [`ec2.RouteTable`][tf-route-tables].
    19  //
    20  // ## Example Usage
    21  //
    22  // <!--Start PulumiCodeChooser -->
    23  // ```go
    24  // package main
    25  //
    26  // import (
    27  //
    28  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    29  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    30  //
    31  // )
    32  //
    33  //	func main() {
    34  //		pulumi.Run(func(ctx *pulumi.Context) error {
    35  //			_, err := ec2.NewMainRouteTableAssociation(ctx, "a", &ec2.MainRouteTableAssociationArgs{
    36  //				VpcId:        pulumi.Any(foo.Id),
    37  //				RouteTableId: pulumi.Any(bar.Id),
    38  //			})
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			return nil
    43  //		})
    44  //	}
    45  //
    46  // ```
    47  // <!--End PulumiCodeChooser -->
    48  //
    49  // ## Notes
    50  //
    51  // On VPC creation, the AWS API always creates an initial Main Route Table. This
    52  // resource records the ID of that Route Table under `originalRouteTableId`.
    53  // The "Delete" action for a `mainRouteTableAssociation` consists of resetting
    54  // this original table as the Main Route Table for the VPC. You'll see this
    55  // additional Route Table in the AWS console; it must remain intact in order for
    56  // the `mainRouteTableAssociation` delete to work properly.
    57  type MainRouteTableAssociation struct {
    58  	pulumi.CustomResourceState
    59  
    60  	// Used internally, see **Notes** below
    61  	OriginalRouteTableId pulumi.StringOutput `pulumi:"originalRouteTableId"`
    62  	// The ID of the Route Table to set as the new
    63  	// main route table for the target VPC
    64  	RouteTableId pulumi.StringOutput `pulumi:"routeTableId"`
    65  	// The ID of the VPC whose main route table should be set
    66  	VpcId pulumi.StringOutput `pulumi:"vpcId"`
    67  }
    68  
    69  // NewMainRouteTableAssociation registers a new resource with the given unique name, arguments, and options.
    70  func NewMainRouteTableAssociation(ctx *pulumi.Context,
    71  	name string, args *MainRouteTableAssociationArgs, opts ...pulumi.ResourceOption) (*MainRouteTableAssociation, error) {
    72  	if args == nil {
    73  		return nil, errors.New("missing one or more required arguments")
    74  	}
    75  
    76  	if args.RouteTableId == nil {
    77  		return nil, errors.New("invalid value for required argument 'RouteTableId'")
    78  	}
    79  	if args.VpcId == nil {
    80  		return nil, errors.New("invalid value for required argument 'VpcId'")
    81  	}
    82  	opts = internal.PkgResourceDefaultOpts(opts)
    83  	var resource MainRouteTableAssociation
    84  	err := ctx.RegisterResource("aws:ec2/mainRouteTableAssociation:MainRouteTableAssociation", name, args, &resource, opts...)
    85  	if err != nil {
    86  		return nil, err
    87  	}
    88  	return &resource, nil
    89  }
    90  
    91  // GetMainRouteTableAssociation gets an existing MainRouteTableAssociation resource's state with the given name, ID, and optional
    92  // state properties that are used to uniquely qualify the lookup (nil if not required).
    93  func GetMainRouteTableAssociation(ctx *pulumi.Context,
    94  	name string, id pulumi.IDInput, state *MainRouteTableAssociationState, opts ...pulumi.ResourceOption) (*MainRouteTableAssociation, error) {
    95  	var resource MainRouteTableAssociation
    96  	err := ctx.ReadResource("aws:ec2/mainRouteTableAssociation:MainRouteTableAssociation", name, id, state, &resource, opts...)
    97  	if err != nil {
    98  		return nil, err
    99  	}
   100  	return &resource, nil
   101  }
   102  
   103  // Input properties used for looking up and filtering MainRouteTableAssociation resources.
   104  type mainRouteTableAssociationState struct {
   105  	// Used internally, see **Notes** below
   106  	OriginalRouteTableId *string `pulumi:"originalRouteTableId"`
   107  	// The ID of the Route Table to set as the new
   108  	// main route table for the target VPC
   109  	RouteTableId *string `pulumi:"routeTableId"`
   110  	// The ID of the VPC whose main route table should be set
   111  	VpcId *string `pulumi:"vpcId"`
   112  }
   113  
   114  type MainRouteTableAssociationState struct {
   115  	// Used internally, see **Notes** below
   116  	OriginalRouteTableId pulumi.StringPtrInput
   117  	// The ID of the Route Table to set as the new
   118  	// main route table for the target VPC
   119  	RouteTableId pulumi.StringPtrInput
   120  	// The ID of the VPC whose main route table should be set
   121  	VpcId pulumi.StringPtrInput
   122  }
   123  
   124  func (MainRouteTableAssociationState) ElementType() reflect.Type {
   125  	return reflect.TypeOf((*mainRouteTableAssociationState)(nil)).Elem()
   126  }
   127  
   128  type mainRouteTableAssociationArgs struct {
   129  	// The ID of the Route Table to set as the new
   130  	// main route table for the target VPC
   131  	RouteTableId string `pulumi:"routeTableId"`
   132  	// The ID of the VPC whose main route table should be set
   133  	VpcId string `pulumi:"vpcId"`
   134  }
   135  
   136  // The set of arguments for constructing a MainRouteTableAssociation resource.
   137  type MainRouteTableAssociationArgs struct {
   138  	// The ID of the Route Table to set as the new
   139  	// main route table for the target VPC
   140  	RouteTableId pulumi.StringInput
   141  	// The ID of the VPC whose main route table should be set
   142  	VpcId pulumi.StringInput
   143  }
   144  
   145  func (MainRouteTableAssociationArgs) ElementType() reflect.Type {
   146  	return reflect.TypeOf((*mainRouteTableAssociationArgs)(nil)).Elem()
   147  }
   148  
   149  type MainRouteTableAssociationInput interface {
   150  	pulumi.Input
   151  
   152  	ToMainRouteTableAssociationOutput() MainRouteTableAssociationOutput
   153  	ToMainRouteTableAssociationOutputWithContext(ctx context.Context) MainRouteTableAssociationOutput
   154  }
   155  
   156  func (*MainRouteTableAssociation) ElementType() reflect.Type {
   157  	return reflect.TypeOf((**MainRouteTableAssociation)(nil)).Elem()
   158  }
   159  
   160  func (i *MainRouteTableAssociation) ToMainRouteTableAssociationOutput() MainRouteTableAssociationOutput {
   161  	return i.ToMainRouteTableAssociationOutputWithContext(context.Background())
   162  }
   163  
   164  func (i *MainRouteTableAssociation) ToMainRouteTableAssociationOutputWithContext(ctx context.Context) MainRouteTableAssociationOutput {
   165  	return pulumi.ToOutputWithContext(ctx, i).(MainRouteTableAssociationOutput)
   166  }
   167  
   168  // MainRouteTableAssociationArrayInput is an input type that accepts MainRouteTableAssociationArray and MainRouteTableAssociationArrayOutput values.
   169  // You can construct a concrete instance of `MainRouteTableAssociationArrayInput` via:
   170  //
   171  //	MainRouteTableAssociationArray{ MainRouteTableAssociationArgs{...} }
   172  type MainRouteTableAssociationArrayInput interface {
   173  	pulumi.Input
   174  
   175  	ToMainRouteTableAssociationArrayOutput() MainRouteTableAssociationArrayOutput
   176  	ToMainRouteTableAssociationArrayOutputWithContext(context.Context) MainRouteTableAssociationArrayOutput
   177  }
   178  
   179  type MainRouteTableAssociationArray []MainRouteTableAssociationInput
   180  
   181  func (MainRouteTableAssociationArray) ElementType() reflect.Type {
   182  	return reflect.TypeOf((*[]*MainRouteTableAssociation)(nil)).Elem()
   183  }
   184  
   185  func (i MainRouteTableAssociationArray) ToMainRouteTableAssociationArrayOutput() MainRouteTableAssociationArrayOutput {
   186  	return i.ToMainRouteTableAssociationArrayOutputWithContext(context.Background())
   187  }
   188  
   189  func (i MainRouteTableAssociationArray) ToMainRouteTableAssociationArrayOutputWithContext(ctx context.Context) MainRouteTableAssociationArrayOutput {
   190  	return pulumi.ToOutputWithContext(ctx, i).(MainRouteTableAssociationArrayOutput)
   191  }
   192  
   193  // MainRouteTableAssociationMapInput is an input type that accepts MainRouteTableAssociationMap and MainRouteTableAssociationMapOutput values.
   194  // You can construct a concrete instance of `MainRouteTableAssociationMapInput` via:
   195  //
   196  //	MainRouteTableAssociationMap{ "key": MainRouteTableAssociationArgs{...} }
   197  type MainRouteTableAssociationMapInput interface {
   198  	pulumi.Input
   199  
   200  	ToMainRouteTableAssociationMapOutput() MainRouteTableAssociationMapOutput
   201  	ToMainRouteTableAssociationMapOutputWithContext(context.Context) MainRouteTableAssociationMapOutput
   202  }
   203  
   204  type MainRouteTableAssociationMap map[string]MainRouteTableAssociationInput
   205  
   206  func (MainRouteTableAssociationMap) ElementType() reflect.Type {
   207  	return reflect.TypeOf((*map[string]*MainRouteTableAssociation)(nil)).Elem()
   208  }
   209  
   210  func (i MainRouteTableAssociationMap) ToMainRouteTableAssociationMapOutput() MainRouteTableAssociationMapOutput {
   211  	return i.ToMainRouteTableAssociationMapOutputWithContext(context.Background())
   212  }
   213  
   214  func (i MainRouteTableAssociationMap) ToMainRouteTableAssociationMapOutputWithContext(ctx context.Context) MainRouteTableAssociationMapOutput {
   215  	return pulumi.ToOutputWithContext(ctx, i).(MainRouteTableAssociationMapOutput)
   216  }
   217  
   218  type MainRouteTableAssociationOutput struct{ *pulumi.OutputState }
   219  
   220  func (MainRouteTableAssociationOutput) ElementType() reflect.Type {
   221  	return reflect.TypeOf((**MainRouteTableAssociation)(nil)).Elem()
   222  }
   223  
   224  func (o MainRouteTableAssociationOutput) ToMainRouteTableAssociationOutput() MainRouteTableAssociationOutput {
   225  	return o
   226  }
   227  
   228  func (o MainRouteTableAssociationOutput) ToMainRouteTableAssociationOutputWithContext(ctx context.Context) MainRouteTableAssociationOutput {
   229  	return o
   230  }
   231  
   232  // Used internally, see **Notes** below
   233  func (o MainRouteTableAssociationOutput) OriginalRouteTableId() pulumi.StringOutput {
   234  	return o.ApplyT(func(v *MainRouteTableAssociation) pulumi.StringOutput { return v.OriginalRouteTableId }).(pulumi.StringOutput)
   235  }
   236  
   237  // The ID of the Route Table to set as the new
   238  // main route table for the target VPC
   239  func (o MainRouteTableAssociationOutput) RouteTableId() pulumi.StringOutput {
   240  	return o.ApplyT(func(v *MainRouteTableAssociation) pulumi.StringOutput { return v.RouteTableId }).(pulumi.StringOutput)
   241  }
   242  
   243  // The ID of the VPC whose main route table should be set
   244  func (o MainRouteTableAssociationOutput) VpcId() pulumi.StringOutput {
   245  	return o.ApplyT(func(v *MainRouteTableAssociation) pulumi.StringOutput { return v.VpcId }).(pulumi.StringOutput)
   246  }
   247  
   248  type MainRouteTableAssociationArrayOutput struct{ *pulumi.OutputState }
   249  
   250  func (MainRouteTableAssociationArrayOutput) ElementType() reflect.Type {
   251  	return reflect.TypeOf((*[]*MainRouteTableAssociation)(nil)).Elem()
   252  }
   253  
   254  func (o MainRouteTableAssociationArrayOutput) ToMainRouteTableAssociationArrayOutput() MainRouteTableAssociationArrayOutput {
   255  	return o
   256  }
   257  
   258  func (o MainRouteTableAssociationArrayOutput) ToMainRouteTableAssociationArrayOutputWithContext(ctx context.Context) MainRouteTableAssociationArrayOutput {
   259  	return o
   260  }
   261  
   262  func (o MainRouteTableAssociationArrayOutput) Index(i pulumi.IntInput) MainRouteTableAssociationOutput {
   263  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *MainRouteTableAssociation {
   264  		return vs[0].([]*MainRouteTableAssociation)[vs[1].(int)]
   265  	}).(MainRouteTableAssociationOutput)
   266  }
   267  
   268  type MainRouteTableAssociationMapOutput struct{ *pulumi.OutputState }
   269  
   270  func (MainRouteTableAssociationMapOutput) ElementType() reflect.Type {
   271  	return reflect.TypeOf((*map[string]*MainRouteTableAssociation)(nil)).Elem()
   272  }
   273  
   274  func (o MainRouteTableAssociationMapOutput) ToMainRouteTableAssociationMapOutput() MainRouteTableAssociationMapOutput {
   275  	return o
   276  }
   277  
   278  func (o MainRouteTableAssociationMapOutput) ToMainRouteTableAssociationMapOutputWithContext(ctx context.Context) MainRouteTableAssociationMapOutput {
   279  	return o
   280  }
   281  
   282  func (o MainRouteTableAssociationMapOutput) MapIndex(k pulumi.StringInput) MainRouteTableAssociationOutput {
   283  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *MainRouteTableAssociation {
   284  		return vs[0].(map[string]*MainRouteTableAssociation)[vs[1].(string)]
   285  	}).(MainRouteTableAssociationOutput)
   286  }
   287  
   288  func init() {
   289  	pulumi.RegisterInputType(reflect.TypeOf((*MainRouteTableAssociationInput)(nil)).Elem(), &MainRouteTableAssociation{})
   290  	pulumi.RegisterInputType(reflect.TypeOf((*MainRouteTableAssociationArrayInput)(nil)).Elem(), MainRouteTableAssociationArray{})
   291  	pulumi.RegisterInputType(reflect.TypeOf((*MainRouteTableAssociationMapInput)(nil)).Elem(), MainRouteTableAssociationMap{})
   292  	pulumi.RegisterOutputType(MainRouteTableAssociationOutput{})
   293  	pulumi.RegisterOutputType(MainRouteTableAssociationArrayOutput{})
   294  	pulumi.RegisterOutputType(MainRouteTableAssociationMapOutput{})
   295  }