github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/lightsail/lbAttachment.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 lightsail 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 Lightsail Instance to a Lightsail Load Balancer. 16 // 17 // ## Example Usage 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws" 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lightsail" 27 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 28 // 29 // ) 30 // 31 // func main() { 32 // pulumi.Run(func(ctx *pulumi.Context) error { 33 // available, err := aws.GetAvailabilityZones(ctx, &aws.GetAvailabilityZonesArgs{ 34 // State: pulumi.StringRef("available"), 35 // Filters: []aws.GetAvailabilityZonesFilter{ 36 // { 37 // Name: "opt-in-status", 38 // Values: []string{ 39 // "opt-in-not-required", 40 // }, 41 // }, 42 // }, 43 // }, nil) 44 // if err != nil { 45 // return err 46 // } 47 // test, err := lightsail.NewLb(ctx, "test", &lightsail.LbArgs{ 48 // Name: pulumi.String("test-load-balancer"), 49 // HealthCheckPath: pulumi.String("/"), 50 // InstancePort: pulumi.Int(80), 51 // Tags: pulumi.StringMap{ 52 // "foo": pulumi.String("bar"), 53 // }, 54 // }) 55 // if err != nil { 56 // return err 57 // } 58 // testInstance, err := lightsail.NewInstance(ctx, "test", &lightsail.InstanceArgs{ 59 // Name: pulumi.String("test-instance"), 60 // AvailabilityZone: pulumi.String(available.Names[0]), 61 // BlueprintId: pulumi.String("amazon_linux_2"), 62 // BundleId: pulumi.String("nano_3_0"), 63 // }) 64 // if err != nil { 65 // return err 66 // } 67 // _, err = lightsail.NewLbAttachment(ctx, "test", &lightsail.LbAttachmentArgs{ 68 // LbName: test.Name, 69 // InstanceName: testInstance.Name, 70 // }) 71 // if err != nil { 72 // return err 73 // } 74 // return nil 75 // }) 76 // } 77 // 78 // ``` 79 // <!--End PulumiCodeChooser --> 80 // 81 // ## Import 82 // 83 // Using `pulumi import`, import `aws_lightsail_lb_attachment` using the name attribute. For example: 84 // 85 // ```sh 86 // $ pulumi import aws:lightsail/lbAttachment:LbAttachment test example-load-balancer,example-instance 87 // ``` 88 type LbAttachment struct { 89 pulumi.CustomResourceState 90 91 // The name of the instance to attach to the load balancer. 92 InstanceName pulumi.StringOutput `pulumi:"instanceName"` 93 // The name of the Lightsail load balancer. 94 LbName pulumi.StringOutput `pulumi:"lbName"` 95 } 96 97 // NewLbAttachment registers a new resource with the given unique name, arguments, and options. 98 func NewLbAttachment(ctx *pulumi.Context, 99 name string, args *LbAttachmentArgs, opts ...pulumi.ResourceOption) (*LbAttachment, error) { 100 if args == nil { 101 return nil, errors.New("missing one or more required arguments") 102 } 103 104 if args.InstanceName == nil { 105 return nil, errors.New("invalid value for required argument 'InstanceName'") 106 } 107 if args.LbName == nil { 108 return nil, errors.New("invalid value for required argument 'LbName'") 109 } 110 opts = internal.PkgResourceDefaultOpts(opts) 111 var resource LbAttachment 112 err := ctx.RegisterResource("aws:lightsail/lbAttachment:LbAttachment", name, args, &resource, opts...) 113 if err != nil { 114 return nil, err 115 } 116 return &resource, nil 117 } 118 119 // GetLbAttachment gets an existing LbAttachment resource's state with the given name, ID, and optional 120 // state properties that are used to uniquely qualify the lookup (nil if not required). 121 func GetLbAttachment(ctx *pulumi.Context, 122 name string, id pulumi.IDInput, state *LbAttachmentState, opts ...pulumi.ResourceOption) (*LbAttachment, error) { 123 var resource LbAttachment 124 err := ctx.ReadResource("aws:lightsail/lbAttachment:LbAttachment", name, id, state, &resource, opts...) 125 if err != nil { 126 return nil, err 127 } 128 return &resource, nil 129 } 130 131 // Input properties used for looking up and filtering LbAttachment resources. 132 type lbAttachmentState struct { 133 // The name of the instance to attach to the load balancer. 134 InstanceName *string `pulumi:"instanceName"` 135 // The name of the Lightsail load balancer. 136 LbName *string `pulumi:"lbName"` 137 } 138 139 type LbAttachmentState struct { 140 // The name of the instance to attach to the load balancer. 141 InstanceName pulumi.StringPtrInput 142 // The name of the Lightsail load balancer. 143 LbName pulumi.StringPtrInput 144 } 145 146 func (LbAttachmentState) ElementType() reflect.Type { 147 return reflect.TypeOf((*lbAttachmentState)(nil)).Elem() 148 } 149 150 type lbAttachmentArgs struct { 151 // The name of the instance to attach to the load balancer. 152 InstanceName string `pulumi:"instanceName"` 153 // The name of the Lightsail load balancer. 154 LbName string `pulumi:"lbName"` 155 } 156 157 // The set of arguments for constructing a LbAttachment resource. 158 type LbAttachmentArgs struct { 159 // The name of the instance to attach to the load balancer. 160 InstanceName pulumi.StringInput 161 // The name of the Lightsail load balancer. 162 LbName pulumi.StringInput 163 } 164 165 func (LbAttachmentArgs) ElementType() reflect.Type { 166 return reflect.TypeOf((*lbAttachmentArgs)(nil)).Elem() 167 } 168 169 type LbAttachmentInput interface { 170 pulumi.Input 171 172 ToLbAttachmentOutput() LbAttachmentOutput 173 ToLbAttachmentOutputWithContext(ctx context.Context) LbAttachmentOutput 174 } 175 176 func (*LbAttachment) ElementType() reflect.Type { 177 return reflect.TypeOf((**LbAttachment)(nil)).Elem() 178 } 179 180 func (i *LbAttachment) ToLbAttachmentOutput() LbAttachmentOutput { 181 return i.ToLbAttachmentOutputWithContext(context.Background()) 182 } 183 184 func (i *LbAttachment) ToLbAttachmentOutputWithContext(ctx context.Context) LbAttachmentOutput { 185 return pulumi.ToOutputWithContext(ctx, i).(LbAttachmentOutput) 186 } 187 188 // LbAttachmentArrayInput is an input type that accepts LbAttachmentArray and LbAttachmentArrayOutput values. 189 // You can construct a concrete instance of `LbAttachmentArrayInput` via: 190 // 191 // LbAttachmentArray{ LbAttachmentArgs{...} } 192 type LbAttachmentArrayInput interface { 193 pulumi.Input 194 195 ToLbAttachmentArrayOutput() LbAttachmentArrayOutput 196 ToLbAttachmentArrayOutputWithContext(context.Context) LbAttachmentArrayOutput 197 } 198 199 type LbAttachmentArray []LbAttachmentInput 200 201 func (LbAttachmentArray) ElementType() reflect.Type { 202 return reflect.TypeOf((*[]*LbAttachment)(nil)).Elem() 203 } 204 205 func (i LbAttachmentArray) ToLbAttachmentArrayOutput() LbAttachmentArrayOutput { 206 return i.ToLbAttachmentArrayOutputWithContext(context.Background()) 207 } 208 209 func (i LbAttachmentArray) ToLbAttachmentArrayOutputWithContext(ctx context.Context) LbAttachmentArrayOutput { 210 return pulumi.ToOutputWithContext(ctx, i).(LbAttachmentArrayOutput) 211 } 212 213 // LbAttachmentMapInput is an input type that accepts LbAttachmentMap and LbAttachmentMapOutput values. 214 // You can construct a concrete instance of `LbAttachmentMapInput` via: 215 // 216 // LbAttachmentMap{ "key": LbAttachmentArgs{...} } 217 type LbAttachmentMapInput interface { 218 pulumi.Input 219 220 ToLbAttachmentMapOutput() LbAttachmentMapOutput 221 ToLbAttachmentMapOutputWithContext(context.Context) LbAttachmentMapOutput 222 } 223 224 type LbAttachmentMap map[string]LbAttachmentInput 225 226 func (LbAttachmentMap) ElementType() reflect.Type { 227 return reflect.TypeOf((*map[string]*LbAttachment)(nil)).Elem() 228 } 229 230 func (i LbAttachmentMap) ToLbAttachmentMapOutput() LbAttachmentMapOutput { 231 return i.ToLbAttachmentMapOutputWithContext(context.Background()) 232 } 233 234 func (i LbAttachmentMap) ToLbAttachmentMapOutputWithContext(ctx context.Context) LbAttachmentMapOutput { 235 return pulumi.ToOutputWithContext(ctx, i).(LbAttachmentMapOutput) 236 } 237 238 type LbAttachmentOutput struct{ *pulumi.OutputState } 239 240 func (LbAttachmentOutput) ElementType() reflect.Type { 241 return reflect.TypeOf((**LbAttachment)(nil)).Elem() 242 } 243 244 func (o LbAttachmentOutput) ToLbAttachmentOutput() LbAttachmentOutput { 245 return o 246 } 247 248 func (o LbAttachmentOutput) ToLbAttachmentOutputWithContext(ctx context.Context) LbAttachmentOutput { 249 return o 250 } 251 252 // The name of the instance to attach to the load balancer. 253 func (o LbAttachmentOutput) InstanceName() pulumi.StringOutput { 254 return o.ApplyT(func(v *LbAttachment) pulumi.StringOutput { return v.InstanceName }).(pulumi.StringOutput) 255 } 256 257 // The name of the Lightsail load balancer. 258 func (o LbAttachmentOutput) LbName() pulumi.StringOutput { 259 return o.ApplyT(func(v *LbAttachment) pulumi.StringOutput { return v.LbName }).(pulumi.StringOutput) 260 } 261 262 type LbAttachmentArrayOutput struct{ *pulumi.OutputState } 263 264 func (LbAttachmentArrayOutput) ElementType() reflect.Type { 265 return reflect.TypeOf((*[]*LbAttachment)(nil)).Elem() 266 } 267 268 func (o LbAttachmentArrayOutput) ToLbAttachmentArrayOutput() LbAttachmentArrayOutput { 269 return o 270 } 271 272 func (o LbAttachmentArrayOutput) ToLbAttachmentArrayOutputWithContext(ctx context.Context) LbAttachmentArrayOutput { 273 return o 274 } 275 276 func (o LbAttachmentArrayOutput) Index(i pulumi.IntInput) LbAttachmentOutput { 277 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *LbAttachment { 278 return vs[0].([]*LbAttachment)[vs[1].(int)] 279 }).(LbAttachmentOutput) 280 } 281 282 type LbAttachmentMapOutput struct{ *pulumi.OutputState } 283 284 func (LbAttachmentMapOutput) ElementType() reflect.Type { 285 return reflect.TypeOf((*map[string]*LbAttachment)(nil)).Elem() 286 } 287 288 func (o LbAttachmentMapOutput) ToLbAttachmentMapOutput() LbAttachmentMapOutput { 289 return o 290 } 291 292 func (o LbAttachmentMapOutput) ToLbAttachmentMapOutputWithContext(ctx context.Context) LbAttachmentMapOutput { 293 return o 294 } 295 296 func (o LbAttachmentMapOutput) MapIndex(k pulumi.StringInput) LbAttachmentOutput { 297 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *LbAttachment { 298 return vs[0].(map[string]*LbAttachment)[vs[1].(string)] 299 }).(LbAttachmentOutput) 300 } 301 302 func init() { 303 pulumi.RegisterInputType(reflect.TypeOf((*LbAttachmentInput)(nil)).Elem(), &LbAttachment{}) 304 pulumi.RegisterInputType(reflect.TypeOf((*LbAttachmentArrayInput)(nil)).Elem(), LbAttachmentArray{}) 305 pulumi.RegisterInputType(reflect.TypeOf((*LbAttachmentMapInput)(nil)).Elem(), LbAttachmentMap{}) 306 pulumi.RegisterOutputType(LbAttachmentOutput{}) 307 pulumi.RegisterOutputType(LbAttachmentArrayOutput{}) 308 pulumi.RegisterOutputType(LbAttachmentMapOutput{}) 309 }