ucloud.LbAttachment
Explore with Pulumi AI
Provides a Load Balancer Attachment resource for attaching Load Balancer to UHost Instance, etc.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as ucloud from "@pulumi/ucloud";
const defaultImages = ucloud.getImages({
availabilityZone: "cn-bj2-04",
nameRegex: "^CentOS 6.5 64",
imageType: "base",
});
// Create Load Balancer
const webLb = new ucloud.Lb("webLb", {tag: "tf-example"});
// Create Load Balancer Listener with http protocol
const defaultLbListener = new ucloud.LbListener("defaultLbListener", {
loadBalancerId: webLb.lbId,
protocol: "http",
});
// Create web server
const webInstance = new ucloud.Instance("webInstance", {
instanceType: "n-basic-2",
availabilityZone: "cn-bj2-04",
rootPassword: "wA1234567",
imageId: defaultImages.then(defaultImages => defaultImages.images?.[0]?.id),
tag: "tf-example",
});
// Attach instances to Load Balancer
const example = new ucloud.LbAttachment("example", {
loadBalancerId: webLb.lbId,
listenerId: defaultLbListener.lbListenerId,
resourceId: webInstance.instanceId,
port: 80,
});
import pulumi
import pulumi_ucloud as ucloud
default_images = ucloud.get_images(availability_zone="cn-bj2-04",
name_regex="^CentOS 6.5 64",
image_type="base")
# Create Load Balancer
web_lb = ucloud.Lb("webLb", tag="tf-example")
# Create Load Balancer Listener with http protocol
default_lb_listener = ucloud.LbListener("defaultLbListener",
load_balancer_id=web_lb.lb_id,
protocol="http")
# Create web server
web_instance = ucloud.Instance("webInstance",
instance_type="n-basic-2",
availability_zone="cn-bj2-04",
root_password="wA1234567",
image_id=default_images.images[0].id,
tag="tf-example")
# Attach instances to Load Balancer
example = ucloud.LbAttachment("example",
load_balancer_id=web_lb.lb_id,
listener_id=default_lb_listener.lb_listener_id,
resource_id=web_instance.instance_id,
port=80)
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/ucloud/ucloud"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
defaultImages, err := ucloud.GetImages(ctx, &ucloud.GetImagesArgs{
AvailabilityZone: pulumi.StringRef("cn-bj2-04"),
NameRegex: pulumi.StringRef("^CentOS 6.5 64"),
ImageType: pulumi.StringRef("base"),
}, nil)
if err != nil {
return err
}
// Create Load Balancer
webLb, err := ucloud.NewLb(ctx, "webLb", &ucloud.LbArgs{
Tag: pulumi.String("tf-example"),
})
if err != nil {
return err
}
// Create Load Balancer Listener with http protocol
defaultLbListener, err := ucloud.NewLbListener(ctx, "defaultLbListener", &ucloud.LbListenerArgs{
LoadBalancerId: webLb.LbId,
Protocol: pulumi.String("http"),
})
if err != nil {
return err
}
// Create web server
webInstance, err := ucloud.NewInstance(ctx, "webInstance", &ucloud.InstanceArgs{
InstanceType: pulumi.String("n-basic-2"),
AvailabilityZone: pulumi.String("cn-bj2-04"),
RootPassword: pulumi.String("wA1234567"),
ImageId: pulumi.String(defaultImages.Images[0].Id),
Tag: pulumi.String("tf-example"),
})
if err != nil {
return err
}
// Attach instances to Load Balancer
_, err = ucloud.NewLbAttachment(ctx, "example", &ucloud.LbAttachmentArgs{
LoadBalancerId: webLb.LbId,
ListenerId: defaultLbListener.LbListenerId,
ResourceId: webInstance.InstanceId,
Port: pulumi.Float64(80),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ucloud = Pulumi.Ucloud;
return await Deployment.RunAsync(() =>
{
var defaultImages = Ucloud.GetImages.Invoke(new()
{
AvailabilityZone = "cn-bj2-04",
NameRegex = "^CentOS 6.5 64",
ImageType = "base",
});
// Create Load Balancer
var webLb = new Ucloud.Lb("webLb", new()
{
Tag = "tf-example",
});
// Create Load Balancer Listener with http protocol
var defaultLbListener = new Ucloud.LbListener("defaultLbListener", new()
{
LoadBalancerId = webLb.LbId,
Protocol = "http",
});
// Create web server
var webInstance = new Ucloud.Instance("webInstance", new()
{
InstanceType = "n-basic-2",
AvailabilityZone = "cn-bj2-04",
RootPassword = "wA1234567",
ImageId = defaultImages.Apply(getImagesResult => getImagesResult.Images[0]?.Id),
Tag = "tf-example",
});
// Attach instances to Load Balancer
var example = new Ucloud.LbAttachment("example", new()
{
LoadBalancerId = webLb.LbId,
ListenerId = defaultLbListener.LbListenerId,
ResourceId = webInstance.InstanceId,
Port = 80,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ucloud.UcloudFunctions;
import com.pulumi.ucloud.inputs.GetImagesArgs;
import com.pulumi.ucloud.Lb;
import com.pulumi.ucloud.LbArgs;
import com.pulumi.ucloud.LbListener;
import com.pulumi.ucloud.LbListenerArgs;
import com.pulumi.ucloud.Instance;
import com.pulumi.ucloud.InstanceArgs;
import com.pulumi.ucloud.LbAttachment;
import com.pulumi.ucloud.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 defaultImages = UcloudFunctions.getImages(GetImagesArgs.builder()
.availabilityZone("cn-bj2-04")
.nameRegex("^CentOS 6.5 64")
.imageType("base")
.build());
// Create Load Balancer
var webLb = new Lb("webLb", LbArgs.builder()
.tag("tf-example")
.build());
// Create Load Balancer Listener with http protocol
var defaultLbListener = new LbListener("defaultLbListener", LbListenerArgs.builder()
.loadBalancerId(webLb.lbId())
.protocol("http")
.build());
// Create web server
var webInstance = new Instance("webInstance", InstanceArgs.builder()
.instanceType("n-basic-2")
.availabilityZone("cn-bj2-04")
.rootPassword("wA1234567")
.imageId(defaultImages.applyValue(getImagesResult -> getImagesResult.images()[0].id()))
.tag("tf-example")
.build());
// Attach instances to Load Balancer
var example = new LbAttachment("example", LbAttachmentArgs.builder()
.loadBalancerId(webLb.lbId())
.listenerId(defaultLbListener.lbListenerId())
.resourceId(webInstance.instanceId())
.port(80)
.build());
}
}
resources:
# Create Load Balancer
webLb:
type: ucloud:Lb
properties:
tag: tf-example
# Create Load Balancer Listener with http protocol
defaultLbListener:
type: ucloud:LbListener
properties:
loadBalancerId: ${webLb.lbId}
protocol: http
# Create web server
webInstance:
type: ucloud:Instance
properties:
instanceType: n-basic-2
availabilityZone: cn-bj2-04
rootPassword: wA1234567
imageId: ${defaultImages.images[0].id}
tag: tf-example
# Attach instances to Load Balancer
example:
type: ucloud:LbAttachment
properties:
loadBalancerId: ${webLb.lbId}
listenerId: ${defaultLbListener.lbListenerId}
resourceId: ${webInstance.instanceId}
port: 80
variables:
defaultImages:
fn::invoke:
function: ucloud:getImages
arguments:
availabilityZone: cn-bj2-04
nameRegex: ^CentOS 6.5 64
imageType: base
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,
listener_id: Optional[str] = None,
load_balancer_id: Optional[str] = None,
resource_id: Optional[str] = None,
lb_attachment_id: Optional[str] = None,
port: Optional[float] = None,
resource_type: 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: ucloud: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 Ucloud.LbAttachment("lbAttachmentResource", new()
{
ListenerId = "string",
LoadBalancerId = "string",
ResourceId = "string",
LbAttachmentId = "string",
Port = 0,
ResourceType = "string",
});
example, err := ucloud.NewLbAttachment(ctx, "lbAttachmentResource", &ucloud.LbAttachmentArgs{
ListenerId: pulumi.String("string"),
LoadBalancerId: pulumi.String("string"),
ResourceId: pulumi.String("string"),
LbAttachmentId: pulumi.String("string"),
Port: pulumi.Float64(0),
ResourceType: pulumi.String("string"),
})
var lbAttachmentResource = new LbAttachment("lbAttachmentResource", LbAttachmentArgs.builder()
.listenerId("string")
.loadBalancerId("string")
.resourceId("string")
.lbAttachmentId("string")
.port(0)
.resourceType("string")
.build());
lb_attachment_resource = ucloud.LbAttachment("lbAttachmentResource",
listener_id="string",
load_balancer_id="string",
resource_id="string",
lb_attachment_id="string",
port=0,
resource_type="string")
const lbAttachmentResource = new ucloud.LbAttachment("lbAttachmentResource", {
listenerId: "string",
loadBalancerId: "string",
resourceId: "string",
lbAttachmentId: "string",
port: 0,
resourceType: "string",
});
type: ucloud:LbAttachment
properties:
lbAttachmentId: string
listenerId: string
loadBalancerId: string
port: 0
resourceId: string
resourceType: 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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The LbAttachment resource accepts the following input properties:
- Listener
Id string - The ID of a listener server.
- Load
Balancer stringId - The ID of a load balancer.
- Resource
Id string - The ID of a backend server.
- Lb
Attachment stringId - The ID of the resource lb attachment.
- Port double
- The listening port of the backend server, range: 1-65535, (Default:
80
). Backend server port have the following restrictions: If the LB listener type isrequest_proxy
, the backend serve can add different ports to implement different service instances of the same IP. Else if LB listener type ispackets_transmit
, the port of the backend server must be consistent with the LB listening port. - Resource
Type string - The types of backend servers, possible values are:
instance
orUHost
as UHost instance.
- Listener
Id string - The ID of a listener server.
- Load
Balancer stringId - The ID of a load balancer.
- Resource
Id string - The ID of a backend server.
- Lb
Attachment stringId - The ID of the resource lb attachment.
- Port float64
- The listening port of the backend server, range: 1-65535, (Default:
80
). Backend server port have the following restrictions: If the LB listener type isrequest_proxy
, the backend serve can add different ports to implement different service instances of the same IP. Else if LB listener type ispackets_transmit
, the port of the backend server must be consistent with the LB listening port. - Resource
Type string - The types of backend servers, possible values are:
instance
orUHost
as UHost instance.
- listener
Id String - The ID of a listener server.
- load
Balancer StringId - The ID of a load balancer.
- resource
Id String - The ID of a backend server.
- lb
Attachment StringId - The ID of the resource lb attachment.
- port Double
- The listening port of the backend server, range: 1-65535, (Default:
80
). Backend server port have the following restrictions: If the LB listener type isrequest_proxy
, the backend serve can add different ports to implement different service instances of the same IP. Else if LB listener type ispackets_transmit
, the port of the backend server must be consistent with the LB listening port. - resource
Type String - The types of backend servers, possible values are:
instance
orUHost
as UHost instance.
- listener
Id string - The ID of a listener server.
- load
Balancer stringId - The ID of a load balancer.
- resource
Id string - The ID of a backend server.
- lb
Attachment stringId - The ID of the resource lb attachment.
- port number
- The listening port of the backend server, range: 1-65535, (Default:
80
). Backend server port have the following restrictions: If the LB listener type isrequest_proxy
, the backend serve can add different ports to implement different service instances of the same IP. Else if LB listener type ispackets_transmit
, the port of the backend server must be consistent with the LB listening port. - resource
Type string - The types of backend servers, possible values are:
instance
orUHost
as UHost instance.
- listener_
id str - The ID of a listener server.
- load_
balancer_ strid - The ID of a load balancer.
- resource_
id str - The ID of a backend server.
- lb_
attachment_ strid - The ID of the resource lb attachment.
- port float
- The listening port of the backend server, range: 1-65535, (Default:
80
). Backend server port have the following restrictions: If the LB listener type isrequest_proxy
, the backend serve can add different ports to implement different service instances of the same IP. Else if LB listener type ispackets_transmit
, the port of the backend server must be consistent with the LB listening port. - resource_
type str - The types of backend servers, possible values are:
instance
orUHost
as UHost instance.
- listener
Id String - The ID of a listener server.
- load
Balancer StringId - The ID of a load balancer.
- resource
Id String - The ID of a backend server.
- lb
Attachment StringId - The ID of the resource lb attachment.
- port Number
- The listening port of the backend server, range: 1-65535, (Default:
80
). Backend server port have the following restrictions: If the LB listener type isrequest_proxy
, the backend serve can add different ports to implement different service instances of the same IP. Else if LB listener type ispackets_transmit
, the port of the backend server must be consistent with the LB listening port. - resource
Type String - The types of backend servers, possible values are:
instance
orUHost
as UHost instance.
Outputs
All input properties are implicitly available as output properties. Additionally, the LbAttachment resource produces the following output properties:
- id str
- The provider-assigned unique ID for this managed resource.
- private_
ip str - The private ip address for backend servers.
- status str
- The status of backend servers. Possible values are:
normalRunning
,exceptionRunning
.
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,
lb_attachment_id: Optional[str] = None,
listener_id: Optional[str] = None,
load_balancer_id: Optional[str] = None,
port: Optional[float] = None,
private_ip: Optional[str] = None,
resource_id: Optional[str] = None,
resource_type: Optional[str] = None,
status: 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)
resources: _: type: ucloud:LbAttachment get: id: ${id}
- 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.
- Lb
Attachment stringId - The ID of the resource lb attachment.
- Listener
Id string - The ID of a listener server.
- Load
Balancer stringId - The ID of a load balancer.
- Port double
- The listening port of the backend server, range: 1-65535, (Default:
80
). Backend server port have the following restrictions: If the LB listener type isrequest_proxy
, the backend serve can add different ports to implement different service instances of the same IP. Else if LB listener type ispackets_transmit
, the port of the backend server must be consistent with the LB listening port. - Private
Ip string - The private ip address for backend servers.
- Resource
Id string - The ID of a backend server.
- Resource
Type string - The types of backend servers, possible values are:
instance
orUHost
as UHost instance. - Status string
- The status of backend servers. Possible values are:
normalRunning
,exceptionRunning
.
- Lb
Attachment stringId - The ID of the resource lb attachment.
- Listener
Id string - The ID of a listener server.
- Load
Balancer stringId - The ID of a load balancer.
- Port float64
- The listening port of the backend server, range: 1-65535, (Default:
80
). Backend server port have the following restrictions: If the LB listener type isrequest_proxy
, the backend serve can add different ports to implement different service instances of the same IP. Else if LB listener type ispackets_transmit
, the port of the backend server must be consistent with the LB listening port. - Private
Ip string - The private ip address for backend servers.
- Resource
Id string - The ID of a backend server.
- Resource
Type string - The types of backend servers, possible values are:
instance
orUHost
as UHost instance. - Status string
- The status of backend servers. Possible values are:
normalRunning
,exceptionRunning
.
- lb
Attachment StringId - The ID of the resource lb attachment.
- listener
Id String - The ID of a listener server.
- load
Balancer StringId - The ID of a load balancer.
- port Double
- The listening port of the backend server, range: 1-65535, (Default:
80
). Backend server port have the following restrictions: If the LB listener type isrequest_proxy
, the backend serve can add different ports to implement different service instances of the same IP. Else if LB listener type ispackets_transmit
, the port of the backend server must be consistent with the LB listening port. - private
Ip String - The private ip address for backend servers.
- resource
Id String - The ID of a backend server.
- resource
Type String - The types of backend servers, possible values are:
instance
orUHost
as UHost instance. - status String
- The status of backend servers. Possible values are:
normalRunning
,exceptionRunning
.
- lb
Attachment stringId - The ID of the resource lb attachment.
- listener
Id string - The ID of a listener server.
- load
Balancer stringId - The ID of a load balancer.
- port number
- The listening port of the backend server, range: 1-65535, (Default:
80
). Backend server port have the following restrictions: If the LB listener type isrequest_proxy
, the backend serve can add different ports to implement different service instances of the same IP. Else if LB listener type ispackets_transmit
, the port of the backend server must be consistent with the LB listening port. - private
Ip string - The private ip address for backend servers.
- resource
Id string - The ID of a backend server.
- resource
Type string - The types of backend servers, possible values are:
instance
orUHost
as UHost instance. - status string
- The status of backend servers. Possible values are:
normalRunning
,exceptionRunning
.
- lb_
attachment_ strid - The ID of the resource lb attachment.
- listener_
id str - The ID of a listener server.
- load_
balancer_ strid - The ID of a load balancer.
- port float
- The listening port of the backend server, range: 1-65535, (Default:
80
). Backend server port have the following restrictions: If the LB listener type isrequest_proxy
, the backend serve can add different ports to implement different service instances of the same IP. Else if LB listener type ispackets_transmit
, the port of the backend server must be consistent with the LB listening port. - private_
ip str - The private ip address for backend servers.
- resource_
id str - The ID of a backend server.
- resource_
type str - The types of backend servers, possible values are:
instance
orUHost
as UHost instance. - status str
- The status of backend servers. Possible values are:
normalRunning
,exceptionRunning
.
- lb
Attachment StringId - The ID of the resource lb attachment.
- listener
Id String - The ID of a listener server.
- load
Balancer StringId - The ID of a load balancer.
- port Number
- The listening port of the backend server, range: 1-65535, (Default:
80
). Backend server port have the following restrictions: If the LB listener type isrequest_proxy
, the backend serve can add different ports to implement different service instances of the same IP. Else if LB listener type ispackets_transmit
, the port of the backend server must be consistent with the LB listening port. - private
Ip String - The private ip address for backend servers.
- resource
Id String - The ID of a backend server.
- resource
Type String - The types of backend servers, possible values are:
instance
orUHost
as UHost instance. - status String
- The status of backend servers. Possible values are:
normalRunning
,exceptionRunning
.
Import
LB Listener can be imported using the id
, e.g.
$ pulumi import ucloud:index/lbAttachment:LbAttachment example backend-abcdefg
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- ucloud ucloud/terraform-provider-ucloud
- License
- Notes
- This Pulumi package is based on the
ucloud
Terraform Provider.