github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2transitgateway/route.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 ec2transitgateway 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 // Manages an EC2 Transit Gateway Route. 16 // 17 // ## Example Usage 18 // 19 // ### Standard usage 20 // 21 // <!--Start PulumiCodeChooser --> 22 // ```go 23 // package main 24 // 25 // import ( 26 // 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2transitgateway" 28 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 29 // 30 // ) 31 // 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // _, err := ec2transitgateway.NewRoute(ctx, "example", &ec2transitgateway.RouteArgs{ 35 // DestinationCidrBlock: pulumi.String("0.0.0.0/0"), 36 // TransitGatewayAttachmentId: pulumi.Any(exampleAwsEc2TransitGatewayVpcAttachment.Id), 37 // TransitGatewayRouteTableId: pulumi.Any(exampleAwsEc2TransitGateway.AssociationDefaultRouteTableId), 38 // }) 39 // if err != nil { 40 // return err 41 // } 42 // return nil 43 // }) 44 // } 45 // 46 // ``` 47 // <!--End PulumiCodeChooser --> 48 // 49 // ### Blackhole route 50 // 51 // <!--Start PulumiCodeChooser --> 52 // ```go 53 // package main 54 // 55 // import ( 56 // 57 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2transitgateway" 58 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 59 // 60 // ) 61 // 62 // func main() { 63 // pulumi.Run(func(ctx *pulumi.Context) error { 64 // _, err := ec2transitgateway.NewRoute(ctx, "example", &ec2transitgateway.RouteArgs{ 65 // DestinationCidrBlock: pulumi.String("0.0.0.0/0"), 66 // Blackhole: pulumi.Bool(true), 67 // TransitGatewayRouteTableId: pulumi.Any(exampleAwsEc2TransitGateway.AssociationDefaultRouteTableId), 68 // }) 69 // if err != nil { 70 // return err 71 // } 72 // return nil 73 // }) 74 // } 75 // 76 // ``` 77 // <!--End PulumiCodeChooser --> 78 // 79 // ## Import 80 // 81 // Using `pulumi import`, import `aws_ec2_transit_gateway_route` using the EC2 Transit Gateway Route Table, an underscore, and the destination. For example: 82 // 83 // ```sh 84 // $ pulumi import aws:ec2transitgateway/route:Route example tgw-rtb-12345678_0.0.0.0/0 85 // ``` 86 type Route struct { 87 pulumi.CustomResourceState 88 89 // Indicates whether to drop traffic that matches this route (default to `false`). 90 Blackhole pulumi.BoolPtrOutput `pulumi:"blackhole"` 91 // IPv4 or IPv6 RFC1924 CIDR used for destination matches. Routing decisions are based on the most specific match. 92 DestinationCidrBlock pulumi.StringOutput `pulumi:"destinationCidrBlock"` 93 // Identifier of EC2 Transit Gateway Attachment (required if `blackhole` is set to false). 94 TransitGatewayAttachmentId pulumi.StringPtrOutput `pulumi:"transitGatewayAttachmentId"` 95 // Identifier of EC2 Transit Gateway Route Table. 96 TransitGatewayRouteTableId pulumi.StringOutput `pulumi:"transitGatewayRouteTableId"` 97 } 98 99 // NewRoute registers a new resource with the given unique name, arguments, and options. 100 func NewRoute(ctx *pulumi.Context, 101 name string, args *RouteArgs, opts ...pulumi.ResourceOption) (*Route, error) { 102 if args == nil { 103 return nil, errors.New("missing one or more required arguments") 104 } 105 106 if args.DestinationCidrBlock == nil { 107 return nil, errors.New("invalid value for required argument 'DestinationCidrBlock'") 108 } 109 if args.TransitGatewayRouteTableId == nil { 110 return nil, errors.New("invalid value for required argument 'TransitGatewayRouteTableId'") 111 } 112 opts = internal.PkgResourceDefaultOpts(opts) 113 var resource Route 114 err := ctx.RegisterResource("aws:ec2transitgateway/route:Route", name, args, &resource, opts...) 115 if err != nil { 116 return nil, err 117 } 118 return &resource, nil 119 } 120 121 // GetRoute gets an existing Route resource's state with the given name, ID, and optional 122 // state properties that are used to uniquely qualify the lookup (nil if not required). 123 func GetRoute(ctx *pulumi.Context, 124 name string, id pulumi.IDInput, state *RouteState, opts ...pulumi.ResourceOption) (*Route, error) { 125 var resource Route 126 err := ctx.ReadResource("aws:ec2transitgateway/route:Route", name, id, state, &resource, opts...) 127 if err != nil { 128 return nil, err 129 } 130 return &resource, nil 131 } 132 133 // Input properties used for looking up and filtering Route resources. 134 type routeState struct { 135 // Indicates whether to drop traffic that matches this route (default to `false`). 136 Blackhole *bool `pulumi:"blackhole"` 137 // IPv4 or IPv6 RFC1924 CIDR used for destination matches. Routing decisions are based on the most specific match. 138 DestinationCidrBlock *string `pulumi:"destinationCidrBlock"` 139 // Identifier of EC2 Transit Gateway Attachment (required if `blackhole` is set to false). 140 TransitGatewayAttachmentId *string `pulumi:"transitGatewayAttachmentId"` 141 // Identifier of EC2 Transit Gateway Route Table. 142 TransitGatewayRouteTableId *string `pulumi:"transitGatewayRouteTableId"` 143 } 144 145 type RouteState struct { 146 // Indicates whether to drop traffic that matches this route (default to `false`). 147 Blackhole pulumi.BoolPtrInput 148 // IPv4 or IPv6 RFC1924 CIDR used for destination matches. Routing decisions are based on the most specific match. 149 DestinationCidrBlock pulumi.StringPtrInput 150 // Identifier of EC2 Transit Gateway Attachment (required if `blackhole` is set to false). 151 TransitGatewayAttachmentId pulumi.StringPtrInput 152 // Identifier of EC2 Transit Gateway Route Table. 153 TransitGatewayRouteTableId pulumi.StringPtrInput 154 } 155 156 func (RouteState) ElementType() reflect.Type { 157 return reflect.TypeOf((*routeState)(nil)).Elem() 158 } 159 160 type routeArgs struct { 161 // Indicates whether to drop traffic that matches this route (default to `false`). 162 Blackhole *bool `pulumi:"blackhole"` 163 // IPv4 or IPv6 RFC1924 CIDR used for destination matches. Routing decisions are based on the most specific match. 164 DestinationCidrBlock string `pulumi:"destinationCidrBlock"` 165 // Identifier of EC2 Transit Gateway Attachment (required if `blackhole` is set to false). 166 TransitGatewayAttachmentId *string `pulumi:"transitGatewayAttachmentId"` 167 // Identifier of EC2 Transit Gateway Route Table. 168 TransitGatewayRouteTableId string `pulumi:"transitGatewayRouteTableId"` 169 } 170 171 // The set of arguments for constructing a Route resource. 172 type RouteArgs struct { 173 // Indicates whether to drop traffic that matches this route (default to `false`). 174 Blackhole pulumi.BoolPtrInput 175 // IPv4 or IPv6 RFC1924 CIDR used for destination matches. Routing decisions are based on the most specific match. 176 DestinationCidrBlock pulumi.StringInput 177 // Identifier of EC2 Transit Gateway Attachment (required if `blackhole` is set to false). 178 TransitGatewayAttachmentId pulumi.StringPtrInput 179 // Identifier of EC2 Transit Gateway Route Table. 180 TransitGatewayRouteTableId pulumi.StringInput 181 } 182 183 func (RouteArgs) ElementType() reflect.Type { 184 return reflect.TypeOf((*routeArgs)(nil)).Elem() 185 } 186 187 type RouteInput interface { 188 pulumi.Input 189 190 ToRouteOutput() RouteOutput 191 ToRouteOutputWithContext(ctx context.Context) RouteOutput 192 } 193 194 func (*Route) ElementType() reflect.Type { 195 return reflect.TypeOf((**Route)(nil)).Elem() 196 } 197 198 func (i *Route) ToRouteOutput() RouteOutput { 199 return i.ToRouteOutputWithContext(context.Background()) 200 } 201 202 func (i *Route) ToRouteOutputWithContext(ctx context.Context) RouteOutput { 203 return pulumi.ToOutputWithContext(ctx, i).(RouteOutput) 204 } 205 206 // RouteArrayInput is an input type that accepts RouteArray and RouteArrayOutput values. 207 // You can construct a concrete instance of `RouteArrayInput` via: 208 // 209 // RouteArray{ RouteArgs{...} } 210 type RouteArrayInput interface { 211 pulumi.Input 212 213 ToRouteArrayOutput() RouteArrayOutput 214 ToRouteArrayOutputWithContext(context.Context) RouteArrayOutput 215 } 216 217 type RouteArray []RouteInput 218 219 func (RouteArray) ElementType() reflect.Type { 220 return reflect.TypeOf((*[]*Route)(nil)).Elem() 221 } 222 223 func (i RouteArray) ToRouteArrayOutput() RouteArrayOutput { 224 return i.ToRouteArrayOutputWithContext(context.Background()) 225 } 226 227 func (i RouteArray) ToRouteArrayOutputWithContext(ctx context.Context) RouteArrayOutput { 228 return pulumi.ToOutputWithContext(ctx, i).(RouteArrayOutput) 229 } 230 231 // RouteMapInput is an input type that accepts RouteMap and RouteMapOutput values. 232 // You can construct a concrete instance of `RouteMapInput` via: 233 // 234 // RouteMap{ "key": RouteArgs{...} } 235 type RouteMapInput interface { 236 pulumi.Input 237 238 ToRouteMapOutput() RouteMapOutput 239 ToRouteMapOutputWithContext(context.Context) RouteMapOutput 240 } 241 242 type RouteMap map[string]RouteInput 243 244 func (RouteMap) ElementType() reflect.Type { 245 return reflect.TypeOf((*map[string]*Route)(nil)).Elem() 246 } 247 248 func (i RouteMap) ToRouteMapOutput() RouteMapOutput { 249 return i.ToRouteMapOutputWithContext(context.Background()) 250 } 251 252 func (i RouteMap) ToRouteMapOutputWithContext(ctx context.Context) RouteMapOutput { 253 return pulumi.ToOutputWithContext(ctx, i).(RouteMapOutput) 254 } 255 256 type RouteOutput struct{ *pulumi.OutputState } 257 258 func (RouteOutput) ElementType() reflect.Type { 259 return reflect.TypeOf((**Route)(nil)).Elem() 260 } 261 262 func (o RouteOutput) ToRouteOutput() RouteOutput { 263 return o 264 } 265 266 func (o RouteOutput) ToRouteOutputWithContext(ctx context.Context) RouteOutput { 267 return o 268 } 269 270 // Indicates whether to drop traffic that matches this route (default to `false`). 271 func (o RouteOutput) Blackhole() pulumi.BoolPtrOutput { 272 return o.ApplyT(func(v *Route) pulumi.BoolPtrOutput { return v.Blackhole }).(pulumi.BoolPtrOutput) 273 } 274 275 // IPv4 or IPv6 RFC1924 CIDR used for destination matches. Routing decisions are based on the most specific match. 276 func (o RouteOutput) DestinationCidrBlock() pulumi.StringOutput { 277 return o.ApplyT(func(v *Route) pulumi.StringOutput { return v.DestinationCidrBlock }).(pulumi.StringOutput) 278 } 279 280 // Identifier of EC2 Transit Gateway Attachment (required if `blackhole` is set to false). 281 func (o RouteOutput) TransitGatewayAttachmentId() pulumi.StringPtrOutput { 282 return o.ApplyT(func(v *Route) pulumi.StringPtrOutput { return v.TransitGatewayAttachmentId }).(pulumi.StringPtrOutput) 283 } 284 285 // Identifier of EC2 Transit Gateway Route Table. 286 func (o RouteOutput) TransitGatewayRouteTableId() pulumi.StringOutput { 287 return o.ApplyT(func(v *Route) pulumi.StringOutput { return v.TransitGatewayRouteTableId }).(pulumi.StringOutput) 288 } 289 290 type RouteArrayOutput struct{ *pulumi.OutputState } 291 292 func (RouteArrayOutput) ElementType() reflect.Type { 293 return reflect.TypeOf((*[]*Route)(nil)).Elem() 294 } 295 296 func (o RouteArrayOutput) ToRouteArrayOutput() RouteArrayOutput { 297 return o 298 } 299 300 func (o RouteArrayOutput) ToRouteArrayOutputWithContext(ctx context.Context) RouteArrayOutput { 301 return o 302 } 303 304 func (o RouteArrayOutput) Index(i pulumi.IntInput) RouteOutput { 305 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Route { 306 return vs[0].([]*Route)[vs[1].(int)] 307 }).(RouteOutput) 308 } 309 310 type RouteMapOutput struct{ *pulumi.OutputState } 311 312 func (RouteMapOutput) ElementType() reflect.Type { 313 return reflect.TypeOf((*map[string]*Route)(nil)).Elem() 314 } 315 316 func (o RouteMapOutput) ToRouteMapOutput() RouteMapOutput { 317 return o 318 } 319 320 func (o RouteMapOutput) ToRouteMapOutputWithContext(ctx context.Context) RouteMapOutput { 321 return o 322 } 323 324 func (o RouteMapOutput) MapIndex(k pulumi.StringInput) RouteOutput { 325 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Route { 326 return vs[0].(map[string]*Route)[vs[1].(string)] 327 }).(RouteOutput) 328 } 329 330 func init() { 331 pulumi.RegisterInputType(reflect.TypeOf((*RouteInput)(nil)).Elem(), &Route{}) 332 pulumi.RegisterInputType(reflect.TypeOf((*RouteArrayInput)(nil)).Elem(), RouteArray{}) 333 pulumi.RegisterInputType(reflect.TypeOf((*RouteMapInput)(nil)).Elem(), RouteMap{}) 334 pulumi.RegisterOutputType(RouteOutput{}) 335 pulumi.RegisterOutputType(RouteArrayOutput{}) 336 pulumi.RegisterOutputType(RouteMapOutput{}) 337 }