github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/autoscaling/attachment.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 autoscaling 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 // Attaches a load balancer to an Auto Scaling group. 16 // 17 // > **NOTE on Auto Scaling Groups, Attachments and Traffic Source Attachments:** Pulumi provides standalone Attachment (for attaching Classic Load Balancers and Application Load Balancer, Gateway Load Balancer, or Network Load Balancer target groups) and Traffic Source Attachment (for attaching Load Balancers and VPC Lattice target groups) resources and an Auto Scaling Group resource with `loadBalancers`, `targetGroupArns` and `trafficSource` attributes. Do not use the same traffic source in more than one of these resources. Doing so will cause a conflict of attachments. A `lifecycle` configuration block can be used to suppress differences if necessary. 18 // 19 // ## Example Usage 20 // 21 // <!--Start PulumiCodeChooser --> 22 // ```go 23 // package main 24 // 25 // import ( 26 // 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/autoscaling" 28 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 29 // 30 // ) 31 // 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // // Create a new load balancer attachment 35 // _, err := autoscaling.NewAttachment(ctx, "example", &autoscaling.AttachmentArgs{ 36 // AutoscalingGroupName: pulumi.Any(exampleAwsAutoscalingGroup.Id), 37 // Elb: pulumi.Any(exampleAwsElb.Id), 38 // }) 39 // if err != nil { 40 // return err 41 // } 42 // return nil 43 // }) 44 // } 45 // 46 // ``` 47 // <!--End PulumiCodeChooser --> 48 // 49 // <!--Start PulumiCodeChooser --> 50 // ```go 51 // package main 52 // 53 // import ( 54 // 55 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/autoscaling" 56 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 57 // 58 // ) 59 // 60 // func main() { 61 // pulumi.Run(func(ctx *pulumi.Context) error { 62 // // Create a new ALB Target Group attachment 63 // _, err := autoscaling.NewAttachment(ctx, "example", &autoscaling.AttachmentArgs{ 64 // AutoscalingGroupName: pulumi.Any(exampleAwsAutoscalingGroup.Id), 65 // LbTargetGroupArn: pulumi.Any(exampleAwsLbTargetGroup.Arn), 66 // }) 67 // if err != nil { 68 // return err 69 // } 70 // return nil 71 // }) 72 // } 73 // 74 // ``` 75 // <!--End PulumiCodeChooser --> 76 type Attachment struct { 77 pulumi.CustomResourceState 78 79 // Name of ASG to associate with the ELB. 80 AutoscalingGroupName pulumi.StringOutput `pulumi:"autoscalingGroupName"` 81 // Name of the ELB. 82 Elb pulumi.StringPtrOutput `pulumi:"elb"` 83 // ARN of a load balancer target group. 84 LbTargetGroupArn pulumi.StringPtrOutput `pulumi:"lbTargetGroupArn"` 85 } 86 87 // NewAttachment registers a new resource with the given unique name, arguments, and options. 88 func NewAttachment(ctx *pulumi.Context, 89 name string, args *AttachmentArgs, opts ...pulumi.ResourceOption) (*Attachment, error) { 90 if args == nil { 91 return nil, errors.New("missing one or more required arguments") 92 } 93 94 if args.AutoscalingGroupName == nil { 95 return nil, errors.New("invalid value for required argument 'AutoscalingGroupName'") 96 } 97 opts = internal.PkgResourceDefaultOpts(opts) 98 var resource Attachment 99 err := ctx.RegisterResource("aws:autoscaling/attachment:Attachment", name, args, &resource, opts...) 100 if err != nil { 101 return nil, err 102 } 103 return &resource, nil 104 } 105 106 // GetAttachment gets an existing Attachment resource's state with the given name, ID, and optional 107 // state properties that are used to uniquely qualify the lookup (nil if not required). 108 func GetAttachment(ctx *pulumi.Context, 109 name string, id pulumi.IDInput, state *AttachmentState, opts ...pulumi.ResourceOption) (*Attachment, error) { 110 var resource Attachment 111 err := ctx.ReadResource("aws:autoscaling/attachment:Attachment", name, id, state, &resource, opts...) 112 if err != nil { 113 return nil, err 114 } 115 return &resource, nil 116 } 117 118 // Input properties used for looking up and filtering Attachment resources. 119 type attachmentState struct { 120 // Name of ASG to associate with the ELB. 121 AutoscalingGroupName *string `pulumi:"autoscalingGroupName"` 122 // Name of the ELB. 123 Elb *string `pulumi:"elb"` 124 // ARN of a load balancer target group. 125 LbTargetGroupArn *string `pulumi:"lbTargetGroupArn"` 126 } 127 128 type AttachmentState struct { 129 // Name of ASG to associate with the ELB. 130 AutoscalingGroupName pulumi.StringPtrInput 131 // Name of the ELB. 132 Elb pulumi.StringPtrInput 133 // ARN of a load balancer target group. 134 LbTargetGroupArn pulumi.StringPtrInput 135 } 136 137 func (AttachmentState) ElementType() reflect.Type { 138 return reflect.TypeOf((*attachmentState)(nil)).Elem() 139 } 140 141 type attachmentArgs struct { 142 // Name of ASG to associate with the ELB. 143 AutoscalingGroupName string `pulumi:"autoscalingGroupName"` 144 // Name of the ELB. 145 Elb *string `pulumi:"elb"` 146 // ARN of a load balancer target group. 147 LbTargetGroupArn *string `pulumi:"lbTargetGroupArn"` 148 } 149 150 // The set of arguments for constructing a Attachment resource. 151 type AttachmentArgs struct { 152 // Name of ASG to associate with the ELB. 153 AutoscalingGroupName pulumi.StringInput 154 // Name of the ELB. 155 Elb pulumi.StringPtrInput 156 // ARN of a load balancer target group. 157 LbTargetGroupArn pulumi.StringPtrInput 158 } 159 160 func (AttachmentArgs) ElementType() reflect.Type { 161 return reflect.TypeOf((*attachmentArgs)(nil)).Elem() 162 } 163 164 type AttachmentInput interface { 165 pulumi.Input 166 167 ToAttachmentOutput() AttachmentOutput 168 ToAttachmentOutputWithContext(ctx context.Context) AttachmentOutput 169 } 170 171 func (*Attachment) ElementType() reflect.Type { 172 return reflect.TypeOf((**Attachment)(nil)).Elem() 173 } 174 175 func (i *Attachment) ToAttachmentOutput() AttachmentOutput { 176 return i.ToAttachmentOutputWithContext(context.Background()) 177 } 178 179 func (i *Attachment) ToAttachmentOutputWithContext(ctx context.Context) AttachmentOutput { 180 return pulumi.ToOutputWithContext(ctx, i).(AttachmentOutput) 181 } 182 183 // AttachmentArrayInput is an input type that accepts AttachmentArray and AttachmentArrayOutput values. 184 // You can construct a concrete instance of `AttachmentArrayInput` via: 185 // 186 // AttachmentArray{ AttachmentArgs{...} } 187 type AttachmentArrayInput interface { 188 pulumi.Input 189 190 ToAttachmentArrayOutput() AttachmentArrayOutput 191 ToAttachmentArrayOutputWithContext(context.Context) AttachmentArrayOutput 192 } 193 194 type AttachmentArray []AttachmentInput 195 196 func (AttachmentArray) ElementType() reflect.Type { 197 return reflect.TypeOf((*[]*Attachment)(nil)).Elem() 198 } 199 200 func (i AttachmentArray) ToAttachmentArrayOutput() AttachmentArrayOutput { 201 return i.ToAttachmentArrayOutputWithContext(context.Background()) 202 } 203 204 func (i AttachmentArray) ToAttachmentArrayOutputWithContext(ctx context.Context) AttachmentArrayOutput { 205 return pulumi.ToOutputWithContext(ctx, i).(AttachmentArrayOutput) 206 } 207 208 // AttachmentMapInput is an input type that accepts AttachmentMap and AttachmentMapOutput values. 209 // You can construct a concrete instance of `AttachmentMapInput` via: 210 // 211 // AttachmentMap{ "key": AttachmentArgs{...} } 212 type AttachmentMapInput interface { 213 pulumi.Input 214 215 ToAttachmentMapOutput() AttachmentMapOutput 216 ToAttachmentMapOutputWithContext(context.Context) AttachmentMapOutput 217 } 218 219 type AttachmentMap map[string]AttachmentInput 220 221 func (AttachmentMap) ElementType() reflect.Type { 222 return reflect.TypeOf((*map[string]*Attachment)(nil)).Elem() 223 } 224 225 func (i AttachmentMap) ToAttachmentMapOutput() AttachmentMapOutput { 226 return i.ToAttachmentMapOutputWithContext(context.Background()) 227 } 228 229 func (i AttachmentMap) ToAttachmentMapOutputWithContext(ctx context.Context) AttachmentMapOutput { 230 return pulumi.ToOutputWithContext(ctx, i).(AttachmentMapOutput) 231 } 232 233 type AttachmentOutput struct{ *pulumi.OutputState } 234 235 func (AttachmentOutput) ElementType() reflect.Type { 236 return reflect.TypeOf((**Attachment)(nil)).Elem() 237 } 238 239 func (o AttachmentOutput) ToAttachmentOutput() AttachmentOutput { 240 return o 241 } 242 243 func (o AttachmentOutput) ToAttachmentOutputWithContext(ctx context.Context) AttachmentOutput { 244 return o 245 } 246 247 // Name of ASG to associate with the ELB. 248 func (o AttachmentOutput) AutoscalingGroupName() pulumi.StringOutput { 249 return o.ApplyT(func(v *Attachment) pulumi.StringOutput { return v.AutoscalingGroupName }).(pulumi.StringOutput) 250 } 251 252 // Name of the ELB. 253 func (o AttachmentOutput) Elb() pulumi.StringPtrOutput { 254 return o.ApplyT(func(v *Attachment) pulumi.StringPtrOutput { return v.Elb }).(pulumi.StringPtrOutput) 255 } 256 257 // ARN of a load balancer target group. 258 func (o AttachmentOutput) LbTargetGroupArn() pulumi.StringPtrOutput { 259 return o.ApplyT(func(v *Attachment) pulumi.StringPtrOutput { return v.LbTargetGroupArn }).(pulumi.StringPtrOutput) 260 } 261 262 type AttachmentArrayOutput struct{ *pulumi.OutputState } 263 264 func (AttachmentArrayOutput) ElementType() reflect.Type { 265 return reflect.TypeOf((*[]*Attachment)(nil)).Elem() 266 } 267 268 func (o AttachmentArrayOutput) ToAttachmentArrayOutput() AttachmentArrayOutput { 269 return o 270 } 271 272 func (o AttachmentArrayOutput) ToAttachmentArrayOutputWithContext(ctx context.Context) AttachmentArrayOutput { 273 return o 274 } 275 276 func (o AttachmentArrayOutput) Index(i pulumi.IntInput) AttachmentOutput { 277 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Attachment { 278 return vs[0].([]*Attachment)[vs[1].(int)] 279 }).(AttachmentOutput) 280 } 281 282 type AttachmentMapOutput struct{ *pulumi.OutputState } 283 284 func (AttachmentMapOutput) ElementType() reflect.Type { 285 return reflect.TypeOf((*map[string]*Attachment)(nil)).Elem() 286 } 287 288 func (o AttachmentMapOutput) ToAttachmentMapOutput() AttachmentMapOutput { 289 return o 290 } 291 292 func (o AttachmentMapOutput) ToAttachmentMapOutputWithContext(ctx context.Context) AttachmentMapOutput { 293 return o 294 } 295 296 func (o AttachmentMapOutput) MapIndex(k pulumi.StringInput) AttachmentOutput { 297 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Attachment { 298 return vs[0].(map[string]*Attachment)[vs[1].(string)] 299 }).(AttachmentOutput) 300 } 301 302 func init() { 303 pulumi.RegisterInputType(reflect.TypeOf((*AttachmentInput)(nil)).Elem(), &Attachment{}) 304 pulumi.RegisterInputType(reflect.TypeOf((*AttachmentArrayInput)(nil)).Elem(), AttachmentArray{}) 305 pulumi.RegisterInputType(reflect.TypeOf((*AttachmentMapInput)(nil)).Elem(), AttachmentMap{}) 306 pulumi.RegisterOutputType(AttachmentOutput{}) 307 pulumi.RegisterOutputType(AttachmentArrayOutput{}) 308 pulumi.RegisterOutputType(AttachmentMapOutput{}) 309 }