1. Packages
  2. Ucloud Provider
  3. API Docs
  4. EipAssociation
ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud

ucloud.EipAssociation

Explore with Pulumi AI

ucloud logo
ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud

    Provides an EIP Association resource for associating Elastic IP to UHost Instance, Load Balancer, etc.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ucloud from "@pulumi/ucloud";
    
    const defaultZones = ucloud.getZones({});
    const defaultImages = defaultZones.then(defaultZones => ucloud.getImages({
        availabilityZone: defaultZones.zones?.[0]?.id,
        nameRegex: "^CentOS 7.[1-2] 64",
        imageType: "base",
    }));
    // Create security group
    const defaultSecurityGroup = new ucloud.SecurityGroup("defaultSecurityGroup", {
        tag: "tf-example",
        rules: [{
            portRange: "80",
            protocol: "tcp",
            cidrBlock: "0.0.0.0/0",
            policy: "accept",
        }],
    });
    // Create an eip
    const defaultEip = new ucloud.Eip("defaultEip", {
        bandwidth: 2,
        chargeMode: "bandwidth",
        tag: "tf-example",
        internetType: "bgp",
    });
    // Create a web server
    const web = new ucloud.Instance("web", {
        instanceType: "n-basic-2",
        availabilityZone: defaultZones.then(defaultZones => defaultZones.zones?.[0]?.id),
        imageId: defaultImages.then(defaultImages => defaultImages.images?.[0]?.id),
        dataDiskSize: 50,
        rootPassword: "wA1234567",
        securityGroup: defaultSecurityGroup.securityGroupId,
        tag: "tf-example",
    });
    // Bind eip to instance
    const defaultEipAssociation = new ucloud.EipAssociation("defaultEipAssociation", {
        resourceId: web.instanceId,
        eipId: defaultEip.eipId,
    });
    
    import pulumi
    import pulumi_ucloud as ucloud
    
    default_zones = ucloud.get_zones()
    default_images = ucloud.get_images(availability_zone=default_zones.zones[0].id,
        name_regex="^CentOS 7.[1-2] 64",
        image_type="base")
    # Create security group
    default_security_group = ucloud.SecurityGroup("defaultSecurityGroup",
        tag="tf-example",
        rules=[{
            "port_range": "80",
            "protocol": "tcp",
            "cidr_block": "0.0.0.0/0",
            "policy": "accept",
        }])
    # Create an eip
    default_eip = ucloud.Eip("defaultEip",
        bandwidth=2,
        charge_mode="bandwidth",
        tag="tf-example",
        internet_type="bgp")
    # Create a web server
    web = ucloud.Instance("web",
        instance_type="n-basic-2",
        availability_zone=default_zones.zones[0].id,
        image_id=default_images.images[0].id,
        data_disk_size=50,
        root_password="wA1234567",
        security_group=default_security_group.security_group_id,
        tag="tf-example")
    # Bind eip to instance
    default_eip_association = ucloud.EipAssociation("defaultEipAssociation",
        resource_id=web.instance_id,
        eip_id=default_eip.eip_id)
    
    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 {
    		defaultZones, err := ucloud.GetZones(ctx, &ucloud.GetZonesArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		defaultImages, err := ucloud.GetImages(ctx, &ucloud.GetImagesArgs{
    			AvailabilityZone: pulumi.StringRef(defaultZones.Zones[0].Id),
    			NameRegex:        pulumi.StringRef("^CentOS 7.[1-2] 64"),
    			ImageType:        pulumi.StringRef("base"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// Create security group
    		defaultSecurityGroup, err := ucloud.NewSecurityGroup(ctx, "defaultSecurityGroup", &ucloud.SecurityGroupArgs{
    			Tag: pulumi.String("tf-example"),
    			Rules: ucloud.SecurityGroupRuleArray{
    				&ucloud.SecurityGroupRuleArgs{
    					PortRange: pulumi.String("80"),
    					Protocol:  pulumi.String("tcp"),
    					CidrBlock: pulumi.String("0.0.0.0/0"),
    					Policy:    pulumi.String("accept"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// Create an eip
    		defaultEip, err := ucloud.NewEip(ctx, "defaultEip", &ucloud.EipArgs{
    			Bandwidth:    pulumi.Float64(2),
    			ChargeMode:   pulumi.String("bandwidth"),
    			Tag:          pulumi.String("tf-example"),
    			InternetType: pulumi.String("bgp"),
    		})
    		if err != nil {
    			return err
    		}
    		// Create a web server
    		web, err := ucloud.NewInstance(ctx, "web", &ucloud.InstanceArgs{
    			InstanceType:     pulumi.String("n-basic-2"),
    			AvailabilityZone: pulumi.String(defaultZones.Zones[0].Id),
    			ImageId:          pulumi.String(defaultImages.Images[0].Id),
    			DataDiskSize:     pulumi.Float64(50),
    			RootPassword:     pulumi.String("wA1234567"),
    			SecurityGroup:    defaultSecurityGroup.SecurityGroupId,
    			Tag:              pulumi.String("tf-example"),
    		})
    		if err != nil {
    			return err
    		}
    		// Bind eip to instance
    		_, err = ucloud.NewEipAssociation(ctx, "defaultEipAssociation", &ucloud.EipAssociationArgs{
    			ResourceId: web.InstanceId,
    			EipId:      defaultEip.EipId,
    		})
    		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 defaultZones = Ucloud.GetZones.Invoke();
    
        var defaultImages = Ucloud.GetImages.Invoke(new()
        {
            AvailabilityZone = defaultZones.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
            NameRegex = "^CentOS 7.[1-2] 64",
            ImageType = "base",
        });
    
        // Create security group
        var defaultSecurityGroup = new Ucloud.SecurityGroup("defaultSecurityGroup", new()
        {
            Tag = "tf-example",
            Rules = new[]
            {
                new Ucloud.Inputs.SecurityGroupRuleArgs
                {
                    PortRange = "80",
                    Protocol = "tcp",
                    CidrBlock = "0.0.0.0/0",
                    Policy = "accept",
                },
            },
        });
    
        // Create an eip
        var defaultEip = new Ucloud.Eip("defaultEip", new()
        {
            Bandwidth = 2,
            ChargeMode = "bandwidth",
            Tag = "tf-example",
            InternetType = "bgp",
        });
    
        // Create a web server
        var web = new Ucloud.Instance("web", new()
        {
            InstanceType = "n-basic-2",
            AvailabilityZone = defaultZones.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
            ImageId = defaultImages.Apply(getImagesResult => getImagesResult.Images[0]?.Id),
            DataDiskSize = 50,
            RootPassword = "wA1234567",
            SecurityGroup = defaultSecurityGroup.SecurityGroupId,
            Tag = "tf-example",
        });
    
        // Bind eip to instance
        var defaultEipAssociation = new Ucloud.EipAssociation("defaultEipAssociation", new()
        {
            ResourceId = web.InstanceId,
            EipId = defaultEip.EipId,
        });
    
    });
    
    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.GetZonesArgs;
    import com.pulumi.ucloud.inputs.GetImagesArgs;
    import com.pulumi.ucloud.SecurityGroup;
    import com.pulumi.ucloud.SecurityGroupArgs;
    import com.pulumi.ucloud.inputs.SecurityGroupRuleArgs;
    import com.pulumi.ucloud.Eip;
    import com.pulumi.ucloud.EipArgs;
    import com.pulumi.ucloud.Instance;
    import com.pulumi.ucloud.InstanceArgs;
    import com.pulumi.ucloud.EipAssociation;
    import com.pulumi.ucloud.EipAssociationArgs;
    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 defaultZones = UcloudFunctions.getZones();
    
            final var defaultImages = UcloudFunctions.getImages(GetImagesArgs.builder()
                .availabilityZone(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
                .nameRegex("^CentOS 7.[1-2] 64")
                .imageType("base")
                .build());
    
            // Create security group
            var defaultSecurityGroup = new SecurityGroup("defaultSecurityGroup", SecurityGroupArgs.builder()
                .tag("tf-example")
                .rules(SecurityGroupRuleArgs.builder()
                    .portRange("80")
                    .protocol("tcp")
                    .cidrBlock("0.0.0.0/0")
                    .policy("accept")
                    .build())
                .build());
    
            // Create an eip
            var defaultEip = new Eip("defaultEip", EipArgs.builder()
                .bandwidth(2)
                .chargeMode("bandwidth")
                .tag("tf-example")
                .internetType("bgp")
                .build());
    
            // Create a web server
            var web = new Instance("web", InstanceArgs.builder()
                .instanceType("n-basic-2")
                .availabilityZone(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
                .imageId(defaultImages.applyValue(getImagesResult -> getImagesResult.images()[0].id()))
                .dataDiskSize(50)
                .rootPassword("wA1234567")
                .securityGroup(defaultSecurityGroup.securityGroupId())
                .tag("tf-example")
                .build());
    
            // Bind eip to instance
            var defaultEipAssociation = new EipAssociation("defaultEipAssociation", EipAssociationArgs.builder()
                .resourceId(web.instanceId())
                .eipId(defaultEip.eipId())
                .build());
    
        }
    }
    
    resources:
      # Create security group
      defaultSecurityGroup:
        type: ucloud:SecurityGroup
        properties:
          tag: tf-example
          rules:
            - portRange: '80'
              protocol: tcp
              cidrBlock: 0.0.0.0/0
              policy: accept
      # Create an eip
      defaultEip:
        type: ucloud:Eip
        properties:
          bandwidth: 2
          chargeMode: bandwidth
          tag: tf-example
          internetType: bgp
      # Create a web server
      web:
        type: ucloud:Instance
        properties:
          instanceType: n-basic-2
          availabilityZone: ${defaultZones.zones[0].id}
          imageId: ${defaultImages.images[0].id}
          dataDiskSize: 50
          rootPassword: wA1234567
          securityGroup: ${defaultSecurityGroup.securityGroupId}
          tag: tf-example
      # Bind eip to instance
      defaultEipAssociation:
        type: ucloud:EipAssociation
        properties:
          resourceId: ${web.instanceId}
          eipId: ${defaultEip.eipId}
    variables:
      defaultZones:
        fn::invoke:
          function: ucloud:getZones
          arguments: {}
      defaultImages:
        fn::invoke:
          function: ucloud:getImages
          arguments:
            availabilityZone: ${defaultZones.zones[0].id}
            nameRegex: ^CentOS 7.[1-2] 64
            imageType: base
    

    Create EipAssociation Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new EipAssociation(name: string, args: EipAssociationArgs, opts?: CustomResourceOptions);
    @overload
    def EipAssociation(resource_name: str,
                       args: EipAssociationArgs,
                       opts: Optional[ResourceOptions] = None)
    
    @overload
    def EipAssociation(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       eip_id: Optional[str] = None,
                       resource_id: Optional[str] = None,
                       eip_association_id: Optional[str] = None,
                       resource_type: Optional[str] = None)
    func NewEipAssociation(ctx *Context, name string, args EipAssociationArgs, opts ...ResourceOption) (*EipAssociation, error)
    public EipAssociation(string name, EipAssociationArgs args, CustomResourceOptions? opts = null)
    public EipAssociation(String name, EipAssociationArgs args)
    public EipAssociation(String name, EipAssociationArgs args, CustomResourceOptions options)
    
    type: ucloud:EipAssociation
    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 EipAssociationArgs
    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 EipAssociationArgs
    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 EipAssociationArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args EipAssociationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args EipAssociationArgs
    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 eipAssociationResource = new Ucloud.EipAssociation("eipAssociationResource", new()
    {
        EipId = "string",
        ResourceId = "string",
        EipAssociationId = "string",
        ResourceType = "string",
    });
    
    example, err := ucloud.NewEipAssociation(ctx, "eipAssociationResource", &ucloud.EipAssociationArgs{
    	EipId:            pulumi.String("string"),
    	ResourceId:       pulumi.String("string"),
    	EipAssociationId: pulumi.String("string"),
    	ResourceType:     pulumi.String("string"),
    })
    
    var eipAssociationResource = new EipAssociation("eipAssociationResource", EipAssociationArgs.builder()
        .eipId("string")
        .resourceId("string")
        .eipAssociationId("string")
        .resourceType("string")
        .build());
    
    eip_association_resource = ucloud.EipAssociation("eipAssociationResource",
        eip_id="string",
        resource_id="string",
        eip_association_id="string",
        resource_type="string")
    
    const eipAssociationResource = new ucloud.EipAssociation("eipAssociationResource", {
        eipId: "string",
        resourceId: "string",
        eipAssociationId: "string",
        resourceType: "string",
    });
    
    type: ucloud:EipAssociation
    properties:
        eipAssociationId: string
        eipId: string
        resourceId: string
        resourceType: string
    

    EipAssociation 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 EipAssociation resource accepts the following input properties:

    EipId string
    The ID of EIP.
    ResourceId string
    The ID of resource with EIP attached.
    EipAssociationId string
    ResourceType string
    The type of resource with EIP attached, possible values are instance or uhost as instance, lb or ulb as load balancer, natgw as NAT GateWay host, udb as database, vpngw as ipsec vpn host, baremetal as bare metal instance.
    EipId string
    The ID of EIP.
    ResourceId string
    The ID of resource with EIP attached.
    EipAssociationId string
    ResourceType string
    The type of resource with EIP attached, possible values are instance or uhost as instance, lb or ulb as load balancer, natgw as NAT GateWay host, udb as database, vpngw as ipsec vpn host, baremetal as bare metal instance.
    eipId String
    The ID of EIP.
    resourceId String
    The ID of resource with EIP attached.
    eipAssociationId String
    resourceType String
    The type of resource with EIP attached, possible values are instance or uhost as instance, lb or ulb as load balancer, natgw as NAT GateWay host, udb as database, vpngw as ipsec vpn host, baremetal as bare metal instance.
    eipId string
    The ID of EIP.
    resourceId string
    The ID of resource with EIP attached.
    eipAssociationId string
    resourceType string
    The type of resource with EIP attached, possible values are instance or uhost as instance, lb or ulb as load balancer, natgw as NAT GateWay host, udb as database, vpngw as ipsec vpn host, baremetal as bare metal instance.
    eip_id str
    The ID of EIP.
    resource_id str
    The ID of resource with EIP attached.
    eip_association_id str
    resource_type str
    The type of resource with EIP attached, possible values are instance or uhost as instance, lb or ulb as load balancer, natgw as NAT GateWay host, udb as database, vpngw as ipsec vpn host, baremetal as bare metal instance.
    eipId String
    The ID of EIP.
    resourceId String
    The ID of resource with EIP attached.
    eipAssociationId String
    resourceType String
    The type of resource with EIP attached, possible values are instance or uhost as instance, lb or ulb as load balancer, natgw as NAT GateWay host, udb as database, vpngw as ipsec vpn host, baremetal as bare metal instance.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the EipAssociation 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 EipAssociation Resource

    Get an existing EipAssociation 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?: EipAssociationState, opts?: CustomResourceOptions): EipAssociation
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            eip_association_id: Optional[str] = None,
            eip_id: Optional[str] = None,
            resource_id: Optional[str] = None,
            resource_type: Optional[str] = None) -> EipAssociation
    func GetEipAssociation(ctx *Context, name string, id IDInput, state *EipAssociationState, opts ...ResourceOption) (*EipAssociation, error)
    public static EipAssociation Get(string name, Input<string> id, EipAssociationState? state, CustomResourceOptions? opts = null)
    public static EipAssociation get(String name, Output<String> id, EipAssociationState state, CustomResourceOptions options)
    resources:  _:    type: ucloud:EipAssociation    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.
    The following state arguments are supported:
    EipAssociationId string
    EipId string
    The ID of EIP.
    ResourceId string
    The ID of resource with EIP attached.
    ResourceType string
    The type of resource with EIP attached, possible values are instance or uhost as instance, lb or ulb as load balancer, natgw as NAT GateWay host, udb as database, vpngw as ipsec vpn host, baremetal as bare metal instance.
    EipAssociationId string
    EipId string
    The ID of EIP.
    ResourceId string
    The ID of resource with EIP attached.
    ResourceType string
    The type of resource with EIP attached, possible values are instance or uhost as instance, lb or ulb as load balancer, natgw as NAT GateWay host, udb as database, vpngw as ipsec vpn host, baremetal as bare metal instance.
    eipAssociationId String
    eipId String
    The ID of EIP.
    resourceId String
    The ID of resource with EIP attached.
    resourceType String
    The type of resource with EIP attached, possible values are instance or uhost as instance, lb or ulb as load balancer, natgw as NAT GateWay host, udb as database, vpngw as ipsec vpn host, baremetal as bare metal instance.
    eipAssociationId string
    eipId string
    The ID of EIP.
    resourceId string
    The ID of resource with EIP attached.
    resourceType string
    The type of resource with EIP attached, possible values are instance or uhost as instance, lb or ulb as load balancer, natgw as NAT GateWay host, udb as database, vpngw as ipsec vpn host, baremetal as bare metal instance.
    eip_association_id str
    eip_id str
    The ID of EIP.
    resource_id str
    The ID of resource with EIP attached.
    resource_type str
    The type of resource with EIP attached, possible values are instance or uhost as instance, lb or ulb as load balancer, natgw as NAT GateWay host, udb as database, vpngw as ipsec vpn host, baremetal as bare metal instance.
    eipAssociationId String
    eipId String
    The ID of EIP.
    resourceId String
    The ID of resource with EIP attached.
    resourceType String
    The type of resource with EIP attached, possible values are instance or uhost as instance, lb or ulb as load balancer, natgw as NAT GateWay host, udb as database, vpngw as ipsec vpn host, baremetal as bare metal instance.

    Package Details

    Repository
    ucloud ucloud/terraform-provider-ucloud
    License
    Notes
    This Pulumi package is based on the ucloud Terraform Provider.
    ucloud logo
    ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud