github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/alb/targetGroupAttachment.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 alb 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 the ability to register instances and containers with an Application Load Balancer (ALB) or Network Load Balancer (NLB) target group. For attaching resources with Elastic Load Balancer (ELB), see the `elb.Attachment` resource. 16 // 17 // > **Note:** `alb.TargetGroupAttachment` is known as `lb.TargetGroupAttachment`. The functionality is identical. 18 // 19 // ## Example Usage 20 // 21 // ### Basic Usage 22 // 23 // <!--Start PulumiCodeChooser --> 24 // ```go 25 // package main 26 // 27 // import ( 28 // 29 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 30 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lb" 31 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 32 // 33 // ) 34 // 35 // func main() { 36 // pulumi.Run(func(ctx *pulumi.Context) error { 37 // testTargetGroup, err := lb.NewTargetGroup(ctx, "test", nil) 38 // if err != nil { 39 // return err 40 // } 41 // testInstance, err := ec2.NewInstance(ctx, "test", nil) 42 // if err != nil { 43 // return err 44 // } 45 // _, err = lb.NewTargetGroupAttachment(ctx, "test", &lb.TargetGroupAttachmentArgs{ 46 // TargetGroupArn: testTargetGroup.Arn, 47 // TargetId: testInstance.ID(), 48 // Port: pulumi.Int(80), 49 // }) 50 // if err != nil { 51 // return err 52 // } 53 // return nil 54 // }) 55 // } 56 // 57 // ``` 58 // <!--End PulumiCodeChooser --> 59 // 60 // ### Lambda Target 61 // 62 // <!--Start PulumiCodeChooser --> 63 // ```go 64 // package main 65 // 66 // import ( 67 // 68 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lambda" 69 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lb" 70 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 71 // 72 // ) 73 // 74 // func main() { 75 // pulumi.Run(func(ctx *pulumi.Context) error { 76 // test, err := lb.NewTargetGroup(ctx, "test", &lb.TargetGroupArgs{ 77 // Name: pulumi.String("test"), 78 // TargetType: pulumi.String("lambda"), 79 // }) 80 // if err != nil { 81 // return err 82 // } 83 // testFunction, err := lambda.NewFunction(ctx, "test", nil) 84 // if err != nil { 85 // return err 86 // } 87 // withLb, err := lambda.NewPermission(ctx, "with_lb", &lambda.PermissionArgs{ 88 // StatementId: pulumi.String("AllowExecutionFromlb"), 89 // Action: pulumi.String("lambda:InvokeFunction"), 90 // Function: testFunction.Name, 91 // Principal: pulumi.String("elasticloadbalancing.amazonaws.com"), 92 // SourceArn: test.Arn, 93 // }) 94 // if err != nil { 95 // return err 96 // } 97 // _, err = lb.NewTargetGroupAttachment(ctx, "test", &lb.TargetGroupAttachmentArgs{ 98 // TargetGroupArn: test.Arn, 99 // TargetId: testFunction.Arn, 100 // }, pulumi.DependsOn([]pulumi.Resource{ 101 // withLb, 102 // })) 103 // if err != nil { 104 // return err 105 // } 106 // return nil 107 // }) 108 // } 109 // 110 // ``` 111 // <!--End PulumiCodeChooser --> 112 type TargetGroupAttachment struct { 113 pulumi.CustomResourceState 114 115 // The Availability Zone where the IP address of the target is to be registered. If the private IP address is outside of the VPC scope, this value must be set to `all`. 116 AvailabilityZone pulumi.StringPtrOutput `pulumi:"availabilityZone"` 117 // The port on which targets receive traffic. 118 Port pulumi.IntPtrOutput `pulumi:"port"` 119 // The ARN of the target group with which to register targets. 120 TargetGroupArn pulumi.StringOutput `pulumi:"targetGroupArn"` 121 // The ID of the target. This is the Instance ID for an instance, or the container ID for an ECS container. If the target type is `ip`, specify an IP address. If the target type is `lambda`, specify the Lambda function ARN. If the target type is `alb`, specify the ALB ARN. 122 // 123 // The following arguments are optional: 124 TargetId pulumi.StringOutput `pulumi:"targetId"` 125 } 126 127 // NewTargetGroupAttachment registers a new resource with the given unique name, arguments, and options. 128 func NewTargetGroupAttachment(ctx *pulumi.Context, 129 name string, args *TargetGroupAttachmentArgs, opts ...pulumi.ResourceOption) (*TargetGroupAttachment, error) { 130 if args == nil { 131 return nil, errors.New("missing one or more required arguments") 132 } 133 134 if args.TargetGroupArn == nil { 135 return nil, errors.New("invalid value for required argument 'TargetGroupArn'") 136 } 137 if args.TargetId == nil { 138 return nil, errors.New("invalid value for required argument 'TargetId'") 139 } 140 aliases := pulumi.Aliases([]pulumi.Alias{ 141 { 142 Type: pulumi.String("aws:applicationloadbalancing/targetGroupAttachment:TargetGroupAttachment"), 143 }, 144 }) 145 opts = append(opts, aliases) 146 opts = internal.PkgResourceDefaultOpts(opts) 147 var resource TargetGroupAttachment 148 err := ctx.RegisterResource("aws:alb/targetGroupAttachment:TargetGroupAttachment", name, args, &resource, opts...) 149 if err != nil { 150 return nil, err 151 } 152 return &resource, nil 153 } 154 155 // GetTargetGroupAttachment gets an existing TargetGroupAttachment resource's state with the given name, ID, and optional 156 // state properties that are used to uniquely qualify the lookup (nil if not required). 157 func GetTargetGroupAttachment(ctx *pulumi.Context, 158 name string, id pulumi.IDInput, state *TargetGroupAttachmentState, opts ...pulumi.ResourceOption) (*TargetGroupAttachment, error) { 159 var resource TargetGroupAttachment 160 err := ctx.ReadResource("aws:alb/targetGroupAttachment:TargetGroupAttachment", name, id, state, &resource, opts...) 161 if err != nil { 162 return nil, err 163 } 164 return &resource, nil 165 } 166 167 // Input properties used for looking up and filtering TargetGroupAttachment resources. 168 type targetGroupAttachmentState struct { 169 // The Availability Zone where the IP address of the target is to be registered. If the private IP address is outside of the VPC scope, this value must be set to `all`. 170 AvailabilityZone *string `pulumi:"availabilityZone"` 171 // The port on which targets receive traffic. 172 Port *int `pulumi:"port"` 173 // The ARN of the target group with which to register targets. 174 TargetGroupArn *string `pulumi:"targetGroupArn"` 175 // The ID of the target. This is the Instance ID for an instance, or the container ID for an ECS container. If the target type is `ip`, specify an IP address. If the target type is `lambda`, specify the Lambda function ARN. If the target type is `alb`, specify the ALB ARN. 176 // 177 // The following arguments are optional: 178 TargetId *string `pulumi:"targetId"` 179 } 180 181 type TargetGroupAttachmentState struct { 182 // The Availability Zone where the IP address of the target is to be registered. If the private IP address is outside of the VPC scope, this value must be set to `all`. 183 AvailabilityZone pulumi.StringPtrInput 184 // The port on which targets receive traffic. 185 Port pulumi.IntPtrInput 186 // The ARN of the target group with which to register targets. 187 TargetGroupArn pulumi.StringPtrInput 188 // The ID of the target. This is the Instance ID for an instance, or the container ID for an ECS container. If the target type is `ip`, specify an IP address. If the target type is `lambda`, specify the Lambda function ARN. If the target type is `alb`, specify the ALB ARN. 189 // 190 // The following arguments are optional: 191 TargetId pulumi.StringPtrInput 192 } 193 194 func (TargetGroupAttachmentState) ElementType() reflect.Type { 195 return reflect.TypeOf((*targetGroupAttachmentState)(nil)).Elem() 196 } 197 198 type targetGroupAttachmentArgs struct { 199 // The Availability Zone where the IP address of the target is to be registered. If the private IP address is outside of the VPC scope, this value must be set to `all`. 200 AvailabilityZone *string `pulumi:"availabilityZone"` 201 // The port on which targets receive traffic. 202 Port *int `pulumi:"port"` 203 // The ARN of the target group with which to register targets. 204 TargetGroupArn string `pulumi:"targetGroupArn"` 205 // The ID of the target. This is the Instance ID for an instance, or the container ID for an ECS container. If the target type is `ip`, specify an IP address. If the target type is `lambda`, specify the Lambda function ARN. If the target type is `alb`, specify the ALB ARN. 206 // 207 // The following arguments are optional: 208 TargetId string `pulumi:"targetId"` 209 } 210 211 // The set of arguments for constructing a TargetGroupAttachment resource. 212 type TargetGroupAttachmentArgs struct { 213 // The Availability Zone where the IP address of the target is to be registered. If the private IP address is outside of the VPC scope, this value must be set to `all`. 214 AvailabilityZone pulumi.StringPtrInput 215 // The port on which targets receive traffic. 216 Port pulumi.IntPtrInput 217 // The ARN of the target group with which to register targets. 218 TargetGroupArn pulumi.StringInput 219 // The ID of the target. This is the Instance ID for an instance, or the container ID for an ECS container. If the target type is `ip`, specify an IP address. If the target type is `lambda`, specify the Lambda function ARN. If the target type is `alb`, specify the ALB ARN. 220 // 221 // The following arguments are optional: 222 TargetId pulumi.StringInput 223 } 224 225 func (TargetGroupAttachmentArgs) ElementType() reflect.Type { 226 return reflect.TypeOf((*targetGroupAttachmentArgs)(nil)).Elem() 227 } 228 229 type TargetGroupAttachmentInput interface { 230 pulumi.Input 231 232 ToTargetGroupAttachmentOutput() TargetGroupAttachmentOutput 233 ToTargetGroupAttachmentOutputWithContext(ctx context.Context) TargetGroupAttachmentOutput 234 } 235 236 func (*TargetGroupAttachment) ElementType() reflect.Type { 237 return reflect.TypeOf((**TargetGroupAttachment)(nil)).Elem() 238 } 239 240 func (i *TargetGroupAttachment) ToTargetGroupAttachmentOutput() TargetGroupAttachmentOutput { 241 return i.ToTargetGroupAttachmentOutputWithContext(context.Background()) 242 } 243 244 func (i *TargetGroupAttachment) ToTargetGroupAttachmentOutputWithContext(ctx context.Context) TargetGroupAttachmentOutput { 245 return pulumi.ToOutputWithContext(ctx, i).(TargetGroupAttachmentOutput) 246 } 247 248 // TargetGroupAttachmentArrayInput is an input type that accepts TargetGroupAttachmentArray and TargetGroupAttachmentArrayOutput values. 249 // You can construct a concrete instance of `TargetGroupAttachmentArrayInput` via: 250 // 251 // TargetGroupAttachmentArray{ TargetGroupAttachmentArgs{...} } 252 type TargetGroupAttachmentArrayInput interface { 253 pulumi.Input 254 255 ToTargetGroupAttachmentArrayOutput() TargetGroupAttachmentArrayOutput 256 ToTargetGroupAttachmentArrayOutputWithContext(context.Context) TargetGroupAttachmentArrayOutput 257 } 258 259 type TargetGroupAttachmentArray []TargetGroupAttachmentInput 260 261 func (TargetGroupAttachmentArray) ElementType() reflect.Type { 262 return reflect.TypeOf((*[]*TargetGroupAttachment)(nil)).Elem() 263 } 264 265 func (i TargetGroupAttachmentArray) ToTargetGroupAttachmentArrayOutput() TargetGroupAttachmentArrayOutput { 266 return i.ToTargetGroupAttachmentArrayOutputWithContext(context.Background()) 267 } 268 269 func (i TargetGroupAttachmentArray) ToTargetGroupAttachmentArrayOutputWithContext(ctx context.Context) TargetGroupAttachmentArrayOutput { 270 return pulumi.ToOutputWithContext(ctx, i).(TargetGroupAttachmentArrayOutput) 271 } 272 273 // TargetGroupAttachmentMapInput is an input type that accepts TargetGroupAttachmentMap and TargetGroupAttachmentMapOutput values. 274 // You can construct a concrete instance of `TargetGroupAttachmentMapInput` via: 275 // 276 // TargetGroupAttachmentMap{ "key": TargetGroupAttachmentArgs{...} } 277 type TargetGroupAttachmentMapInput interface { 278 pulumi.Input 279 280 ToTargetGroupAttachmentMapOutput() TargetGroupAttachmentMapOutput 281 ToTargetGroupAttachmentMapOutputWithContext(context.Context) TargetGroupAttachmentMapOutput 282 } 283 284 type TargetGroupAttachmentMap map[string]TargetGroupAttachmentInput 285 286 func (TargetGroupAttachmentMap) ElementType() reflect.Type { 287 return reflect.TypeOf((*map[string]*TargetGroupAttachment)(nil)).Elem() 288 } 289 290 func (i TargetGroupAttachmentMap) ToTargetGroupAttachmentMapOutput() TargetGroupAttachmentMapOutput { 291 return i.ToTargetGroupAttachmentMapOutputWithContext(context.Background()) 292 } 293 294 func (i TargetGroupAttachmentMap) ToTargetGroupAttachmentMapOutputWithContext(ctx context.Context) TargetGroupAttachmentMapOutput { 295 return pulumi.ToOutputWithContext(ctx, i).(TargetGroupAttachmentMapOutput) 296 } 297 298 type TargetGroupAttachmentOutput struct{ *pulumi.OutputState } 299 300 func (TargetGroupAttachmentOutput) ElementType() reflect.Type { 301 return reflect.TypeOf((**TargetGroupAttachment)(nil)).Elem() 302 } 303 304 func (o TargetGroupAttachmentOutput) ToTargetGroupAttachmentOutput() TargetGroupAttachmentOutput { 305 return o 306 } 307 308 func (o TargetGroupAttachmentOutput) ToTargetGroupAttachmentOutputWithContext(ctx context.Context) TargetGroupAttachmentOutput { 309 return o 310 } 311 312 // The Availability Zone where the IP address of the target is to be registered. If the private IP address is outside of the VPC scope, this value must be set to `all`. 313 func (o TargetGroupAttachmentOutput) AvailabilityZone() pulumi.StringPtrOutput { 314 return o.ApplyT(func(v *TargetGroupAttachment) pulumi.StringPtrOutput { return v.AvailabilityZone }).(pulumi.StringPtrOutput) 315 } 316 317 // The port on which targets receive traffic. 318 func (o TargetGroupAttachmentOutput) Port() pulumi.IntPtrOutput { 319 return o.ApplyT(func(v *TargetGroupAttachment) pulumi.IntPtrOutput { return v.Port }).(pulumi.IntPtrOutput) 320 } 321 322 // The ARN of the target group with which to register targets. 323 func (o TargetGroupAttachmentOutput) TargetGroupArn() pulumi.StringOutput { 324 return o.ApplyT(func(v *TargetGroupAttachment) pulumi.StringOutput { return v.TargetGroupArn }).(pulumi.StringOutput) 325 } 326 327 // The ID of the target. This is the Instance ID for an instance, or the container ID for an ECS container. If the target type is `ip`, specify an IP address. If the target type is `lambda`, specify the Lambda function ARN. If the target type is `alb`, specify the ALB ARN. 328 // 329 // The following arguments are optional: 330 func (o TargetGroupAttachmentOutput) TargetId() pulumi.StringOutput { 331 return o.ApplyT(func(v *TargetGroupAttachment) pulumi.StringOutput { return v.TargetId }).(pulumi.StringOutput) 332 } 333 334 type TargetGroupAttachmentArrayOutput struct{ *pulumi.OutputState } 335 336 func (TargetGroupAttachmentArrayOutput) ElementType() reflect.Type { 337 return reflect.TypeOf((*[]*TargetGroupAttachment)(nil)).Elem() 338 } 339 340 func (o TargetGroupAttachmentArrayOutput) ToTargetGroupAttachmentArrayOutput() TargetGroupAttachmentArrayOutput { 341 return o 342 } 343 344 func (o TargetGroupAttachmentArrayOutput) ToTargetGroupAttachmentArrayOutputWithContext(ctx context.Context) TargetGroupAttachmentArrayOutput { 345 return o 346 } 347 348 func (o TargetGroupAttachmentArrayOutput) Index(i pulumi.IntInput) TargetGroupAttachmentOutput { 349 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *TargetGroupAttachment { 350 return vs[0].([]*TargetGroupAttachment)[vs[1].(int)] 351 }).(TargetGroupAttachmentOutput) 352 } 353 354 type TargetGroupAttachmentMapOutput struct{ *pulumi.OutputState } 355 356 func (TargetGroupAttachmentMapOutput) ElementType() reflect.Type { 357 return reflect.TypeOf((*map[string]*TargetGroupAttachment)(nil)).Elem() 358 } 359 360 func (o TargetGroupAttachmentMapOutput) ToTargetGroupAttachmentMapOutput() TargetGroupAttachmentMapOutput { 361 return o 362 } 363 364 func (o TargetGroupAttachmentMapOutput) ToTargetGroupAttachmentMapOutputWithContext(ctx context.Context) TargetGroupAttachmentMapOutput { 365 return o 366 } 367 368 func (o TargetGroupAttachmentMapOutput) MapIndex(k pulumi.StringInput) TargetGroupAttachmentOutput { 369 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *TargetGroupAttachment { 370 return vs[0].(map[string]*TargetGroupAttachment)[vs[1].(string)] 371 }).(TargetGroupAttachmentOutput) 372 } 373 374 func init() { 375 pulumi.RegisterInputType(reflect.TypeOf((*TargetGroupAttachmentInput)(nil)).Elem(), &TargetGroupAttachment{}) 376 pulumi.RegisterInputType(reflect.TypeOf((*TargetGroupAttachmentArrayInput)(nil)).Elem(), TargetGroupAttachmentArray{}) 377 pulumi.RegisterInputType(reflect.TypeOf((*TargetGroupAttachmentMapInput)(nil)).Elem(), TargetGroupAttachmentMap{}) 378 pulumi.RegisterOutputType(TargetGroupAttachmentOutput{}) 379 pulumi.RegisterOutputType(TargetGroupAttachmentArrayOutput{}) 380 pulumi.RegisterOutputType(TargetGroupAttachmentMapOutput{}) 381 }