github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/routeTableAssociation.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 create an association between a route table and a subnet or a route table and an 16 // internet gateway or virtual private gateway. 17 // 18 // ## Example Usage 19 // 20 // <!--Start PulumiCodeChooser --> 21 // ```go 22 // package main 23 // 24 // import ( 25 // 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 27 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 28 // 29 // ) 30 // 31 // func main() { 32 // pulumi.Run(func(ctx *pulumi.Context) error { 33 // _, err := ec2.NewRouteTableAssociation(ctx, "a", &ec2.RouteTableAssociationArgs{ 34 // SubnetId: pulumi.Any(foo.Id), 35 // RouteTableId: pulumi.Any(bar.Id), 36 // }) 37 // if err != nil { 38 // return err 39 // } 40 // return nil 41 // }) 42 // } 43 // 44 // ``` 45 // <!--End PulumiCodeChooser --> 46 // 47 // <!--Start PulumiCodeChooser --> 48 // ```go 49 // package main 50 // 51 // import ( 52 // 53 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 54 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 55 // 56 // ) 57 // 58 // func main() { 59 // pulumi.Run(func(ctx *pulumi.Context) error { 60 // _, err := ec2.NewRouteTableAssociation(ctx, "b", &ec2.RouteTableAssociationArgs{ 61 // GatewayId: pulumi.Any(foo.Id), 62 // RouteTableId: pulumi.Any(bar.Id), 63 // }) 64 // if err != nil { 65 // return err 66 // } 67 // return nil 68 // }) 69 // } 70 // 71 // ``` 72 // <!--End PulumiCodeChooser --> 73 // 74 // ## Import 75 // 76 // With EC2 Internet Gateways: 77 // 78 // __Using `pulumi import` to import__ EC2 Route Table Associations using the associated resource ID and Route Table ID separated by a forward slash (`/`). For example: 79 // 80 // With EC2 Subnets: 81 // 82 // ```sh 83 // $ pulumi import aws:ec2/routeTableAssociation:RouteTableAssociation assoc subnet-6777656e646f6c796e/rtb-656c65616e6f72 84 // ``` 85 // With EC2 Internet Gateways: 86 // 87 // ```sh 88 // $ pulumi import aws:ec2/routeTableAssociation:RouteTableAssociation assoc igw-01b3a60780f8d034a/rtb-656c65616e6f72 89 // ``` 90 type RouteTableAssociation struct { 91 pulumi.CustomResourceState 92 93 // The gateway ID to create an association. Conflicts with `subnetId`. 94 GatewayId pulumi.StringPtrOutput `pulumi:"gatewayId"` 95 // The ID of the routing table to associate with. 96 RouteTableId pulumi.StringOutput `pulumi:"routeTableId"` 97 // The subnet ID to create an association. Conflicts with `gatewayId`. 98 SubnetId pulumi.StringPtrOutput `pulumi:"subnetId"` 99 } 100 101 // NewRouteTableAssociation registers a new resource with the given unique name, arguments, and options. 102 func NewRouteTableAssociation(ctx *pulumi.Context, 103 name string, args *RouteTableAssociationArgs, opts ...pulumi.ResourceOption) (*RouteTableAssociation, error) { 104 if args == nil { 105 return nil, errors.New("missing one or more required arguments") 106 } 107 108 if args.RouteTableId == nil { 109 return nil, errors.New("invalid value for required argument 'RouteTableId'") 110 } 111 opts = internal.PkgResourceDefaultOpts(opts) 112 var resource RouteTableAssociation 113 err := ctx.RegisterResource("aws:ec2/routeTableAssociation:RouteTableAssociation", name, args, &resource, opts...) 114 if err != nil { 115 return nil, err 116 } 117 return &resource, nil 118 } 119 120 // GetRouteTableAssociation gets an existing RouteTableAssociation resource's state with the given name, ID, and optional 121 // state properties that are used to uniquely qualify the lookup (nil if not required). 122 func GetRouteTableAssociation(ctx *pulumi.Context, 123 name string, id pulumi.IDInput, state *RouteTableAssociationState, opts ...pulumi.ResourceOption) (*RouteTableAssociation, error) { 124 var resource RouteTableAssociation 125 err := ctx.ReadResource("aws:ec2/routeTableAssociation:RouteTableAssociation", name, id, state, &resource, opts...) 126 if err != nil { 127 return nil, err 128 } 129 return &resource, nil 130 } 131 132 // Input properties used for looking up and filtering RouteTableAssociation resources. 133 type routeTableAssociationState struct { 134 // The gateway ID to create an association. Conflicts with `subnetId`. 135 GatewayId *string `pulumi:"gatewayId"` 136 // The ID of the routing table to associate with. 137 RouteTableId *string `pulumi:"routeTableId"` 138 // The subnet ID to create an association. Conflicts with `gatewayId`. 139 SubnetId *string `pulumi:"subnetId"` 140 } 141 142 type RouteTableAssociationState struct { 143 // The gateway ID to create an association. Conflicts with `subnetId`. 144 GatewayId pulumi.StringPtrInput 145 // The ID of the routing table to associate with. 146 RouteTableId pulumi.StringPtrInput 147 // The subnet ID to create an association. Conflicts with `gatewayId`. 148 SubnetId pulumi.StringPtrInput 149 } 150 151 func (RouteTableAssociationState) ElementType() reflect.Type { 152 return reflect.TypeOf((*routeTableAssociationState)(nil)).Elem() 153 } 154 155 type routeTableAssociationArgs struct { 156 // The gateway ID to create an association. Conflicts with `subnetId`. 157 GatewayId *string `pulumi:"gatewayId"` 158 // The ID of the routing table to associate with. 159 RouteTableId string `pulumi:"routeTableId"` 160 // The subnet ID to create an association. Conflicts with `gatewayId`. 161 SubnetId *string `pulumi:"subnetId"` 162 } 163 164 // The set of arguments for constructing a RouteTableAssociation resource. 165 type RouteTableAssociationArgs struct { 166 // The gateway ID to create an association. Conflicts with `subnetId`. 167 GatewayId pulumi.StringPtrInput 168 // The ID of the routing table to associate with. 169 RouteTableId pulumi.StringInput 170 // The subnet ID to create an association. Conflicts with `gatewayId`. 171 SubnetId pulumi.StringPtrInput 172 } 173 174 func (RouteTableAssociationArgs) ElementType() reflect.Type { 175 return reflect.TypeOf((*routeTableAssociationArgs)(nil)).Elem() 176 } 177 178 type RouteTableAssociationInput interface { 179 pulumi.Input 180 181 ToRouteTableAssociationOutput() RouteTableAssociationOutput 182 ToRouteTableAssociationOutputWithContext(ctx context.Context) RouteTableAssociationOutput 183 } 184 185 func (*RouteTableAssociation) ElementType() reflect.Type { 186 return reflect.TypeOf((**RouteTableAssociation)(nil)).Elem() 187 } 188 189 func (i *RouteTableAssociation) ToRouteTableAssociationOutput() RouteTableAssociationOutput { 190 return i.ToRouteTableAssociationOutputWithContext(context.Background()) 191 } 192 193 func (i *RouteTableAssociation) ToRouteTableAssociationOutputWithContext(ctx context.Context) RouteTableAssociationOutput { 194 return pulumi.ToOutputWithContext(ctx, i).(RouteTableAssociationOutput) 195 } 196 197 // RouteTableAssociationArrayInput is an input type that accepts RouteTableAssociationArray and RouteTableAssociationArrayOutput values. 198 // You can construct a concrete instance of `RouteTableAssociationArrayInput` via: 199 // 200 // RouteTableAssociationArray{ RouteTableAssociationArgs{...} } 201 type RouteTableAssociationArrayInput interface { 202 pulumi.Input 203 204 ToRouteTableAssociationArrayOutput() RouteTableAssociationArrayOutput 205 ToRouteTableAssociationArrayOutputWithContext(context.Context) RouteTableAssociationArrayOutput 206 } 207 208 type RouteTableAssociationArray []RouteTableAssociationInput 209 210 func (RouteTableAssociationArray) ElementType() reflect.Type { 211 return reflect.TypeOf((*[]*RouteTableAssociation)(nil)).Elem() 212 } 213 214 func (i RouteTableAssociationArray) ToRouteTableAssociationArrayOutput() RouteTableAssociationArrayOutput { 215 return i.ToRouteTableAssociationArrayOutputWithContext(context.Background()) 216 } 217 218 func (i RouteTableAssociationArray) ToRouteTableAssociationArrayOutputWithContext(ctx context.Context) RouteTableAssociationArrayOutput { 219 return pulumi.ToOutputWithContext(ctx, i).(RouteTableAssociationArrayOutput) 220 } 221 222 // RouteTableAssociationMapInput is an input type that accepts RouteTableAssociationMap and RouteTableAssociationMapOutput values. 223 // You can construct a concrete instance of `RouteTableAssociationMapInput` via: 224 // 225 // RouteTableAssociationMap{ "key": RouteTableAssociationArgs{...} } 226 type RouteTableAssociationMapInput interface { 227 pulumi.Input 228 229 ToRouteTableAssociationMapOutput() RouteTableAssociationMapOutput 230 ToRouteTableAssociationMapOutputWithContext(context.Context) RouteTableAssociationMapOutput 231 } 232 233 type RouteTableAssociationMap map[string]RouteTableAssociationInput 234 235 func (RouteTableAssociationMap) ElementType() reflect.Type { 236 return reflect.TypeOf((*map[string]*RouteTableAssociation)(nil)).Elem() 237 } 238 239 func (i RouteTableAssociationMap) ToRouteTableAssociationMapOutput() RouteTableAssociationMapOutput { 240 return i.ToRouteTableAssociationMapOutputWithContext(context.Background()) 241 } 242 243 func (i RouteTableAssociationMap) ToRouteTableAssociationMapOutputWithContext(ctx context.Context) RouteTableAssociationMapOutput { 244 return pulumi.ToOutputWithContext(ctx, i).(RouteTableAssociationMapOutput) 245 } 246 247 type RouteTableAssociationOutput struct{ *pulumi.OutputState } 248 249 func (RouteTableAssociationOutput) ElementType() reflect.Type { 250 return reflect.TypeOf((**RouteTableAssociation)(nil)).Elem() 251 } 252 253 func (o RouteTableAssociationOutput) ToRouteTableAssociationOutput() RouteTableAssociationOutput { 254 return o 255 } 256 257 func (o RouteTableAssociationOutput) ToRouteTableAssociationOutputWithContext(ctx context.Context) RouteTableAssociationOutput { 258 return o 259 } 260 261 // The gateway ID to create an association. Conflicts with `subnetId`. 262 func (o RouteTableAssociationOutput) GatewayId() pulumi.StringPtrOutput { 263 return o.ApplyT(func(v *RouteTableAssociation) pulumi.StringPtrOutput { return v.GatewayId }).(pulumi.StringPtrOutput) 264 } 265 266 // The ID of the routing table to associate with. 267 func (o RouteTableAssociationOutput) RouteTableId() pulumi.StringOutput { 268 return o.ApplyT(func(v *RouteTableAssociation) pulumi.StringOutput { return v.RouteTableId }).(pulumi.StringOutput) 269 } 270 271 // The subnet ID to create an association. Conflicts with `gatewayId`. 272 func (o RouteTableAssociationOutput) SubnetId() pulumi.StringPtrOutput { 273 return o.ApplyT(func(v *RouteTableAssociation) pulumi.StringPtrOutput { return v.SubnetId }).(pulumi.StringPtrOutput) 274 } 275 276 type RouteTableAssociationArrayOutput struct{ *pulumi.OutputState } 277 278 func (RouteTableAssociationArrayOutput) ElementType() reflect.Type { 279 return reflect.TypeOf((*[]*RouteTableAssociation)(nil)).Elem() 280 } 281 282 func (o RouteTableAssociationArrayOutput) ToRouteTableAssociationArrayOutput() RouteTableAssociationArrayOutput { 283 return o 284 } 285 286 func (o RouteTableAssociationArrayOutput) ToRouteTableAssociationArrayOutputWithContext(ctx context.Context) RouteTableAssociationArrayOutput { 287 return o 288 } 289 290 func (o RouteTableAssociationArrayOutput) Index(i pulumi.IntInput) RouteTableAssociationOutput { 291 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *RouteTableAssociation { 292 return vs[0].([]*RouteTableAssociation)[vs[1].(int)] 293 }).(RouteTableAssociationOutput) 294 } 295 296 type RouteTableAssociationMapOutput struct{ *pulumi.OutputState } 297 298 func (RouteTableAssociationMapOutput) ElementType() reflect.Type { 299 return reflect.TypeOf((*map[string]*RouteTableAssociation)(nil)).Elem() 300 } 301 302 func (o RouteTableAssociationMapOutput) ToRouteTableAssociationMapOutput() RouteTableAssociationMapOutput { 303 return o 304 } 305 306 func (o RouteTableAssociationMapOutput) ToRouteTableAssociationMapOutputWithContext(ctx context.Context) RouteTableAssociationMapOutput { 307 return o 308 } 309 310 func (o RouteTableAssociationMapOutput) MapIndex(k pulumi.StringInput) RouteTableAssociationOutput { 311 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *RouteTableAssociation { 312 return vs[0].(map[string]*RouteTableAssociation)[vs[1].(string)] 313 }).(RouteTableAssociationOutput) 314 } 315 316 func init() { 317 pulumi.RegisterInputType(reflect.TypeOf((*RouteTableAssociationInput)(nil)).Elem(), &RouteTableAssociation{}) 318 pulumi.RegisterInputType(reflect.TypeOf((*RouteTableAssociationArrayInput)(nil)).Elem(), RouteTableAssociationArray{}) 319 pulumi.RegisterInputType(reflect.TypeOf((*RouteTableAssociationMapInput)(nil)).Elem(), RouteTableAssociationMap{}) 320 pulumi.RegisterOutputType(RouteTableAssociationOutput{}) 321 pulumi.RegisterOutputType(RouteTableAssociationArrayOutput{}) 322 pulumi.RegisterOutputType(RouteTableAssociationMapOutput{}) 323 }