title: "EipAssociate" title_tag: "huaweicloud.Vpc.EipAssociate" meta_desc: "Documentation for the huaweicloud.Vpc.EipAssociate resource with examples, input properties, output properties, lookup functions, and supporting types." layout: api no_edit_this_page: true


Associates an EIP to a specified IP address or port.

## Example Usage

Associate with a fixed IP

using System.Collections.Generic;
using Pulumi;
using Huaweicloud = Pulumi.Huaweicloud;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var publicAddress = config.RequireObject<dynamic>("publicAddress");
    var networkId = config.RequireObject<dynamic>("networkId");
    var associated = new Huaweicloud.Vpc.EipAssociate("associated", new()
    {
        PublicIp = publicAddress,
        NetworkId = networkId,
        FixedIp = "192.168.0.100",
    });

});
package main

import (
    "github.com/huaweicloud/pulumi-huaweicloud/sdk/go/huaweicloud/Vpc"
    "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        cfg := config.New(ctx, "")
        publicAddress := cfg.RequireObject("publicAddress")
        networkId := cfg.RequireObject("networkId")
        _, err := Vpc.NewEipAssociate(ctx, "associated", &Vpc.EipAssociateArgs{
            PublicIp:  pulumi.Any(publicAddress),
            NetworkId: pulumi.Any(networkId),
            FixedIp:   pulumi.String("192.168.0.100"),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.huaweicloud.Vpc.EipAssociate;
import com.pulumi.huaweicloud.Vpc.EipAssociateArgs;
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 config = ctx.config();
        final var publicAddress = config.get("publicAddress");
        final var networkId = config.get("networkId");
        var associated = new EipAssociate("associated", EipAssociateArgs.builder()        
            .publicIp(publicAddress)
            .networkId(networkId)
            .fixedIp("192.168.0.100")
            .build());

    }
}
import pulumi
import pulumi_huaweicloud as huaweicloud

config = pulumi.Config()
public_address = config.require_object("publicAddress")
network_id = config.require_object("networkId")
associated = huaweicloud.vpc.EipAssociate("associated",
    public_ip=public_address,
    network_id=network_id,
    fixed_ip="192.168.0.100")
import * as pulumi from "@pulumi/pulumi";
import * as pulumi from "@huaweicloudos/pulumi";

const config = new pulumi.Config();
const publicAddress = config.requireObject("publicAddress");
const networkId = config.requireObject("networkId");
const associated = new huaweicloud.vpc.EipAssociate("associated", {
    publicIp: publicAddress,
    networkId: networkId,
    fixedIp: "192.168.0.100",
});
configuration:
  publicAddress:
    type: dynamic
  networkId:
    type: dynamic
resources:
  associated:
    type: huaweicloud:Vpc:EipAssociate
    properties:
      publicIp: ${publicAddress}
      networkId: ${networkId}
      fixedIp: 192.168.0.100

Associate with a port

using System.Collections.Generic;
using Pulumi;
using Huaweicloud = Pulumi.Huaweicloud;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var networkId = config.RequireObject<dynamic>("networkId");
    var myport = Huaweicloud.Vpc.GetPort.Invoke(new()
    {
        NetworkId = networkId,
        FixedIp = "192.168.0.100",
    });

    var myeip = new Huaweicloud.Vpc.Eip("myeip", new()
    {
        Publicip = new Huaweicloud.Vpc.Inputs.EipPublicipArgs
        {
            Type = "5_bgp",
        },
        Bandwidth = new Huaweicloud.Vpc.Inputs.EipBandwidthArgs
        {
            Name = "test",
            Size = 5,
            ShareType = "PER",
            ChargeMode = "traffic",
        },
    });

    var associated = new Huaweicloud.Vpc.EipAssociate("associated", new()
    {
        PublicIp = myeip.Address,
        PortId = myport.Apply(getPortResult => getPortResult.Id),
    });

});
package main

