github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/defaultRouteTable.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 a default route table of a VPC. This resource can manage the default route table of the default or a non-default VPC.
    16  //
    17  // > **NOTE:** This is an advanced resource with special caveats. Please read this document in its entirety before using this resource. The `ec2.DefaultRouteTable` resource behaves differently from normal resources. This provider does not _create_ this resource but instead attempts to "adopt" it into management. **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.MainRouteTableAssociation documentation for more details.
    18  //
    19  // Every VPC has a default route table that can be managed but not destroyed. When the provider first adopts a default route table, it **immediately removes all defined routes**. It then proceeds to create any routes specified in the configuration. This step is required so that only the routes specified in the configuration exist in the default route table.
    20  //
    21  // For more information, see the Amazon VPC User Guide on [Route Tables](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Route_Tables.html). For information about managing normal route tables in this provider, see `ec2.RouteTable`.
    22  //
    23  // ## Example Usage
    24  //
    25  // <!--Start PulumiCodeChooser -->
    26  // ```go
    27  // package main
    28  //
    29  // import (
    30  //
    31  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    32  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    33  //
    34  // )
    35  //
    36  //	func main() {
    37  //		pulumi.Run(func(ctx *pulumi.Context) error {
    38  //			_, err := ec2.NewDefaultRouteTable(ctx, "example", &ec2.DefaultRouteTableArgs{
    39  //				DefaultRouteTableId: pulumi.Any(exampleAwsVpc.DefaultRouteTableId),
    40  //				Routes: ec2.DefaultRouteTableRouteArray{
    41  //					&ec2.DefaultRouteTableRouteArgs{
    42  //						CidrBlock: pulumi.String("10.0.1.0/24"),
    43  //						GatewayId: pulumi.Any(exampleAwsInternetGateway.Id),
    44  //					},
    45  //					&ec2.DefaultRouteTableRouteArgs{
    46  //						Ipv6CidrBlock:       pulumi.String("::/0"),
    47  //						EgressOnlyGatewayId: pulumi.Any(exampleAwsEgressOnlyInternetGateway.Id),
    48  //					},
    49  //				},
    50  //				Tags: pulumi.StringMap{
    51  //					"Name": pulumi.String("example"),
    52  //				},
    53  //			})
    54  //			if err != nil {
    55  //				return err
    56  //			}
    57  //			return nil
    58  //		})
    59  //	}
    60  //
    61  // ```
    62  // <!--End PulumiCodeChooser -->
    63  //
    64  // To subsequently remove all managed routes:
    65  //
    66  // <!--Start PulumiCodeChooser -->
    67  // ```go
    68  // package main
    69  //
    70  // import (
    71  //
    72  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    73  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    74  //
    75  // )
    76  //
    77  //	func main() {
    78  //		pulumi.Run(func(ctx *pulumi.Context) error {
    79  //			_, err := ec2.NewDefaultRouteTable(ctx, "example", &ec2.DefaultRouteTableArgs{
    80  //				DefaultRouteTableId: pulumi.Any(exampleAwsVpc.DefaultRouteTableId),
    81  //				Routes:              ec2.DefaultRouteTableRouteArray{},
    82  //				Tags: pulumi.StringMap{
    83  //					"Name": pulumi.String("example"),
    84  //				},
    85  //			})
    86  //			if err != nil {
    87  //				return err
    88  //			}
    89  //			return nil
    90  //		})
    91  //	}
    92  //
    93  // ```
    94  // <!--End PulumiCodeChooser -->
    95  //
    96  // ## Import
    97  //
    98  // Using `pulumi import`, import Default VPC route tables using the `vpc_id`. For example:
    99  //
   100  // ```sh
   101  // $ pulumi import aws:ec2/defaultRouteTable:DefaultRouteTable example vpc-33cc44dd
   102  // ```
   103  type DefaultRouteTable struct {
   104  	pulumi.CustomResourceState
   105  
   106  	// The ARN of the route table.
   107  	Arn pulumi.StringOutput `pulumi:"arn"`
   108  	// ID of the default route table.
   109  	//
   110  	// The following arguments are optional:
   111  	DefaultRouteTableId pulumi.StringOutput `pulumi:"defaultRouteTableId"`
   112  	// ID of the AWS account that owns the route table.
   113  	OwnerId pulumi.StringOutput `pulumi:"ownerId"`
   114  	// List of virtual gateways for propagation.
   115  	PropagatingVgws pulumi.StringArrayOutput `pulumi:"propagatingVgws"`
   116  	// Set of objects. Detailed below
   117  	Routes DefaultRouteTableRouteArrayOutput `pulumi:"routes"`
   118  	// Map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   119  	Tags pulumi.StringMapOutput `pulumi:"tags"`
   120  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   121  	//
   122  	// Deprecated: Please use `tags` instead.
   123  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
   124  	// ID of the VPC.
   125  	VpcId pulumi.StringOutput `pulumi:"vpcId"`
   126  }
   127  
   128  // NewDefaultRouteTable registers a new resource with the given unique name, arguments, and options.
   129  func NewDefaultRouteTable(ctx *pulumi.Context,
   130  	name string, args *DefaultRouteTableArgs, opts ...pulumi.ResourceOption) (*DefaultRouteTable, error) {
   131  	if args == nil {
   132  		return nil, errors.New("missing one or more required arguments")
   133  	}
   134  
   135  	if args.DefaultRouteTableId == nil {
   136  		return nil, errors.New("invalid value for required argument 'DefaultRouteTableId'")
   137  	}
   138  	opts = internal.PkgResourceDefaultOpts(opts)
   139  	var resource DefaultRouteTable
   140  	err := ctx.RegisterResource("aws:ec2/defaultRouteTable:DefaultRouteTable", name, args, &resource, opts...)
   141  	if err != nil {
   142  		return nil, err
   143  	}
   144  	return &resource, nil
   145  }
   146  
   147  // GetDefaultRouteTable gets an existing DefaultRouteTable resource's state with the given name, ID, and optional
   148  // state properties that are used to uniquely qualify the lookup (nil if not required).
   149  func GetDefaultRouteTable(ctx *pulumi.Context,
   150  	name string, id pulumi.IDInput, state *DefaultRouteTableState, opts ...pulumi.ResourceOption) (*DefaultRouteTable, error) {
   151  	var resource DefaultRouteTable
   152  	err := ctx.ReadResource("aws:ec2/defaultRouteTable:DefaultRouteTable", name, id, state, &resource, opts...)
   153  	if err != nil {
   154  		return nil, err
   155  	}
   156  	return &resource, nil
   157  }
   158  
   159  // Input properties used for looking up and filtering DefaultRouteTable resources.
   160  type defaultRouteTableState struct {
   161  	// The ARN of the route table.
   162  	Arn *string `pulumi:"arn"`
   163  	// ID of the default route table.
   164  	//
   165  	// The following arguments are optional:
   166  	DefaultRouteTableId *string `pulumi:"defaultRouteTableId"`
   167  	// ID of the AWS account that owns the route table.
   168  	OwnerId *string `pulumi:"ownerId"`
   169  	// List of virtual gateways for propagation.
   170  	PropagatingVgws []string `pulumi:"propagatingVgws"`
   171  	// Set of objects. Detailed below
   172  	Routes []DefaultRouteTableRoute `pulumi:"routes"`
   173  	// Map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   174  	Tags map[string]string `pulumi:"tags"`
   175  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   176  	//
   177  	// Deprecated: Please use `tags` instead.
   178  	TagsAll map[string]string `pulumi:"tagsAll"`
   179  	// ID of the VPC.
   180  	VpcId *string `pulumi:"vpcId"`
   181  }
   182  
   183  type DefaultRouteTableState struct {
   184  	// The ARN of the route table.
   185  	Arn pulumi.StringPtrInput
   186  	// ID of the default route table.
   187  	//
   188  	// The following arguments are optional:
   189  	DefaultRouteTableId pulumi.StringPtrInput
   190  	// ID of the AWS account that owns the route table.
   191  	OwnerId pulumi.StringPtrInput
   192  	// List of virtual gateways for propagation.
   193  	PropagatingVgws pulumi.StringArrayInput
   194  	// Set of objects. Detailed below
   195  	Routes DefaultRouteTableRouteArrayInput
   196  	// Map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   197  	Tags pulumi.StringMapInput
   198  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   199  	//
   200  	// Deprecated: Please use `tags` instead.
   201  	TagsAll pulumi.StringMapInput
   202  	// ID of the VPC.
   203  	VpcId pulumi.StringPtrInput
   204  }
   205  
   206  func (DefaultRouteTableState) ElementType() reflect.Type {
   207  	return reflect.TypeOf((*defaultRouteTableState)(nil)).Elem()
   208  }
   209  
   210  type defaultRouteTableArgs struct {
   211  	// ID of the default route table.
   212  	//
   213  	// The following arguments are optional:
   214  	DefaultRouteTableId string `pulumi:"defaultRouteTableId"`
   215  	// List of virtual gateways for propagation.
   216  	PropagatingVgws []string `pulumi:"propagatingVgws"`
   217  	// Set of objects. Detailed below
   218  	Routes []DefaultRouteTableRoute `pulumi:"routes"`
   219  	// Map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   220  	Tags map[string]string `pulumi:"tags"`
   221  }
   222  
   223  // The set of arguments for constructing a DefaultRouteTable resource.
   224  type DefaultRouteTableArgs struct {
   225  	// ID of the default route table.
   226  	//
   227  	// The following arguments are optional:
   228  	DefaultRouteTableId pulumi.StringInput
   229  	// List of virtual gateways for propagation.
   230  	PropagatingVgws pulumi.StringArrayInput
   231  	// Set of objects. Detailed below
   232  	Routes DefaultRouteTableRouteArrayInput
   233  	// Map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   234  	Tags pulumi.StringMapInput
   235  }
   236  
   237  func (DefaultRouteTableArgs) ElementType() reflect.Type {
   238  	return reflect.TypeOf((*defaultRouteTableArgs)(nil)).Elem()
   239  }
   240  
   241  type DefaultRouteTableInput interface {
   242  	pulumi.Input
   243  
   244  	ToDefaultRouteTableOutput() DefaultRouteTableOutput
   245  	ToDefaultRouteTableOutputWithContext(ctx context.Context) DefaultRouteTableOutput
   246  }
   247  
   248  func (*DefaultRouteTable) ElementType() reflect.Type {
   249  	return reflect.TypeOf((**DefaultRouteTable)(nil)).Elem()
   250  }
   251  
   252  func (i *DefaultRouteTable) ToDefaultRouteTableOutput() DefaultRouteTableOutput {
   253  	return i.ToDefaultRouteTableOutputWithContext(context.Background())
   254  }
   255  
   256  func (i *DefaultRouteTable) ToDefaultRouteTableOutputWithContext(ctx context.Context) DefaultRouteTableOutput {
   257  	return pulumi.ToOutputWithContext(ctx, i).(DefaultRouteTableOutput)
   258  }
   259  
   260  // DefaultRouteTableArrayInput is an input type that accepts DefaultRouteTableArray and DefaultRouteTableArrayOutput values.
   261  // You can construct a concrete instance of `DefaultRouteTableArrayInput` via:
   262  //
   263  //	DefaultRouteTableArray{ DefaultRouteTableArgs{...} }
   264  type DefaultRouteTableArrayInput interface {
   265  	pulumi.Input
   266  
   267  	ToDefaultRouteTableArrayOutput() DefaultRouteTableArrayOutput
   268  	ToDefaultRouteTableArrayOutputWithContext(context.Context) DefaultRouteTableArrayOutput
   269  }
   270  
   271  type DefaultRouteTableArray []DefaultRouteTableInput
   272  
   273  func (DefaultRouteTableArray) ElementType() reflect.Type {
   274  	return reflect.TypeOf((*[]*DefaultRouteTable)(nil)).Elem()
   275  }
   276  
   277  func (i DefaultRouteTableArray) ToDefaultRouteTableArrayOutput() DefaultRouteTableArrayOutput {
   278  	return i.ToDefaultRouteTableArrayOutputWithContext(context.Background())
   279  }
   280  
   281  func (i DefaultRouteTableArray) ToDefaultRouteTableArrayOutputWithContext(ctx context.Context) DefaultRouteTableArrayOutput {
   282  	return pulumi.ToOutputWithContext(ctx, i).(DefaultRouteTableArrayOutput)
   283  }
   284  
   285  // DefaultRouteTableMapInput is an input type that accepts DefaultRouteTableMap and DefaultRouteTableMapOutput values.
   286  // You can construct a concrete instance of `DefaultRouteTableMapInput` via:
   287  //
   288  //	DefaultRouteTableMap{ "key": DefaultRouteTableArgs{...} }
   289  type DefaultRouteTableMapInput interface {
   290  	pulumi.Input
   291  
   292  	ToDefaultRouteTableMapOutput() DefaultRouteTableMapOutput
   293  	ToDefaultRouteTableMapOutputWithContext(context.Context) DefaultRouteTableMapOutput
   294  }
   295  
   296  type DefaultRouteTableMap map[string]DefaultRouteTableInput
   297  
   298  func (DefaultRouteTableMap) ElementType() reflect.Type {
   299  	return reflect.TypeOf((*map[string]*DefaultRouteTable)(nil)).Elem()
   300  }
   301  
   302  func (i DefaultRouteTableMap) ToDefaultRouteTableMapOutput() DefaultRouteTableMapOutput {
   303  	return i.ToDefaultRouteTableMapOutputWithContext(context.Background())
   304  }
   305  
   306  func (i DefaultRouteTableMap) ToDefaultRouteTableMapOutputWithContext(ctx context.Context) DefaultRouteTableMapOutput {
   307  	return pulumi.ToOutputWithContext(ctx, i).(DefaultRouteTableMapOutput)
   308  }
   309  
   310  type DefaultRouteTableOutput struct{ *pulumi.OutputState }
   311  
   312  func (DefaultRouteTableOutput) ElementType() reflect.Type {
   313  	return reflect.TypeOf((**DefaultRouteTable)(nil)).Elem()
   314  }
   315  
   316  func (o DefaultRouteTableOutput) ToDefaultRouteTableOutput() DefaultRouteTableOutput {
   317  	return o
   318  }
   319  
   320  func (o DefaultRouteTableOutput) ToDefaultRouteTableOutputWithContext(ctx context.Context) DefaultRouteTableOutput {
   321  	return o
   322  }
   323  
   324  // The ARN of the route table.
   325  func (o DefaultRouteTableOutput) Arn() pulumi.StringOutput {
   326  	return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   327  }
   328  
   329  // ID of the default route table.
   330  //
   331  // The following arguments are optional:
   332  func (o DefaultRouteTableOutput) DefaultRouteTableId() pulumi.StringOutput {
   333  	return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringOutput { return v.DefaultRouteTableId }).(pulumi.StringOutput)
   334  }
   335  
   336  // ID of the AWS account that owns the route table.
   337  func (o DefaultRouteTableOutput) OwnerId() pulumi.StringOutput {
   338  	return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringOutput { return v.OwnerId }).(pulumi.StringOutput)
   339  }
   340  
   341  // List of virtual gateways for propagation.
   342  func (o DefaultRouteTableOutput) PropagatingVgws() pulumi.StringArrayOutput {
   343  	return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringArrayOutput { return v.PropagatingVgws }).(pulumi.StringArrayOutput)
   344  }
   345  
   346  // Set of objects. Detailed below
   347  func (o DefaultRouteTableOutput) Routes() DefaultRouteTableRouteArrayOutput {
   348  	return o.ApplyT(func(v *DefaultRouteTable) DefaultRouteTableRouteArrayOutput { return v.Routes }).(DefaultRouteTableRouteArrayOutput)
   349  }
   350  
   351  // Map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   352  func (o DefaultRouteTableOutput) Tags() pulumi.StringMapOutput {
   353  	return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   354  }
   355  
   356  // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   357  //
   358  // Deprecated: Please use `tags` instead.
   359  func (o DefaultRouteTableOutput) TagsAll() pulumi.StringMapOutput {
   360  	return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   361  }
   362  
   363  // ID of the VPC.
   364  func (o DefaultRouteTableOutput) VpcId() pulumi.StringOutput {
   365  	return o.ApplyT(func(v *DefaultRouteTable) pulumi.StringOutput { return v.VpcId }).(pulumi.StringOutput)
   366  }
   367  
   368  type DefaultRouteTableArrayOutput struct{ *pulumi.OutputState }
   369  
   370  func (DefaultRouteTableArrayOutput) ElementType() reflect.Type {
   371  	return reflect.TypeOf((*[]*DefaultRouteTable)(nil)).Elem()
   372  }
   373  
   374  func (o DefaultRouteTableArrayOutput) ToDefaultRouteTableArrayOutput() DefaultRouteTableArrayOutput {
   375  	return o
   376  }
   377  
   378  func (o DefaultRouteTableArrayOutput) ToDefaultRouteTableArrayOutputWithContext(ctx context.Context) DefaultRouteTableArrayOutput {
   379  	return o
   380  }
   381  
   382  func (o DefaultRouteTableArrayOutput) Index(i pulumi.IntInput) DefaultRouteTableOutput {
   383  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *DefaultRouteTable {
   384  		return vs[0].([]*DefaultRouteTable)[vs[1].(int)]
   385  	}).(DefaultRouteTableOutput)
   386  }
   387  
   388  type DefaultRouteTableMapOutput struct{ *pulumi.OutputState }
   389  
   390  func (DefaultRouteTableMapOutput) ElementType() reflect.Type {
   391  	return reflect.TypeOf((*map[string]*DefaultRouteTable)(nil)).Elem()
   392  }
   393  
   394  func (o DefaultRouteTableMapOutput) ToDefaultRouteTableMapOutput() DefaultRouteTableMapOutput {
   395  	return o
   396  }
   397  
   398  func (o DefaultRouteTableMapOutput) ToDefaultRouteTableMapOutputWithContext(ctx context.Context) DefaultRouteTableMapOutput {
   399  	return o
   400  }
   401  
   402  func (o DefaultRouteTableMapOutput) MapIndex(k pulumi.StringInput) DefaultRouteTableOutput {
   403  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *DefaultRouteTable {
   404  		return vs[0].(map[string]*DefaultRouteTable)[vs[1].(string)]
   405  	}).(DefaultRouteTableOutput)
   406  }
   407  
   408  func init() {
   409  	pulumi.RegisterInputType(reflect.TypeOf((*DefaultRouteTableInput)(nil)).Elem(), &DefaultRouteTable{})
   410  	pulumi.RegisterInputType(reflect.TypeOf((*DefaultRouteTableArrayInput)(nil)).Elem(), DefaultRouteTableArray{})
   411  	pulumi.RegisterInputType(reflect.TypeOf((*DefaultRouteTableMapInput)(nil)).Elem(), DefaultRouteTableMap{})
   412  	pulumi.RegisterOutputType(DefaultRouteTableOutput{})
   413  	pulumi.RegisterOutputType(DefaultRouteTableArrayOutput{})
   414  	pulumi.RegisterOutputType(DefaultRouteTableMapOutput{})
   415  }