aws.lightsail.StaticIpAttachment
Explore with Pulumi AI
Manages a static IP address attachment - relationship between a Lightsail static IP and Lightsail instance.
Use this resource to attach a static IP address to a Lightsail instance to provide a consistent public IP address that persists across instance restarts.
Note: Lightsail is currently only supported in a limited number of AWS Regions, please see “Regions and Availability Zones in Amazon Lightsail” for more details.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.lightsail.StaticIp("example", {name: "example"});
const exampleInstance = new aws.lightsail.Instance("example", {
name: "example",
availabilityZone: "us-east-1a",
blueprintId: "ubuntu_20_04",
bundleId: "nano_2_0",
});
const exampleStaticIpAttachment = new aws.lightsail.StaticIpAttachment("example", {
staticIpName: example.id,
instanceName: exampleInstance.id,
});
import pulumi
import pulumi_aws as aws
example = aws.lightsail.StaticIp("example", name="example")
example_instance = aws.lightsail.Instance("example",
name="example",
availability_zone="us-east-1a",
blueprint_id="ubuntu_20_04",
bundle_id="nano_2_0")
example_static_ip_attachment = aws.lightsail.StaticIpAttachment("example",
static_ip_name=example.id,
instance_name=example_instance.id)
package main
import (
"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 {
example, err := lightsail.NewStaticIp(ctx, "example", &lightsail.StaticIpArgs{
Name: pulumi.String("example"),
})
if err != nil {
return err
}
exampleInstance, err := lightsail.NewInstance(ctx, "example", &lightsail.InstanceArgs{
Name: pulumi.String("example"),
AvailabilityZone: pulumi.String("us-east-1a"),
BlueprintId: pulumi.String("ubuntu_20_04"),
BundleId: pulumi.String("nano_2_0"),
})
if err != nil {
return err
}
_, err = lightsail.NewStaticIpAttachment(ctx, "example", &lightsail.StaticIpAttachmentArgs{
StaticIpName: example.ID(),
InstanceName: exampleInstance.ID(),
})
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 example = new Aws.LightSail.StaticIp("example", new()
{
Name = "example",
});
var exampleInstance = new Aws.LightSail.Instance("example", new()
{
Name = "example",
AvailabilityZone = "us-east-1a",
BlueprintId = "ubuntu_20_04",
BundleId = "nano_2_0",
});
var exampleStaticIpAttachment = new Aws.LightSail.StaticIpAttachment("example", new()
{
StaticIpName = example.Id,
InstanceName = exampleInstance.Id,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lightsail.StaticIp;
import com.pulumi.aws.lightsail.StaticIpArgs;
import com.pulumi.aws.lightsail.Instance;
import com.pulumi.aws.lightsail.InstanceArgs;
import com.pulumi.aws.lightsail.StaticIpAttachment;
import com.pulumi.aws.lightsail.StaticIpAttachmentArgs;
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 example = new StaticIp("example", StaticIpArgs.builder()
.name("example")
.build());
var exampleInstance = new Instance("exampleInstance", InstanceArgs.builder()
.name("example")
.availabilityZone("us-east-1a")
.blueprintId("ubuntu_20_04")
.bundleId("nano_2_0")
.build());
var exampleStaticIpAttachment = new StaticIpAttachment("exampleStaticIpAttachment", StaticIpAttachmentArgs.builder()
.staticIpName(example.id())
.instanceName(exampleInstance.id())
.build());
}
}
resources:
example:
type: aws:lightsail:StaticIp
properties:
name: example
exampleInstance:
type: aws:lightsail:Instance
name: example
properties:
name: example
availabilityZone: us-east-1a
blueprintId: ubuntu_20_04
bundleId: nano_2_0
exampleStaticIpAttachment:
type: aws:lightsail:StaticIpAttachment
name: example
properties:
staticIpName: ${example.id}
instanceName: ${exampleInstance.id}
Create StaticIpAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new StaticIpAttachment(name: string, args: StaticIpAttachmentArgs, opts?: CustomResourceOptions);
@overload
def StaticIpAttachment(resource_name: str,
args: StaticIpAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def StaticIpAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
instance_name: Optional[str] = None,
static_ip_name: Optional[str] = None)
func NewStaticIpAttachment(ctx *Context, name string, args StaticIpAttachmentArgs, opts ...ResourceOption) (*StaticIpAttachment, error)
public StaticIpAttachment(string name, StaticIpAttachmentArgs args, CustomResourceOptions? opts = null)
public StaticIpAttachment(String name, StaticIpAttachmentArgs args)
public StaticIpAttachment(String name, StaticIpAttachmentArgs args, CustomResourceOptions options)
type: aws:lightsail:StaticIpAttachment
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 StaticIpAttachmentArgs
- 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 StaticIpAttachmentArgs
- 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 StaticIpAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args StaticIpAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args StaticIpAttachmentArgs
- 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 staticIpAttachmentResource = new Aws.LightSail.StaticIpAttachment("staticIpAttachmentResource", new()
{
InstanceName = "string",
StaticIpName = "string",
});
example, err := lightsail.NewStaticIpAttachment(ctx, "staticIpAttachmentResource", &lightsail.StaticIpAttachmentArgs{
InstanceName: pulumi.String("string"),
StaticIpName: pulumi.String("string"),
})
var staticIpAttachmentResource = new StaticIpAttachment("staticIpAttachmentResource", StaticIpAttachmentArgs.builder()
.instanceName("string")
.staticIpName("string")
.build());
static_ip_attachment_resource = aws.lightsail.StaticIpAttachment("staticIpAttachmentResource",
instance_name="string",
static_ip_name="string")
const staticIpAttachmentResource = new aws.lightsail.StaticIpAttachment("staticIpAttachmentResource", {
instanceName: "string",
staticIpName: "string",
});
type: aws:lightsail:StaticIpAttachment
properties:
instanceName: string
staticIpName: string
StaticIpAttachment 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 StaticIpAttachment resource accepts the following input properties:
- Instance
Name string - Name of the Lightsail instance to attach the IP to.
- Static
Ip stringName - Name of the allocated static IP.
- Instance
Name string - Name of the Lightsail instance to attach the IP to.
- Static
Ip stringName - Name of the allocated static IP.
- instance
Name String - Name of the Lightsail instance to attach the IP to.
- static
Ip StringName - Name of the allocated static IP.
- instance
Name string - Name of the Lightsail instance to attach the IP to.
- static
Ip stringName - Name of the allocated static IP.
- instance_
name str - Name of the Lightsail instance to attach the IP to.
- static_
ip_ strname - Name of the allocated static IP.
- instance
Name String - Name of the Lightsail instance to attach the IP to.
- static
Ip StringName - Name of the allocated static IP.
Outputs
All input properties are implicitly available as output properties. Additionally, the StaticIpAttachment resource produces the following output properties:
- id str
- The provider-assigned unique ID for this managed resource.
- ip_
address str - Allocated static IP address.
Look up Existing StaticIpAttachment Resource
Get an existing StaticIpAttachment 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?: StaticIpAttachmentState, opts?: CustomResourceOptions): StaticIpAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
instance_name: Optional[str] = None,
ip_address: Optional[str] = None,
static_ip_name: Optional[str] = None) -> StaticIpAttachment
func GetStaticIpAttachment(ctx *Context, name string, id IDInput, state *StaticIpAttachmentState, opts ...ResourceOption) (*StaticIpAttachment, error)
public static StaticIpAttachment Get(string name, Input<string> id, StaticIpAttachmentState? state, CustomResourceOptions? opts = null)
public static StaticIpAttachment get(String name, Output<String> id, StaticIpAttachmentState state, CustomResourceOptions options)
resources: _: type: aws:lightsail:StaticIpAttachment 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.
- Instance
Name string - Name of the Lightsail instance to attach the IP to.
- Ip
Address string - Allocated static IP address.
- Static
Ip stringName - Name of the allocated static IP.
- Instance
Name string - Name of the Lightsail instance to attach the IP to.
- Ip
Address string - Allocated static IP address.
- Static
Ip stringName - Name of the allocated static IP.
- instance
Name String - Name of the Lightsail instance to attach the IP to.
- ip
Address String - Allocated static IP address.
- static
Ip StringName - Name of the allocated static IP.
- instance
Name string - Name of the Lightsail instance to attach the IP to.
- ip
Address string - Allocated static IP address.
- static
Ip stringName - Name of the allocated static IP.
- instance_
name str - Name of the Lightsail instance to attach the IP to.
- ip_
address str - Allocated static IP address.
- static_
ip_ strname - Name of the allocated static IP.
- instance
Name String - Name of the Lightsail instance to attach the IP to.
- ip
Address String - Allocated static IP address.
- static
Ip StringName - Name of the allocated static IP.
Import
Using pulumi import
, import aws_lightsail_static_ip_attachment
using the static IP name. For example:
$ pulumi import aws:lightsail/staticIpAttachment:StaticIpAttachment example example-static-ip
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.