equinix.metal.IpAttachment
Explore with Pulumi AI
Provides a resource to attach elastic IP subnets to devices.
To attach an IP subnet from a reserved block to a provisioned device, you must derive a subnet CIDR belonging to one of your reserved blocks in the same project and metro as the target device.
For example, you have reserved IPv4 address block 147.229.10.152/30
, you can choose to assign either the whole block as one subnet to a device; or 2 subnets with CIDRs 147.229.10.152/31
and 147.229.10.154/31
; or 4 subnets with mask prefix length 32
. More about the elastic IP subnets is here.
Device and reserved block must be in the same metro.
Example Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Equinix = Pulumi.Equinix;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var myblock = new Equinix.Metal.ReservedIpBlock("myblock", new()
{
ProjectId = projectId,
Metro = "ny",
Quantity = 2,
});
var firstAddressAssignment = new Equinix.Metal.IpAttachment("firstAddressAssignment", new()
{
DeviceId = mydevice.Id,
CidrNotation = Std.Cidrhost.Invoke(new()
{
Input = myblockMetalReservedIpBlock.CidrNotation,
Host = 0,
}).Apply(invoke => Std.Join.Invoke(new()
{
Separator = "/",
Input = new[]
{
invoke.Result,
"32",
},
})).Apply(invoke => invoke.Result),
});
});
package main
import (
"github.com/equinix/pulumi-equinix/sdk/go/equinix/metal"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := metal.NewReservedIpBlock(ctx, "myblock", &metal.ReservedIpBlockArgs{
ProjectId: pulumi.Any(projectId),
Metro: pulumi.String("ny"),
Quantity: pulumi.Int(2),
})
if err != nil {
return err
}
invokeJoin, err := std.Join(ctx, &std.JoinArgs{
Separator: "/",
Input: []*string{
std.Cidrhost(ctx, &std.CidrhostArgs{
Input: myblockMetalReservedIpBlock.CidrNotation,
Host: 0,
}, nil).Result,
"32",
},
}, nil)
if err != nil {
return err
}
_, err = metal.NewIpAttachment(ctx, "firstAddressAssignment", &metal.IpAttachmentArgs{
DeviceId: pulumi.Any(mydevice.Id),
CidrNotation: pulumi.String(invokeJoin.Result),
})
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.equinix.metal.ReservedIpBlock;
import com.pulumi.equinix.metal.ReservedIpBlockArgs;
import com.pulumi.equinix.metal.IpAttachment;
import com.pulumi.equinix.metal.IpAttachmentArgs;
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) {
var myblock = new ReservedIpBlock("myblock", ReservedIpBlockArgs.builder()
.projectId(projectId)
.metro("ny")
.quantity(2)
.build());
var firstAddressAssignment = new IpAttachment("firstAddressAssignment", IpAttachmentArgs.builder()
.deviceId(mydevice.id())
.cidrNotation(StdFunctions.join(JoinArgs.builder()
.separator("/")
.input(
StdFunctions.cidrhost(CidrhostArgs.builder()
.input(myblockMetalReservedIpBlock.cidrNotation())
.host(0)
.build()).result(),
"32")
.build()).result())
.build());
}
}
import pulumi
import pulumi_equinix as equinix
import pulumi_std as std
myblock = equinix.metal.ReservedIpBlock("myblock",
project_id=project_id,
metro="ny",
quantity=2)
first_address_assignment = equinix.metal.IpAttachment("firstAddressAssignment",
device_id=mydevice["id"],
cidr_notation=std.join_output(separator="/",
input=[
std.cidrhost_output(input=myblock_metal_reserved_ip_block["cidrNotation"],
host=0).apply(lambda invoke: invoke.result),
"32",
]).apply(lambda invoke: invoke.result))
import * as pulumi from "@pulumi/pulumi";
import * as equinix from "@equinix-labs/pulumi-equinix";
import * as std from "@pulumi/std";
const myblock = new equinix.metal.ReservedIpBlock("myblock", {
projectId: projectId,
metro: "ny",
quantity: 2,
});
const firstAddressAssignment = new equinix.metal.IpAttachment("firstAddressAssignment", {
deviceId: mydevice.id,
cidrNotation: std.joinOutput({
separator: "/",
input: [
std.cidrhostOutput({
input: myblockMetalReservedIpBlock.cidrNotation,
host: 0,
}).apply(invoke => invoke.result),
"32",
],
}).apply(invoke => invoke.result),
});
resources:
# Reserve /30 block of max 2 public IPv4 addresses in metro ny for myproject
myblock:
type: equinix:metal:ReservedIpBlock
properties:
projectId: ${projectId}
metro: ny
quantity: 2
# Assign /32 subnet (single address) from reserved block to a device
firstAddressAssignment:
type: equinix:metal:IpAttachment
name: first_address_assignment
properties:
deviceId: ${mydevice.id}
cidrNotation:
fn::invoke:
Function: std:join
Arguments:
separator: /
input:
- fn::invoke:
Function: std:cidrhost
Arguments:
input: ${myblockMetalReservedIpBlock.cidrNotation}
host: 0
Return: result
- '32'
Return: result
Create IpAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new IpAttachment(name: string, args: IpAttachmentArgs, opts?: CustomResourceOptions);
@overload
def IpAttachment(resource_name: str,
args: IpAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def IpAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
cidr_notation: Optional[str] = None,
device_id: Optional[str] = None)
func NewIpAttachment(ctx *Context, name string, args IpAttachmentArgs, opts ...ResourceOption) (*IpAttachment, error)
public IpAttachment(string name, IpAttachmentArgs args, CustomResourceOptions? opts = null)
public IpAttachment(String name, IpAttachmentArgs args)
public IpAttachment(String name, IpAttachmentArgs args, CustomResourceOptions options)
type: equinix:metal:IpAttachment
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 IpAttachmentArgs
- 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 IpAttachmentArgs
- 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 IpAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args IpAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args IpAttachmentArgs
- 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 ipAttachmentResource = new Equinix.Metal.IpAttachment("ipAttachmentResource", new()
{
CidrNotation = "string",
DeviceId = "string",
});
example, err := metal.NewIpAttachment(ctx, "ipAttachmentResource", &metal.IpAttachmentArgs{
CidrNotation: pulumi.String("string"),
DeviceId: pulumi.String("string"),
})
var ipAttachmentResource = new IpAttachment("ipAttachmentResource", IpAttachmentArgs.builder()
.cidrNotation("string")
.deviceId("string")
.build());
ip_attachment_resource = equinix.metal.IpAttachment("ipAttachmentResource",
cidr_notation="string",
device_id="string")
const ipAttachmentResource = new equinix.metal.IpAttachment("ipAttachmentResource", {
cidrNotation: "string",
deviceId: "string",
});
type: equinix:metal:IpAttachment
properties:
cidrNotation: string
deviceId: string
IpAttachment 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 IpAttachment resource accepts the following input properties:
- Cidr
Notation string - CIDR notation of subnet from block reserved in the same project and metro as the device.
- Device
Id string - ID of device to which to assign the subnet.
- Cidr
Notation string - CIDR notation of subnet from block reserved in the same project and metro as the device.
- Device
Id string - ID of device to which to assign the subnet.
- cidr
Notation String - CIDR notation of subnet from block reserved in the same project and metro as the device.
- device
Id String - ID of device to which to assign the subnet.
- cidr
Notation string - CIDR notation of subnet from block reserved in the same project and metro as the device.
- device
Id string - ID of device to which to assign the subnet.
- cidr_
notation str - CIDR notation of subnet from block reserved in the same project and metro as the device.
- device_
id str - ID of device to which to assign the subnet.
- cidr
Notation String - CIDR notation of subnet from block reserved in the same project and metro as the device.
- device
Id String - ID of device to which to assign the subnet.
Outputs
All input properties are implicitly available as output properties. Additionally, the IpAttachment resource produces the following output properties:
- Address string
- Address
Family int - Address family as integer. One of
4
or6
. - Cidr int
- Length of CIDR prefix of the subnet as integer.
- Gateway string
- IP address of gateway for the subnet.
- Global bool
- Flag indicating whether IP block is global, i.e. assignable in any location
- Id string
- The provider-assigned unique ID for this managed resource.
- Manageable bool
- Management bool
- Netmask string
- Subnet mask in decimal notation, e.g.,
255.255.255.0
. - Network string
- Subnet network address.
- Public bool
- Boolean flag whether subnet is reachable from the Internet.
- Vrf
Id string
- Address string
- Address
Family int - Address family as integer. One of
4
or6
. - Cidr int
- Length of CIDR prefix of the subnet as integer.
- Gateway string
- IP address of gateway for the subnet.
- Global bool
- Flag indicating whether IP block is global, i.e. assignable in any location
- Id string
- The provider-assigned unique ID for this managed resource.
- Manageable bool
- Management bool
- Netmask string
- Subnet mask in decimal notation, e.g.,
255.255.255.0
. - Network string
- Subnet network address.
- Public bool
- Boolean flag whether subnet is reachable from the Internet.
- Vrf
Id string
- address String
- address
Family Integer - Address family as integer. One of
4
or6
. - cidr Integer
- Length of CIDR prefix of the subnet as integer.
- gateway String
- IP address of gateway for the subnet.
- global Boolean
- Flag indicating whether IP block is global, i.e. assignable in any location
- id String
- The provider-assigned unique ID for this managed resource.
- manageable Boolean
- management Boolean
- netmask String
- Subnet mask in decimal notation, e.g.,
255.255.255.0
. - network String
- Subnet network address.
- public_ Boolean
- Boolean flag whether subnet is reachable from the Internet.
- vrf
Id String
- address string
- address
Family number - Address family as integer. One of
4
or6
. - cidr number
- Length of CIDR prefix of the subnet as integer.
- gateway string
- IP address of gateway for the subnet.
- global boolean
- Flag indicating whether IP block is global, i.e. assignable in any location
- id string
- The provider-assigned unique ID for this managed resource.
- manageable boolean
- management boolean
- netmask string
- Subnet mask in decimal notation, e.g.,
255.255.255.0
. - network string
- Subnet network address.
- public boolean
- Boolean flag whether subnet is reachable from the Internet.
- vrf
Id string
- address str
- address_
family int - Address family as integer. One of
4
or6
. - cidr int
- Length of CIDR prefix of the subnet as integer.
- gateway str
- IP address of gateway for the subnet.
- global_ bool
- Flag indicating whether IP block is global, i.e. assignable in any location
- id str
- The provider-assigned unique ID for this managed resource.
- manageable bool
- management bool
- netmask str
- Subnet mask in decimal notation, e.g.,
255.255.255.0
. - network str
- Subnet network address.
- public bool
- Boolean flag whether subnet is reachable from the Internet.
- vrf_
id str
- address String
- address
Family Number - Address family as integer. One of
4
or6
. - cidr Number
- Length of CIDR prefix of the subnet as integer.
- gateway String
- IP address of gateway for the subnet.
- global Boolean
- Flag indicating whether IP block is global, i.e. assignable in any location
- id String
- The provider-assigned unique ID for this managed resource.
- manageable Boolean
- management Boolean
- netmask String
- Subnet mask in decimal notation, e.g.,
255.255.255.0
. - network String
- Subnet network address.
- public Boolean
- Boolean flag whether subnet is reachable from the Internet.
- vrf
Id String
Look up Existing IpAttachment Resource
Get an existing IpAttachment 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?: IpAttachmentState, opts?: CustomResourceOptions): IpAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
address: Optional[str] = None,
address_family: Optional[int] = None,
cidr: Optional[int] = None,
cidr_notation: Optional[str] = None,
device_id: Optional[str] = None,
gateway: Optional[str] = None,
global_: Optional[bool] = None,
manageable: Optional[bool] = None,
management: Optional[bool] = None,
netmask: Optional[str] = None,
network: Optional[str] = None,
public: Optional[bool] = None,
vrf_id: Optional[str] = None) -> IpAttachment
func GetIpAttachment(ctx *Context, name string, id IDInput, state *IpAttachmentState, opts ...ResourceOption) (*IpAttachment, error)
public static IpAttachment Get(string name, Input<string> id, IpAttachmentState? state, CustomResourceOptions? opts = null)
public static IpAttachment get(String name, Output<String> id, IpAttachmentState 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.
- Address string
- Address
Family int - Address family as integer. One of
4
or6
. - Cidr int
- Length of CIDR prefix of the subnet as integer.
- Cidr
Notation string - CIDR notation of subnet from block reserved in the same project and metro as the device.
- Device
Id string - ID of device to which to assign the subnet.
- Gateway string
- IP address of gateway for the subnet.
- Global bool
- Flag indicating whether IP block is global, i.e. assignable in any location
- Manageable bool
- Management bool
- Netmask string
- Subnet mask in decimal notation, e.g.,
255.255.255.0
. - Network string
- Subnet network address.
- Public bool
- Boolean flag whether subnet is reachable from the Internet.
- Vrf
Id string
- Address string
- Address
Family int - Address family as integer. One of
4
or6
. - Cidr int
- Length of CIDR prefix of the subnet as integer.
- Cidr
Notation string - CIDR notation of subnet from block reserved in the same project and metro as the device.
- Device
Id string - ID of device to which to assign the subnet.
- Gateway string
- IP address of gateway for the subnet.
- Global bool
- Flag indicating whether IP block is global, i.e. assignable in any location
- Manageable bool
- Management bool
- Netmask string
- Subnet mask in decimal notation, e.g.,
255.255.255.0
. - Network string
- Subnet network address.
- Public bool
- Boolean flag whether subnet is reachable from the Internet.
- Vrf
Id string
- address String
- address
Family Integer - Address family as integer. One of
4
or6
. - cidr Integer
- Length of CIDR prefix of the subnet as integer.
- cidr
Notation String - CIDR notation of subnet from block reserved in the same project and metro as the device.
- device
Id String - ID of device to which to assign the subnet.
- gateway String
- IP address of gateway for the subnet.
- global Boolean
- Flag indicating whether IP block is global, i.e. assignable in any location
- manageable Boolean
- management Boolean
- netmask String
- Subnet mask in decimal notation, e.g.,
255.255.255.0
. - network String
- Subnet network address.
- public_ Boolean
- Boolean flag whether subnet is reachable from the Internet.
- vrf
Id String
- address string
- address
Family number - Address family as integer. One of
4
or6
. - cidr number
- Length of CIDR prefix of the subnet as integer.
- cidr
Notation string - CIDR notation of subnet from block reserved in the same project and metro as the device.
- device
Id string - ID of device to which to assign the subnet.
- gateway string
- IP address of gateway for the subnet.
- global boolean
- Flag indicating whether IP block is global, i.e. assignable in any location
- manageable boolean
- management boolean
- netmask string
- Subnet mask in decimal notation, e.g.,
255.255.255.0
. - network string
- Subnet network address.
- public boolean
- Boolean flag whether subnet is reachable from the Internet.
- vrf
Id string
- address str
- address_
family int - Address family as integer. One of
4
or6
. - cidr int
- Length of CIDR prefix of the subnet as integer.
- cidr_
notation str - CIDR notation of subnet from block reserved in the same project and metro as the device.
- device_
id str - ID of device to which to assign the subnet.
- gateway str
- IP address of gateway for the subnet.
- global_ bool
- Flag indicating whether IP block is global, i.e. assignable in any location
- manageable bool
- management bool
- netmask str
- Subnet mask in decimal notation, e.g.,
255.255.255.0
. - network str
- Subnet network address.
- public bool
- Boolean flag whether subnet is reachable from the Internet.
- vrf_
id str
- address String
- address
Family Number - Address family as integer. One of
4
or6
. - cidr Number
- Length of CIDR prefix of the subnet as integer.
- cidr
Notation String - CIDR notation of subnet from block reserved in the same project and metro as the device.
- device
Id String - ID of device to which to assign the subnet.
- gateway String
- IP address of gateway for the subnet.
- global Boolean
- Flag indicating whether IP block is global, i.e. assignable in any location
- manageable Boolean
- management Boolean
- netmask String
- Subnet mask in decimal notation, e.g.,
255.255.255.0
. - network String
- Subnet network address.
- public Boolean
- Boolean flag whether subnet is reachable from the Internet.
- vrf
Id String
Package Details
- Repository
- equinix equinix/pulumi-equinix
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
equinix
Terraform Provider.