AmiFromInstance class

The "AMI from instance" resource allows the creation of an Amazon Machine Image (AMI) modeled 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

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.ec2.AmiFromInstance("example", {
    name: "example",
    sourceInstanceId: "i-xxxxxxxx",
});
import pulumi
import pulumi_aws as aws

example = aws.ec2.AmiFromInstance("example",
    name="example",
    source_instance_id="i-xxxxxxxx")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.Ec2.AmiFromInstance("example", new()
    {
        Name = "example",
        SourceInstanceId = "i-xxxxxxxx",
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ec2.NewAmiFromInstance(ctx, "example", &ec2.AmiFromInstanceArgs{
			Name:             pulumi.String("example"),
			SourceInstanceId: pulumi.String("i-xxxxxxxx"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_ec2_amifrominstance" "example" {
  name               = "example"
  source_instance_id = "i-xxxxxxxx"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.AmiFromInstance;
import com.pulumi.aws.ec2.AmiFromInstanceArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 AmiFromInstance("example", AmiFromInstanceArgs.builder()
            .name("example")
            .sourceInstanceId("i-xxxxxxxx")
            .build());

    }
}
resources:
  example:
    type: aws:ec2:AmiFromInstance
    properties:
      name: example
      sourceInstanceId: i-xxxxxxxx

Constructors

AmiFromInstance(String name, {AmiFromInstanceArgs? args, CustomResourceOptions? options})
Creates a new AmiFromInstance. name The Pulumi resource name. args Arguments used to configure this AmiFromInstance. The set of arguments for AmiFromInstance. options Resource options controlling this resource's behavior.
AmiFromInstance.reference(String urn)
Creates a typed reference to an existing AmiFromInstance resource.

Properties

architecture ↔ Output<String>
Machine architecture for created instances. Defaults to x8664.
latefinal
arn ↔ Output<String>
ARN of the AMI.
latefinal
bootMode ↔ Output<String>
Boot mode of the AMI. For more information, see Boot modes in the EC2 User Guide.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
deprecationTime ↔ Output<String?>
Date and time to deprecate the AMI. If you specified a value for seconds, Amazon EC2 rounds the seconds to the nearest minute. Valid values: RFC3339 time string (YYYY-MM-DDTHH:MM:SSZ)
latefinal
description ↔ Output<String?>
Longer, human-readable description for the AMI.
latefinal
ebsBlockDevices ↔ Output<List<AmiFromInstanceEbsBlockDevice>>
Nested block describing an EBS block device that should be attached to created instances. The structure of this block is described below.
latefinal
enaSupport ↔ Output<bool>
Whether enhanced networking with ENA is enabled. Defaults to false.
latefinal
ephemeralBlockDevices ↔ Output<List<AmiFromInstanceEphemeralBlockDevice>>
Nested block describing an ephemeral block device that should be attached to created instances. The structure of this block is described below.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
hypervisor ↔ Output<String>
latefinal
id ↔ Output<String>
getter/setter pairinherited
imageLocation ↔ Output<String>
Path to an S3 object containing an image manifest, e.g., created by the ec2-upload-bundle command in the EC2 command line tools.
latefinal
imageOwnerAlias ↔ Output<String>
latefinal
imageType ↔ Output<String>
latefinal
imdsSupport ↔ Output<String>
If EC2 instances started from this image should require the use of the Instance Metadata Service V2 (IMDSv2), set this argument to v2.0. For more information, see Configure instance metadata options for new instances.
latefinal
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
kernelId ↔ Output<String>
ID of the kernel image (AKI) that will be used as the paravirtual kernel in created instances.
latefinal
lastLaunchedTime ↔ Output<String>
Date and time, in ISO 8601 date-time format , when the AMI was last used to launch an EC2 instance. When the AMI is used to launch an instance, there is a 24-hour delay before that usage is reported. For more information, see the following AWS document.
latefinal
manageEbsSnapshots ↔ Output<bool>
latefinal
name ↔ Output<String>
Region-unique name for the AMI.
latefinal
ownerId ↔ Output<String>
latefinal
platform ↔ Output<String>
latefinal
platformDetails ↔ Output<String>
latefinal
public ↔ Output<bool>
latefinal
ramdiskId ↔ Output<String>
ID of an initrd image (ARI) that will be used when booting the created instances.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
rootDeviceName ↔ Output<String>
Name of the root device (for example, /dev/sda1, or /dev/xvda).
latefinal
rootSnapshotId ↔ Output<String>
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
snapshotWithoutReboot ↔ Output<bool?>
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.
latefinal
sourceInstanceId ↔ Output<String>
ID of the instance to use as the basis of the AMI.
latefinal
sriovNetSupport ↔ Output<String>
When set to "simple" (the default), enables enhanced networking for created instances. No other value is supported at this time.
latefinal
tags ↔ Output<Map<String, String>?>
Map of tags to assign to the resource. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
latefinal
tagsAll ↔ Output<Map<String, String>>
latefinal
tpmSupport ↔ Output<String>
If the image is configured for NitroTPM support, the value is v2.0. For more information, see NitroTPM in the EC2 User Guide.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
uefiData ↔ Output<String>
Base64 representation of the non-volatile UEFI variable store.
latefinal
urn ↔ Output<String>
latefinalinherited
usageOperation ↔ Output<String>
latefinal
virtualizationType ↔ Output<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.
latefinal

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {AmiFromInstanceState? state, CustomResourceOptions? options}) → AmiFromInstance
Gets an existing AmiFromInstance resource's state with the given name and id.