aws.lightsail.LbAttachment
Explore with Pulumi AI
Attaches a Lightsail Instance to a Lightsail Load Balancer.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const available = aws.getAvailabilityZones({
state: "available",
filters: [{
name: "opt-in-status",
values: ["opt-in-not-required"],
}],
});
const test = new aws.lightsail.Lb("test", {
name: "test-load-balancer",
healthCheckPath: "/",
instancePort: 80,
tags: {
foo: "bar",
},
});
const testInstance = new aws.lightsail.Instance("test", {
name: "test-instance",
availabilityZone: available.then(available => available.names?.[0]),
blueprintId: "amazon_linux_2",
bundleId: "nano_3_0",
});
const testLbAttachment = new aws.lightsail.LbAttachment("test", {
lbName: test.name,
instanceName: testInstance.name,
});
import pulumi
import pulumi_aws as aws
available = aws.get_availability_zones(state="available",
filters=[{
"name": "opt-in-status",
"values": ["opt-in-not-required"],
}])
test = aws.lightsail.Lb("test",
name="test-load-balancer",
health_check_path="/",
instance_port=80,
tags={
"foo": "bar",
})
test_instance = aws.lightsail.Instance("test",
name="test-instance",
availability_zone=available.names[0],
blueprint_id="amazon_linux_2",
bundle_id="nano_3_0")
test_lb_attachment = aws.lightsail.LbAttachment("test",
lb_name=test.name,
instance_name=test_instance.name)
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lightsail"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
available, err := aws.GetAvailabilityZones(ctx, &aws.GetAvailabilityZonesArgs{
State: pulumi.StringRef("available"),
Filters: []aws.GetAvailabilityZonesFilter{
{
Name: "opt-in-status",
Values: []string{
"opt-in-not-required",
},
},
},
}, nil)
if err != nil {
return err
}
test, err := lightsail.NewLb(ctx, "test", &lightsail.LbArgs{
Name: pulumi.String("test-load-balancer"),
HealthCheckPath: pulumi.String("/"),
InstancePort: pulumi.Int(80),
Tags: pulumi.StringMap{
"foo": pulumi.String("bar"),
},
})
if err != nil {
return err
}
testInstance, err := lightsail.NewInstance(ctx, "test", &lightsail.InstanceArgs{
Name: pulumi.String("test-instance"),
AvailabilityZone: pulumi.String(available.Names[0]),
BlueprintId: pulumi.String("amazon_linux_2"),
BundleId: pulumi.String("nano_3_0"),
})
if err != nil {
return err
}
_, err = lightsail.NewLbAttachment(ctx, "test", &lightsail.LbAttachmentArgs{
LbName: test.Name,
InstanceName: testInstance.Name,
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var available = Aws.GetAvailabilityZones.Invoke(new()
{
State = "available",
Filters = new[]
{
new Aws.Inputs.GetAvailabilityZonesFilterInputArgs
{
Name = "opt-in-status",
Values = new[]
{
"opt-in-not-required",
},
},
},
});
var test = new Aws.LightSail.Lb("test", new()
{
Name = "test-load-balancer",
HealthCheckPath = "/",
InstancePort = 80,
Tags =
{
{ "foo", "bar" },
},
});
var testInstance = new Aws.LightSail.Instance("test", new()
{
Name = "test-instance",
AvailabilityZone = available.Apply(getAvailabilityZonesResult => getAvailabilityZonesResult.Names[0]),
BlueprintId = "amazon_linux_2",
BundleId = "nano_3_0",
});
var testLbAttachment = new Aws.LightSail.LbAttachment("test", new()
{
LbName = test.Name,
InstanceName = testInstance.Name,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.AwsFunctions;
import com.pulumi.aws.inputs.GetAvailabilityZonesArgs;
import com.pulumi.aws.lightsail.Lb;
import com.pulumi.aws.lightsail.LbArgs;
import com.pulumi.aws.lightsail.Instance;
import com.pulumi.aws.lightsail.InstanceArgs;
import com.pulumi.aws.lightsail.LbAttachment;
import com.pulumi.aws.lightsail.LbAttachmentArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var available = AwsFunctions.getAvailabilityZones(GetAvailabilityZonesArgs.builder()
.state("available")
.filters(GetAvailabilityZonesFilterArgs.builder()
.name("opt-in-status")
.values("opt-in-not-required")
.build())
.build());
var test = new Lb("test", LbArgs.builder()
.name("test-load-balancer")
.healthCheckPath("/")
.instancePort("80")
.tags(Map.of("foo", "bar"))
.build());
var testInstance = new Instance("testInstance", InstanceArgs.builder()
.name("test-instance")
.availabilityZone(available.applyValue(getAvailabilityZonesResult -> getAvailabilityZonesResult.names()[0]))
.blueprintId("amazon_linux_2")
.bundleId("nano_3_0")
.build());
var testLbAttachment = new LbAttachment("testLbAttachment", LbAttachmentArgs.builder()
.lbName(test.name())
.instanceName(testInstance.name())
.build());
}
}
resources:
test:
type: aws:lightsail:Lb
properties:
name: test-load-balancer
healthCheckPath: /
instancePort: '80'
tags:
foo: bar
testInstance:
type: aws:lightsail:Instance
name: test
properties:
name: test-instance
availabilityZone: ${available.names[0]}
blueprintId: amazon_linux_2
bundleId: nano_3_0
testLbAttachment:
type: aws:lightsail:LbAttachment
name: test
properties:
lbName: ${test.name}
instanceName: ${testInstance.name}
variables:
available:
fn::invoke:
Function: aws:getAvailabilityZones
Arguments:
state: available
filters:
- name: opt-in-status
values:
- opt-in-not-required
Create LbAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new LbAttachment(name: string, args: LbAttachmentArgs, opts?: CustomResourceOptions);
@overload
def LbAttachment(resource_name: str,
args: LbAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def LbAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
instance_name: Optional[str] = None,
lb_name: Optional[str] = None)
func NewLbAttachment(ctx *Context, name string, args LbAttachmentArgs, opts ...ResourceOption) (*LbAttachment, error)
public LbAttachment(string name, LbAttachmentArgs args, CustomResourceOptions? opts = null)
public LbAttachment(String name, LbAttachmentArgs args)
public LbAttachment(String name, LbAttachmentArgs args, CustomResourceOptions options)
type: aws:lightsail:LbAttachment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args LbAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args LbAttachmentArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args LbAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args LbAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args LbAttachmentArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var lbAttachmentResource = new Aws.LightSail.LbAttachment("lbAttachmentResource", new()
{
InstanceName = "string",
LbName = "string",
});
example, err := lightsail.NewLbAttachment(ctx, "lbAttachmentResource", &lightsail.LbAttachmentArgs{
InstanceName: pulumi.String("string"),
LbName: pulumi.String("string"),
})
var lbAttachmentResource = new LbAttachment("lbAttachmentResource", LbAttachmentArgs.builder()
.instanceName("string")
.lbName("string")
.build());
lb_attachment_resource = aws.lightsail.LbAttachment("lbAttachmentResource",
instance_name="string",
lb_name="string")
const lbAttachmentResource = new aws.lightsail.LbAttachment("lbAttachmentResource", {
instanceName: "string",
lbName: "string",
});
type: aws:lightsail:LbAttachment
properties:
instanceName: string
lbName: string
LbAttachment Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The LbAttachment resource accepts the following input properties:
- Instance
Name string - The name of the instance to attach to the load balancer.
- Lb
Name string - The name of the Lightsail load balancer.
- Instance
Name string - The name of the instance to attach to the load balancer.
- Lb
Name string - The name of the Lightsail load balancer.
- instance
Name String - The name of the instance to attach to the load balancer.
- lb
Name String - The name of the Lightsail load balancer.
- instance
Name string - The name of the instance to attach to the load balancer.
- lb
Name string - The name of the Lightsail load balancer.
- instance_
name str - The name of the instance to attach to the load balancer.
- lb_
name str - The name of the Lightsail load balancer.
- instance
Name String - The name of the instance to attach to the load balancer.
- lb
Name String - The name of the Lightsail load balancer.
Outputs
All input properties are implicitly available as output properties. Additionally, the LbAttachment resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing LbAttachment Resource
Get an existing LbAttachment resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: LbAttachmentState, opts?: CustomResourceOptions): LbAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
instance_name: Optional[str] = None,
lb_name: Optional[str] = None) -> LbAttachment
func GetLbAttachment(ctx *Context, name string, id IDInput, state *LbAttachmentState, opts ...ResourceOption) (*LbAttachment, error)
public static LbAttachment Get(string name, Input<string> id, LbAttachmentState? state, CustomResourceOptions? opts = null)
public static LbAttachment get(String name, Output<String> id, LbAttachmentState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Instance
Name string - The name of the instance to attach to the load balancer.
- Lb
Name string - The name of the Lightsail load balancer.
- Instance
Name string - The name of the instance to attach to the load balancer.
- Lb
Name string - The name of the Lightsail load balancer.
- instance
Name String - The name of the instance to attach to the load balancer.
- lb
Name String - The name of the Lightsail load balancer.
- instance
Name string - The name of the instance to attach to the load balancer.
- lb
Name string - The name of the Lightsail load balancer.
- instance_
name str - The name of the instance to attach to the load balancer.
- lb_
name str - The name of the Lightsail load balancer.
- instance
Name String - The name of the instance to attach to the load balancer.
- lb
Name String - The name of the Lightsail load balancer.
Import
Using pulumi import
, import aws_lightsail_lb_attachment
using the name attribute. For example:
$ pulumi import aws:lightsail/lbAttachment:LbAttachment test example-load-balancer,example-instance
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.