import (
    "github.com/huaweicloud/pulumi-huaweicloud/sdk/go/huaweicloud/Vpc"
    "github.com/pulumi/pulumi-huaweicloud/sdk/go/huaweicloud/Vpc"
    "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        cfg := config.New(ctx, "")
        networkId := cfg.RequireObject("networkId")
        myport, err := Vpc.GetPort(ctx, &vpc.GetPortArgs{
            NetworkId: pulumi.StringRef(networkId),
            FixedIp:   pulumi.StringRef("192.168.0.100"),
        }, nil)
        if err != nil {
            return err
        }
        myeip, err := Vpc.NewEip(ctx, "myeip", &Vpc.EipArgs{
            Publicip: &vpc.EipPublicipArgs{
                Type: pulumi.String("5_bgp"),
            },
            Bandwidth: &vpc.EipBandwidthArgs{
                Name:       pulumi.String("test"),
                Size:       pulumi.Int(5),
                ShareType:  pulumi.String("PER"),
                ChargeMode: pulumi.String("traffic"),
            },
        })
        if err != nil {
            return err
        }
        _, err = Vpc.NewEipAssociate(ctx, "associated", &Vpc.EipAssociateArgs{
            PublicIp: myeip.Address,
            PortId:   pulumi.String(myport.Id),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.huaweicloud.Vpc.VpcFunctions;
import com.pulumi.huaweicloud.Iec.inputs.GetPortArgs;
import com.pulumi.huaweicloud.Vpc.Eip;
import com.pulumi.huaweicloud.Vpc.EipArgs;
import com.pulumi.huaweicloud.Vpc.inputs.EipPublicipArgs;
import com.pulumi.huaweicloud.Vpc.inputs.EipBandwidthArgs;
import com.pulumi.huaweicloud.Vpc.EipAssociate;
import com.pulumi.huaweicloud.Vpc.EipAssociateArgs;
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 config = ctx.config();
        final var networkId = config.get("networkId");
        final var myport = VpcFunctions.getPort(GetPortArgs.builder()
            .networkId(networkId)
            .fixedIp("192.168.0.100")
            .build());

        var myeip = new Eip("myeip", EipArgs.builder()        
            .publicip(EipPublicipArgs.builder()
                .type("5_bgp")
                .build())
            .bandwidth(EipBandwidthArgs.builder()
                .name("test")
                .size(5)
                .shareType("PER")
                .chargeMode("traffic")
                .build())
            .build());

        var associated = new EipAssociate("associated", EipAssociateArgs.builder()        
            .publicIp(myeip.address())
            .portId(myport.applyValue(getPortResult -> getPortResult.id()))
            .build());

    }
}
import pulumi
import pulumi_huaweicloud as huaweicloud

config = pulumi.Config()
network_id = config.require_object("networkId")
myport = huaweicloud.Vpc.get_port(network_id=network_id,
    fixed_ip="192.168.0.100")
myeip = huaweicloud.vpc.Eip("myeip",
    publicip=huaweicloud.vpc.EipPublicipArgs(
        type="5_bgp",
    ),
    bandwidth=huaweicloud.vpc.EipBandwidthArgs(
        name="test",
        size=5,
        share_type="PER",
        charge_mode="traffic",
    ))
associated = huaweicloud.vpc.EipAssociate("associated",
    public_ip=myeip.address,
    port_id=myport.id)
import * as pulumi from "@pulumi/pulumi";
import * as huaweicloud from "@pulumi/huaweicloud";
import * as pulumi from "@huaweicloudos/pulumi";

const config = new pulumi.Config();
const networkId = config.requireObject("networkId");
const myport = huaweicloud.Vpc.getPort({
    networkId: networkId,
    fixedIp: "192.168.0.100",
});
const myeip = new huaweicloud.vpc.Eip("myeip", {
    publicip: {
        type: "5_bgp",
    },
    bandwidth: {
        name: "test",
        size: 5,
        shareType: "PER",
        chargeMode: "traffic",
    },
});
const associated = new huaweicloud.vpc.EipAssociate("associated", {
    publicIp: myeip.address,
    portId: myport.then(myport => myport.id),
});
configuration:
  networkId:
    type: dynamic
resources:
  myeip:
    type: huaweicloud:Vpc:Eip
    properties:
      publicip:
        type: 5_bgp
      bandwidth:
        name: test
        size: 5
        shareType: PER
        chargeMode: traffic
  associated:
    type: huaweicloud:Vpc:EipAssociate
    properties:
      publicIp: ${myeip.address}
      portId: ${myport.id}
variables:
  myport:
    Fn::Invoke:
      Function: huaweicloud:Vpc:getPort
      Arguments:
        networkId: ${networkId}
        fixedIp: 192.168.0.100

Create EipAssociate Resource {#create}

new EipAssociate(name: string, args: EipAssociateArgs, opts?: CustomResourceOptions);
@overload
def EipAssociate(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 fixed_ip: Optional[str] = None,
                 network_id: Optional[str] = None,
                 port_id: Optional[str] = None,
                 public_ip: Optional[str] = None,
                 region: Optional[str] = None)
@overload
def EipAssociate(resource_name: str,
                 args: EipAssociateArgs,
                 opts: Optional[ResourceOptions] = None)
func NewEipAssociate(ctx *Context, name string, args EipAssociateArgs, opts ...ResourceOption) (*EipAssociate, error)
public EipAssociate(string name, EipAssociateArgs args, CustomResourceOptions? opts = null)
public EipAssociate(String name, EipAssociateArgs args)
public EipAssociate(String name, EipAssociateArgs args, CustomResourceOptions options)
type: huaweicloud:Vpc:EipAssociate
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args EipAssociateArgs
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 EipAssociateArgs
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 EipAssociateArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args EipAssociateArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args EipAssociateArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

EipAssociate Resource Properties {#properties}

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The EipAssociate resource accepts the following input properties:

PublicIp string

Specifies the EIP address to associate. Changing this creates a new resource.

FixedIp string

Specifies a private IP address to associate with the EIP. Changing this creates a new resource.

NetworkId string

Specifies the ID of the network to which the fixed_ip belongs. It is mandatory when fixed_ip is set. Changing this creates a new resource.

PortId string

Specifies an existing port ID to associate with the EIP. This parameter and fixed_ip are alternative. Changing this creates a new resource.

Region string

Specifies the region in which to associate the EIP. If omitted, the provider-level region will be used. Changing this creates a new resource.

PublicIp string

Specifies the EIP address to associate. Changing this creates a new resource.

FixedIp string

Specifies a private IP address to associate with the EIP. Changing this creates a new resource.

NetworkId string

Specifies the ID of the network to which the fixed_ip belongs. It is mandatory when fixed_ip is set. Changing this creates a new resource.

PortId string

Specifies an existing port ID to associate with the EIP. This parameter and fixed_ip are alternative. Changing this creates a new resource.

Region string

Specifies the region in which to associate the EIP. If omitted, the provider-level region will be used. Changing this creates a new resource.

publicIp String

Specifies the EIP address to associate. Changing this creates a new resource.

fixedIp String

Specifies a private IP address to associate with the EIP. Changing this creates a new resource.

networkId String

Specifies the ID of the network to which the fixed_ip belongs. It is mandatory when fixed_ip is set. Changing this creates a new resource.

portId String

Specifies an existing port ID to associate with the EIP. This parameter and fixed_ip are alternative. Changing this creates a new resource.

region String

Specifies the region in which to associate the EIP. If omitted, the provider-level region will be used. Changing this creates a new resource.

publicIp string

Specifies the EIP address to associate. Changing this creates a new resource.

fixedIp string

Specifies a private IP address to associate with the EIP. Changing this creates a new resource.

networkId string

Specifies the ID of the network to which the fixed_ip belongs. It is mandatory when fixed_ip is set. Changing this creates a new resource.

portId string

Specifies an existing port ID to associate with the EIP. This parameter and fixed_ip are alternative. Changing this creates a new resource.

region string

Specifies the region in which to associate the EIP. If omitted, the provider-level region will be used. Changing this creates a new resource.

public_ip str

Specifies the EIP address to associate. Changing this creates a new resource.

fixed_ip str

Specifies a private IP address to associate with the EIP. Changing this creates a new resource.

network_id str

Specifies the ID of the network to which the fixed_ip belongs. It is mandatory when fixed_ip is set. Changing this creates a new resource.

port_id str

Specifies an existing port ID to associate with the EIP. This parameter and fixed_ip are alternative. Changing this creates a new resource.

region str

Specifies the region in which to associate the EIP. If omitted, the provider-level region will be used. Changing this creates a new resource.

publicIp String

Specifies the EIP address to associate. Changing this creates a new resource.

fixedIp String

Specifies a private IP address to associate with the EIP. Changing this creates a new resource.

networkId String

Specifies the ID of the network to which the fixed_ip belongs. It is mandatory when fixed_ip is set. Changing this creates a new resource.

portId String

Specifies an existing port ID to associate with the EIP. This parameter and fixed_ip are alternative. Changing this creates a new resource.

region String

Specifies the region in which to associate the EIP. If omitted, the provider-level region will be used. Changing this creates a new resource.

Outputs

All input properties are implicitly available as output properties. Additionally, the EipAssociate resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

MacAddress string

The MAC address of the private IP.

Status string

The status of EIP, should be BOUND.

Id string

The provider-assigned unique ID for this managed resource.

MacAddress string

The MAC address of the private IP.

Status string

The status of EIP, should be BOUND.

id String

The provider-assigned unique ID for this managed resource.

macAddress String

The MAC address of the private IP.

status String

The status of EIP, should be BOUND.

id string

The provider-assigned unique ID for this managed resource.

macAddress string

The MAC address of the private IP.

status string

The status of EIP, should be BOUND.

id str

The provider-assigned unique ID for this managed resource.

mac_address str

The MAC address of the private IP.

status str

The status of EIP, should be BOUND.

id String

The provider-assigned unique ID for this managed resource.

macAddress String

The MAC address of the private IP.

status String

The status of EIP, should be BOUND.

Look up Existing EipAssociate Resource {#look-up}

Get an existing EipAssociate 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?: EipAssociateState, opts?: CustomResourceOptions): EipAssociate
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        fixed_ip: Optional[str] = None,
        mac_address: Optional[str] = None,
        network_id: Optional[str] = None,
        port_id: Optional[str] = None,
        public_ip: Optional[str] = None,
        region: Optional[str] = None,
        status: Optional[str] = None) -> EipAssociate
func GetEipAssociate(ctx *Context, name string, id IDInput, state *EipAssociateState, opts ...ResourceOption) (*EipAssociate, error)
public static EipAssociate Get(string name, Input<string> id, EipAssociateState? state, CustomResourceOptions? opts = null)
public static EipAssociate get(String name, Output<String> id, EipAssociateState 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.
The following state arguments are supported:
FixedIp string

Specifies a private IP address to associate with the EIP. Changing this creates a new resource.

MacAddress string

The MAC address of the private IP.

NetworkId string

Specifies the ID of the network to which the fixed_ip belongs. It is mandatory when fixed_ip is set. Changing this creates a new resource.

PortId string

Specifies an existing port ID to associate with the EIP. This parameter and fixed_ip are alternative. Changing this creates a new resource.

PublicIp string

Specifies the EIP address to associate. Changing this creates a new resource.

Region string

Specifies the region in which to associate the EIP. If omitted, the provider-level region will be used. Changing this creates a new resource.

Status string

The status of EIP, should be BOUND.

FixedIp string

Specifies a private IP address to associate with the EIP. Changing this creates a new resource.

MacAddress string

The MAC address of the private IP.

NetworkId string

Specifies the ID of the network to which the fixed_ip belongs. It is mandatory when fixed_ip is set. Changing this creates a new resource.

PortId string

Specifies an existing port ID to associate with the EIP. This parameter and fixed_ip are alternative. Changing this creates a new resource.

PublicIp string

Specifies the EIP address to associate. Changing this creates a new resource.

Region string

Specifies the region in which to associate the EIP. If omitted, the provider-level region will be used. Changing this creates a new resource.

Status string

The status of EIP, should be BOUND.

fixedIp String

Specifies a private IP address to associate with the EIP. Changing this creates a new resource.

macAddress String

The MAC address of the private IP.

networkId String

Specifies the ID of the network to which the fixed_ip belongs. It is mandatory when fixed_ip is set. Changing this creates a new resource.

portId String

Specifies an existing port ID to associate with the EIP. This parameter and fixed_ip are alternative. Changing this creates a new resource.

publicIp String

Specifies the EIP address to associate. Changing this creates a new resource.

region String

Specifies the region in which to associate the EIP. If omitted, the provider-level region will be used. Changing this creates a new resource.

status String

The status of EIP, should be BOUND.

fixedIp string

Specifies a private IP address to associate with the EIP. Changing this creates a new resource.

macAddress string

The MAC address of the private IP.

networkId string

Specifies the ID of the network to which the fixed_ip belongs. It is mandatory when fixed_ip is set. Changing this creates a new resource.

portId string

Specifies an existing port ID to associate with the EIP. This parameter and fixed_ip are alternative. Changing this creates a new resource.

publicIp string

Specifies the EIP address to associate. Changing this creates a new resource.

region string

Specifies the region in which to associate the EIP. If omitted, the provider-level region will be used. Changing this creates a new resource.

status string

The status of EIP, should be BOUND.

fixed_ip str

Specifies a private IP address to associate with the EIP. Changing this creates a new resource.

mac_address str

The MAC address of the private IP.

network_id str

Specifies the ID of the network to which the fixed_ip belongs. It is mandatory when fixed_ip is set. Changing this creates a new resource.

port_id str

Specifies an existing port ID to associate with the EIP. This parameter and fixed_ip are alternative. Changing this creates a new resource.

public_ip str

Specifies the EIP address to associate. Changing this creates a new resource.

region str

Specifies the region in which to associate the EIP. If omitted, the provider-level region will be used. Changing this creates a new resource.

status str

The status of EIP, should be BOUND.

fixedIp String

Specifies a private IP address to associate with the EIP. Changing this creates a new resource.

macAddress String

The MAC address of the private IP.

networkId String

Specifies the ID of the network to which the fixed_ip belongs. It is mandatory when fixed_ip is set. Changing this creates a new resource.

portId String

Specifies an existing port ID to associate with the EIP. This parameter and fixed_ip are alternative. Changing this creates a new resource.

publicIp String

Specifies the EIP address to associate. Changing this creates a new resource.

region String

Specifies the region in which to associate the EIP. If omitted, the provider-level region will be used. Changing this creates a new resource.

status String

The status of EIP, should be BOUND.

Import

EIP associations can be imported using the id of the EIP, e.g.

 $ pulumi import huaweicloud:Vpc/eipAssociate:EipAssociate eip 2c7f39f3-702b-48d1-940c-b50384177ee1

Package Details

Repository
https://github.com/huaweicloud/pulumi-huaweicloud
License
Apache-2.0
Notes

This Pulumi package is based on the huaweicloud Terraform Provider.