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