AmiFromInstance
The “AMI from instance” resource allows the creation of an Amazon Machine Image (AMI) modelled after an existing EBS-backed EC2 instance.
The created AMI will refer to implicitly-created snapshots of the instance’s EBS volumes and mimick its assigned block device configuration at the time the resource is created.
This resource is best applied to an instance that is stopped when this instance is created, so that the contents of the created image are predictable. When applied to an instance that is running, the instance will be stopped before taking the snapshots and then started back up again, resulting in a period of downtime.
Note that the source instance is inspected only at the initial creation of this resource. Ongoing updates to the referenced instance will not be propagated into the generated AMI. Users may taint or otherwise recreate the resource in order to produce a fresh snapshot.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = new Aws.Ec2.AmiFromInstance("example", new Aws.Ec2.AmiFromInstanceArgs
{
SourceInstanceId = "i-xxxxxxxx",
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ec2.NewAmiFromInstance(ctx, "example", &ec2.AmiFromInstanceArgs{
SourceInstanceId: pulumi.String("i-xxxxxxxx"),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
example = aws.ec2.AmiFromInstance("example", source_instance_id="i-xxxxxxxx")import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.ec2.AmiFromInstance("example", {
sourceInstanceId: "i-xxxxxxxx",
});Create a AmiFromInstance Resource
new AmiFromInstance(name: string, args: AmiFromInstanceArgs, opts?: CustomResourceOptions);def AmiFromInstance(resource_name, opts=None, description=None, ebs_block_devices=None, ephemeral_block_devices=None, name=None, snapshot_without_reboot=None, source_instance_id=None, tags=None, __props__=None);func NewAmiFromInstance(ctx *Context, name string, args AmiFromInstanceArgs, opts ...ResourceOption) (*AmiFromInstance, error)public AmiFromInstance(string name, AmiFromInstanceArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args AmiFromInstanceArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args AmiFromInstanceArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args AmiFromInstanceArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
AmiFromInstance Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The AmiFromInstance resource accepts the following input properties:
- Source
Instance stringId The id of the instance to use as the basis of the AMI.
- Description string
A longer, human-readable description for the AMI.
- Ebs
Block List<AmiDevices From Instance Ebs Block Device Args> Nested block describing an EBS block device that should be attached to created instances. The structure of this block is described below.
- Ephemeral
Block List<AmiDevices From Instance Ephemeral Block Device Args> Nested block describing an ephemeral block device that should be attached to created instances. The structure of this block is described below.
- Name string
A region-unique name for the AMI.
- Snapshot
Without boolReboot Boolean that overrides the behavior of stopping the instance before snapshotting. This is risky since it may cause a snapshot of an inconsistent filesystem state, but can be used to avoid downtime if the user otherwise guarantees that no filesystem writes will be underway at the time of snapshot.
- Dictionary<string, string>
A map of tags to assign to the resource.
- Source
Instance stringId The id of the instance to use as the basis of the AMI.
- Description string
A longer, human-readable description for the AMI.
- Ebs
Block []AmiDevices From Instance Ebs Block Device Nested block describing an EBS block device that should be attached to created instances. The structure of this block is described below.
- Ephemeral
Block []AmiDevices From Instance Ephemeral Block Device Nested block describing an ephemeral block device that should be attached to created instances. The structure of this block is described below.
- Name string
A region-unique name for the AMI.
- Snapshot
Without boolReboot Boolean that overrides the behavior of stopping the instance before snapshotting. This is risky since it may cause a snapshot of an inconsistent filesystem state, but can be used to avoid downtime if the user otherwise guarantees that no filesystem writes will be underway at the time of snapshot.
- map[string]string
A map of tags to assign to the resource.
- source
Instance stringId The id of the instance to use as the basis of the AMI.
- description string
A longer, human-readable description for the AMI.
- ebs
Block AmiDevices From Instance Ebs Block Device[] Nested block describing an EBS block device that should be attached to created instances. The structure of this block is described below.
- ephemeral
Block AmiDevices From Instance Ephemeral Block Device[] Nested block describing an ephemeral block device that should be attached to created instances. The structure of this block is described below.
- name string
A region-unique name for the AMI.
- snapshot
Without booleanReboot Boolean that overrides the behavior of stopping the instance before snapshotting. This is risky since it may cause a snapshot of an inconsistent filesystem state, but can be used to avoid downtime if the user otherwise guarantees that no filesystem writes will be underway at the time of snapshot.
- {[key: string]: string}
A map of tags to assign to the resource.
- source_
instance_ strid The id of the instance to use as the basis of the AMI.
- description str
A longer, human-readable description for the AMI.
- ebs_
block_ List[Amidevices From Instance Ebs Block Device] Nested block describing an EBS block device that should be attached to created instances. The structure of this block is described below.
- ephemeral_
block_ List[Amidevices From Instance Ephemeral Block Device] Nested block describing an ephemeral block device that should be attached to created instances. The structure of this block is described below.
- name str
A region-unique name for the AMI.
- snapshot_
without_ boolreboot Boolean that overrides the behavior of stopping the instance before snapshotting. This is risky since it may cause a snapshot of an inconsistent filesystem state, but can be used to avoid downtime if the user otherwise guarantees that no filesystem writes will be underway at the time of snapshot.
- Dict[str, str]
A map of tags to assign to the resource.
Outputs
All input properties are implicitly available as output properties. Additionally, the AmiFromInstance resource produces the following output properties:
- Architecture string
Machine architecture for created instances. Defaults to “x86_64”.
- Arn string
The ARN of the AMI.
- Ena
Support bool Specifies whether enhanced networking with ENA is enabled. Defaults to
false.- Id string
- The provider-assigned unique ID for this managed resource.
- Image
Location string Path to an S3 object containing an image manifest, e.g. created by the
ec2-upload-bundlecommand in the EC2 command line tools.- Kernel
Id string The id of the kernel image (AKI) that will be used as the paravirtual kernel in created instances.
- Manage
Ebs boolSnapshots - Ramdisk
Id string The id of an initrd image (ARI) that will be used when booting the created instances.
- Root
Device stringName The name of the root device (for example,
/dev/sda1, or/dev/xvda).- Root
Snapshot stringId - Sriov
Net stringSupport When set to “simple” (the default), enables enhanced networking for created instances. No other value is supported at this time.
- Virtualization
Type string Keyword to choose what virtualization mode created instances will use. Can be either “paravirtual” (the default) or “hvm”. The choice of virtualization type changes the set of further arguments that are required, as described below.
- Architecture string
Machine architecture for created instances. Defaults to “x86_64”.
- Arn string
The ARN of the AMI.
- Ena
Support bool Specifies whether enhanced networking with ENA is enabled. Defaults to
false.- Id string
- The provider-assigned unique ID for this managed resource.
- Image
Location string Path to an S3 object containing an image manifest, e.g. created by the
ec2-upload-bundlecommand in the EC2 command line tools.- Kernel
Id string The id of the kernel image (AKI) that will be used as the paravirtual kernel in created instances.
- Manage
Ebs boolSnapshots - Ramdisk
Id string The id of an initrd image (ARI) that will be used when booting the created instances.
- Root
Device stringName The name of the root device (for example,
/dev/sda1, or/dev/xvda).- Root
Snapshot stringId - Sriov
Net stringSupport When set to “simple” (the default), enables enhanced networking for created instances. No other value is supported at this time.
- Virtualization
Type string Keyword to choose what virtualization mode created instances will use. Can be either “paravirtual” (the default) or “hvm”. The choice of virtualization type changes the set of further arguments that are required, as described below.
- architecture string
Machine architecture for created instances. Defaults to “x86_64”.
- arn string
The ARN of the AMI.
- ena
Support boolean Specifies whether enhanced networking with ENA is enabled. Defaults to
false.- id string
- The provider-assigned unique ID for this managed resource.
- image
Location string Path to an S3 object containing an image manifest, e.g. created by the
ec2-upload-bundlecommand in the EC2 command line tools.- kernel
Id string The id of the kernel image (AKI) that will be used as the paravirtual kernel in created instances.
- manage
Ebs booleanSnapshots - ramdisk
Id string The id of an initrd image (ARI) that will be used when booting the created instances.
- root
Device stringName The name of the root device (for example,
/dev/sda1, or/dev/xvda).- root
Snapshot stringId - sriov
Net stringSupport When set to “simple” (the default), enables enhanced networking for created instances. No other value is supported at this time.
- virtualization
Type string Keyword to choose what virtualization mode created instances will use. Can be either “paravirtual” (the default) or “hvm”. The choice of virtualization type changes the set of further arguments that are required, as described below.
- architecture str
Machine architecture for created instances. Defaults to “x86_64”.
- arn str
The ARN of the AMI.
- ena_
support bool Specifies whether enhanced networking with ENA is enabled. Defaults to
false.- id str
- The provider-assigned unique ID for this managed resource.
- image_
location str Path to an S3 object containing an image manifest, e.g. created by the
ec2-upload-bundlecommand in the EC2 command line tools.- kernel_
id str The id of the kernel image (AKI) that will be used as the paravirtual kernel in created instances.
- manage_
ebs_ boolsnapshots - ramdisk_
id str The id of an initrd image (ARI) that will be used when booting the created instances.
- root_
device_ strname The name of the root device (for example,
/dev/sda1, or/dev/xvda).- root_
snapshot_ strid - sriov_
net_ strsupport When set to “simple” (the default), enables enhanced networking for created instances. No other value is supported at this time.
- virtualization_
type str Keyword to choose what virtualization mode created instances will use. Can be either “paravirtual” (the default) or “hvm”. The choice of virtualization type changes the set of further arguments that are required, as described below.
Look up an Existing AmiFromInstance Resource
Get an existing AmiFromInstance 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?: AmiFromInstanceState, opts?: CustomResourceOptions): AmiFromInstancestatic get(resource_name, id, opts=None, architecture=None, arn=None, description=None, ebs_block_devices=None, ena_support=None, ephemeral_block_devices=None, image_location=None, kernel_id=None, manage_ebs_snapshots=None, name=None, ramdisk_id=None, root_device_name=None, root_snapshot_id=None, snapshot_without_reboot=None, source_instance_id=None, sriov_net_support=None, tags=None, virtualization_type=None, __props__=None);func GetAmiFromInstance(ctx *Context, name string, id IDInput, state *AmiFromInstanceState, opts ...ResourceOption) (*AmiFromInstance, error)public static AmiFromInstance Get(string name, Input<string> id, AmiFromInstanceState? state, CustomResourceOptions? opts = null)- 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.
The following state arguments are supported:
- Architecture string
Machine architecture for created instances. Defaults to “x86_64”.
- Arn string
The ARN of the AMI.
- Description string
A longer, human-readable description for the AMI.
- Ebs
Block List<AmiDevices From Instance Ebs Block Device Args> Nested block describing an EBS block device that should be attached to created instances. The structure of this block is described below.
- Ena
Support bool Specifies whether enhanced networking with ENA is enabled. Defaults to
false.- Ephemeral
Block List<AmiDevices From Instance Ephemeral Block Device Args> Nested block describing an ephemeral block device that should be attached to created instances. The structure of this block is described below.
- Image
Location string Path to an S3 object containing an image manifest, e.g. created by the
ec2-upload-bundlecommand in the EC2 command line tools.- Kernel
Id string The id of the kernel image (AKI) that will be used as the paravirtual kernel in created instances.
- Manage
Ebs boolSnapshots - Name string
A region-unique name for the AMI.
- Ramdisk
Id string The id of an initrd image (ARI) that will be used when booting the created instances.
- Root
Device stringName The name of the root device (for example,
/dev/sda1, or/dev/xvda).- Root
Snapshot stringId - Snapshot
Without boolReboot Boolean that overrides the behavior of stopping the instance before snapshotting. This is risky since it may cause a snapshot of an inconsistent filesystem state, but can be used to avoid downtime if the user otherwise guarantees that no filesystem writes will be underway at the time of snapshot.
- Source
Instance stringId The id of the instance to use as the basis of the AMI.
- Sriov
Net stringSupport When set to “simple” (the default), enables enhanced networking for created instances. No other value is supported at this time.
- Dictionary<string, string>
A map of tags to assign to the resource.
- Virtualization
Type string Keyword to choose what virtualization mode created instances will use. Can be either “paravirtual” (the default) or “hvm”. The choice of virtualization type changes the set of further arguments that are required, as described below.
- Architecture string
Machine architecture for created instances. Defaults to “x86_64”.
- Arn string
The ARN of the AMI.
- Description string
A longer, human-readable description for the AMI.
- Ebs
Block []AmiDevices From Instance Ebs Block Device Nested block describing an EBS block device that should be attached to created instances. The structure of this block is described below.
- Ena
Support bool Specifies whether enhanced networking with ENA is enabled. Defaults to
false.- Ephemeral
Block []AmiDevices From Instance Ephemeral Block Device Nested block describing an ephemeral block device that should be attached to created instances. The structure of this block is described below.
- Image
Location string Path to an S3 object containing an image manifest, e.g. created by the
ec2-upload-bundlecommand in the EC2 command line tools.- Kernel
Id string The id of the kernel image (AKI) that will be used as the paravirtual kernel in created instances.
- Manage
Ebs boolSnapshots - Name string
A region-unique name for the AMI.
- Ramdisk
Id string The id of an initrd image (ARI) that will be used when booting the created instances.
- Root
Device stringName The name of the root device (for example,
/dev/sda1, or/dev/xvda).- Root
Snapshot stringId - Snapshot
Without boolReboot Boolean that overrides the behavior of stopping the instance before snapshotting. This is risky since it may cause a snapshot of an inconsistent filesystem state, but can be used to avoid downtime if the user otherwise guarantees that no filesystem writes will be underway at the time of snapshot.
- Source
Instance stringId The id of the instance to use as the basis of the AMI.
- Sriov
Net stringSupport When set to “simple” (the default), enables enhanced networking for created instances. No other value is supported at this time.
- map[string]string
A map of tags to assign to the resource.
- Virtualization
Type string Keyword to choose what virtualization mode created instances will use. Can be either “paravirtual” (the default) or “hvm”. The choice of virtualization type changes the set of further arguments that are required, as described below.
- architecture string
Machine architecture for created instances. Defaults to “x86_64”.
- arn string
The ARN of the AMI.
- description string
A longer, human-readable description for the AMI.
- ebs
Block AmiDevices From Instance Ebs Block Device[] Nested block describing an EBS block device that should be attached to created instances. The structure of this block is described below.
- ena
Support boolean Specifies whether enhanced networking with ENA is enabled. Defaults to
false.- ephemeral
Block AmiDevices From Instance Ephemeral Block Device[] Nested block describing an ephemeral block device that should be attached to created instances. The structure of this block is described below.
- image
Location string Path to an S3 object containing an image manifest, e.g. created by the
ec2-upload-bundlecommand in the EC2 command line tools.- kernel
Id string The id of the kernel image (AKI) that will be used as the paravirtual kernel in created instances.
- manage
Ebs booleanSnapshots - name string
A region-unique name for the AMI.
- ramdisk
Id string The id of an initrd image (ARI) that will be used when booting the created instances.
- root
Device stringName The name of the root device (for example,
/dev/sda1, or/dev/xvda).- root
Snapshot stringId - snapshot
Without booleanReboot Boolean that overrides the behavior of stopping the instance before snapshotting. This is risky since it may cause a snapshot of an inconsistent filesystem state, but can be used to avoid downtime if the user otherwise guarantees that no filesystem writes will be underway at the time of snapshot.
- source
Instance stringId The id of the instance to use as the basis of the AMI.
- sriov
Net stringSupport When set to “simple” (the default), enables enhanced networking for created instances. No other value is supported at this time.
- {[key: string]: string}
A map of tags to assign to the resource.
- virtualization
Type string Keyword to choose what virtualization mode created instances will use. Can be either “paravirtual” (the default) or “hvm”. The choice of virtualization type changes the set of further arguments that are required, as described below.
- architecture str
Machine architecture for created instances. Defaults to “x86_64”.
- arn str
The ARN of the AMI.
- description str
A longer, human-readable description for the AMI.
- ebs_
block_ List[Amidevices From Instance Ebs Block Device] Nested block describing an EBS block device that should be attached to created instances. The structure of this block is described below.
- ena_
support bool Specifies whether enhanced networking with ENA is enabled. Defaults to
false.- ephemeral_
block_ List[Amidevices From Instance Ephemeral Block Device] Nested block describing an ephemeral block device that should be attached to created instances. The structure of this block is described below.
- image_
location str Path to an S3 object containing an image manifest, e.g. created by the
ec2-upload-bundlecommand in the EC2 command line tools.- kernel_
id str The id of the kernel image (AKI) that will be used as the paravirtual kernel in created instances.
- manage_
ebs_ boolsnapshots - name str
A region-unique name for the AMI.
- ramdisk_
id str The id of an initrd image (ARI) that will be used when booting the created instances.
- root_
device_ strname The name of the root device (for example,
/dev/sda1, or/dev/xvda).- root_
snapshot_ strid - snapshot_
without_ boolreboot Boolean that overrides the behavior of stopping the instance before snapshotting. This is risky since it may cause a snapshot of an inconsistent filesystem state, but can be used to avoid downtime if the user otherwise guarantees that no filesystem writes will be underway at the time of snapshot.
- source_
instance_ strid The id of the instance to use as the basis of the AMI.
- sriov_
net_ strsupport When set to “simple” (the default), enables enhanced networking for created instances. No other value is supported at this time.
- Dict[str, str]
A map of tags to assign to the resource.
- virtualization_
type str Keyword to choose what virtualization mode created instances will use. Can be either “paravirtual” (the default) or “hvm”. The choice of virtualization type changes the set of further arguments that are required, as described below.
Supporting Types
AmiFromInstanceEbsBlockDevice
- Delete
On boolTermination Boolean controlling whether the EBS volumes created to support each created instance will be deleted once that instance is terminated.
- Device
Name string The path at which the device is exposed to created instances.
- Encrypted bool
Boolean controlling whether the created EBS volumes will be encrypted. Can’t be used with
snapshot_id.- Iops int
Number of I/O operations per second the created volumes will support.
- Snapshot
Id string The id of an EBS snapshot that will be used to initialize the created EBS volumes. If set, the
volume_sizeattribute must be at least as large as the referenced snapshot.- Volume
Size int The size of created volumes in GiB. If
snapshot_idis set andvolume_sizeis omitted then the volume will have the same size as the selected snapshot.- Volume
Type string The type of EBS volume to create. Can be one of “standard” (the default), “io1” or “gp2”.
- Delete
On boolTermination Boolean controlling whether the EBS volumes created to support each created instance will be deleted once that instance is terminated.
- Device
Name string The path at which the device is exposed to created instances.
- Encrypted bool
Boolean controlling whether the created EBS volumes will be encrypted. Can’t be used with
snapshot_id.- Iops int
Number of I/O operations per second the created volumes will support.
- Snapshot
Id string The id of an EBS snapshot that will be used to initialize the created EBS volumes. If set, the
volume_sizeattribute must be at least as large as the referenced snapshot.- Volume
Size int The size of created volumes in GiB. If
snapshot_idis set andvolume_sizeis omitted then the volume will have the same size as the selected snapshot.- Volume
Type string The type of EBS volume to create. Can be one of “standard” (the default), “io1” or “gp2”.
- delete
On booleanTermination Boolean controlling whether the EBS volumes created to support each created instance will be deleted once that instance is terminated.
- device
Name string The path at which the device is exposed to created instances.
- encrypted boolean
Boolean controlling whether the created EBS volumes will be encrypted. Can’t be used with
snapshot_id.- iops number
Number of I/O operations per second the created volumes will support.
- snapshot
Id string The id of an EBS snapshot that will be used to initialize the created EBS volumes. If set, the
volume_sizeattribute must be at least as large as the referenced snapshot.- volume
Size number The size of created volumes in GiB. If
snapshot_idis set andvolume_sizeis omitted then the volume will have the same size as the selected snapshot.- volume
Type string The type of EBS volume to create. Can be one of “standard” (the default), “io1” or “gp2”.
- delete
On boolTermination Boolean controlling whether the EBS volumes created to support each created instance will be deleted once that instance is terminated.
- device_
name str The path at which the device is exposed to created instances.
- encrypted bool
Boolean controlling whether the created EBS volumes will be encrypted. Can’t be used with
snapshot_id.- iops float
Number of I/O operations per second the created volumes will support.
- snapshot_
id str The id of an EBS snapshot that will be used to initialize the created EBS volumes. If set, the
volume_sizeattribute must be at least as large as the referenced snapshot.- volume
Type str The type of EBS volume to create. Can be one of “standard” (the default), “io1” or “gp2”.
- volume_
size float The size of created volumes in GiB. If
snapshot_idis set andvolume_sizeis omitted then the volume will have the same size as the selected snapshot.
AmiFromInstanceEphemeralBlockDevice
- Device
Name string The path at which the device is exposed to created instances.
- Virtual
Name string A name for the ephemeral device, of the form “ephemeralN” where N is a volume number starting from zero.
- Device
Name string The path at which the device is exposed to created instances.
- Virtual
Name string A name for the ephemeral device, of the form “ephemeralN” where N is a volume number starting from zero.
- device
Name string The path at which the device is exposed to created instances.
- virtual
Name string A name for the ephemeral device, of the form “ephemeralN” where N is a volume number starting from zero.
- device_
name str The path at which the device is exposed to created instances.
- virtual
Name str A name for the ephemeral device, of the form “ephemeralN” where N is a volume number starting from zero.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.