GetAmi
Use this data source to get the ID of a registered AMI for use in other resources.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = Output.Create(Aws.GetAmi.InvokeAsync(new Aws.GetAmiArgs
{
ExecutableUsers =
{
"self",
},
Filters =
{
new Aws.Inputs.GetAmiFilterArgs
{
Name = "name",
Values =
{
"myami-*",
},
},
new Aws.Inputs.GetAmiFilterArgs
{
Name = "root-device-type",
Values =
{
"ebs",
},
},
new Aws.Inputs.GetAmiFilterArgs
{
Name = "virtualization-type",
Values =
{
"hvm",
},
},
},
MostRecent = true,
NameRegex = "^myami-\\d{3}",
Owners =
{
"self",
},
}));
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
opt0 := true
opt1 := "^myami-\\d{3}"
_, err := aws.GetAmi(ctx, &aws.GetAmiArgs{
ExecutableUsers: []string{
"self",
},
Filters: []aws.GetAmiFilter{
aws.GetAmiFilter{
Name: "name",
Values: []string{
"myami-*",
},
},
aws.GetAmiFilter{
Name: "root-device-type",
Values: []string{
"ebs",
},
},
aws.GetAmiFilter{
Name: "virtualization-type",
Values: []string{
"hvm",
},
},
},
MostRecent: &opt0,
NameRegex: &opt1,
Owners: []string{
"self",
},
}, nil)
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
example = aws.get_ami(executable_users=["self"],
filters=[
{
"name": "name",
"values": ["myami-*"],
},
{
"name": "root-device-type",
"values": ["ebs"],
},
{
"name": "virtualization-type",
"values": ["hvm"],
},
],
most_recent=True,
name_regex="^myami-\\d{3}",
owners=["self"])import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = pulumi.output(aws.getAmi({
executableUsers: ["self"],
filters: [
{
name: "name",
values: ["myami-*"],
},
{
name: "root-device-type",
values: ["ebs"],
},
{
name: "virtualization-type",
values: ["hvm"],
},
],
mostRecent: true,
nameRegex: "^myami-\\d{3}",
owners: ["self"],
}, { async: true }));Using GetAmi
function getAmi(args: GetAmiArgs, opts?: InvokeOptions): Promise<GetAmiResult>function get_ami(executable_users=None, filters=None, most_recent=None, name_regex=None, owners=None, tags=None, opts=None)func GetAmi(ctx *Context, args *GetAmiArgs, opts ...InvokeOption) (*GetAmiResult, error)public static class GetAmi {
public static Task<GetAmiResult> InvokeAsync(GetAmiArgs args, InvokeOptions? opts = null)
}The following arguments are supported:
- Owners List<string>
List of AMI owners to limit search. At least 1 value must be specified. Valid values: an AWS account ID,
self(the current account), or an AWS owner alias (e.g.amazon,aws-marketplace,microsoft).- Executable
Users List<string> Limit search to users with explicit launch permission on the image. Valid items are the numeric account ID or
self.- Filters
List<Get
Ami Filter Args> One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-images in the AWS CLI reference][1].
- Most
Recent bool If more than one result is returned, use the most recent AMI.
- Name
Regex string A regex string to apply to the AMI list returned by AWS. This allows more advanced filtering not supported from the AWS API. This filtering is done locally on what AWS returns, and could have a performance impact if the result is large. It is recommended to combine this with other options to narrow down the list AWS returns.
- Dictionary<string, string>
Any tags assigned to the image. *
tags.#.key- The key name of the tag. *tags.#.value- The value of the tag.
- Owners []string
List of AMI owners to limit search. At least 1 value must be specified. Valid values: an AWS account ID,
self(the current account), or an AWS owner alias (e.g.amazon,aws-marketplace,microsoft).- Executable
Users []string Limit search to users with explicit launch permission on the image. Valid items are the numeric account ID or
self.- Filters
[]Get
Ami Filter One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-images in the AWS CLI reference][1].
- Most
Recent bool If more than one result is returned, use the most recent AMI.
- Name
Regex string A regex string to apply to the AMI list returned by AWS. This allows more advanced filtering not supported from the AWS API. This filtering is done locally on what AWS returns, and could have a performance impact if the result is large. It is recommended to combine this with other options to narrow down the list AWS returns.
- map[string]string
Any tags assigned to the image. *
tags.#.key- The key name of the tag. *tags.#.value- The value of the tag.
- owners string[]
List of AMI owners to limit search. At least 1 value must be specified. Valid values: an AWS account ID,
self(the current account), or an AWS owner alias (e.g.amazon,aws-marketplace,microsoft).- executable
Users string[] Limit search to users with explicit launch permission on the image. Valid items are the numeric account ID or
self.- filters
Get
Ami Filter[] One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-images in the AWS CLI reference][1].
- most
Recent boolean If more than one result is returned, use the most recent AMI.
- name
Regex string A regex string to apply to the AMI list returned by AWS. This allows more advanced filtering not supported from the AWS API. This filtering is done locally on what AWS returns, and could have a performance impact if the result is large. It is recommended to combine this with other options to narrow down the list AWS returns.
- {[key: string]: string}
Any tags assigned to the image. *
tags.#.key- The key name of the tag. *tags.#.value- The value of the tag.
- owners List[str]
List of AMI owners to limit search. At least 1 value must be specified. Valid values: an AWS account ID,
self(the current account), or an AWS owner alias (e.g.amazon,aws-marketplace,microsoft).- executable_
users List[str] Limit search to users with explicit launch permission on the image. Valid items are the numeric account ID or
self.- filters
List[Get
Ami Filter] One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-images in the AWS CLI reference][1].
- most_
recent bool If more than one result is returned, use the most recent AMI.
- name_
regex str A regex string to apply to the AMI list returned by AWS. This allows more advanced filtering not supported from the AWS API. This filtering is done locally on what AWS returns, and could have a performance impact if the result is large. It is recommended to combine this with other options to narrow down the list AWS returns.
- Dict[str, str]
Any tags assigned to the image. *
tags.#.key- The key name of the tag. *tags.#.value- The value of the tag.
GetAmi Result
The following output properties are available:
- Architecture string
The OS architecture of the AMI (ie:
i386orx86_64).- Arn string
The ARN of the AMI.
- Block
Device List<GetMappings Ami Block Device Mapping> The block device mappings of the AMI. *
block_device_mappings.#.device_name- The physical name of the device. *block_device_mappings.#.ebs.delete_on_termination-trueif the EBS volume will be deleted on termination. *block_device_mappings.#.ebs.encrypted-trueif the EBS volume is encrypted. *block_device_mappings.#.ebs.iops-0if the EBS volume is not a provisioned IOPS image, otherwise the supported IOPS count. *block_device_mappings.#.ebs.snapshot_id- The ID of the snapshot. *block_device_mappings.#.ebs.volume_size- The size of the volume, in GiB. *block_device_mappings.#.ebs.volume_type- The volume type. *block_device_mappings.#.no_device- Suppresses the specified device included in the block device mapping of the AMI. *block_device_mappings.#.virtual_name- The virtual device name (for instance stores).- Creation
Date string The date and time the image was created.
- Description string
The description of the AMI that was provided during image creation.
- Hypervisor string
The hypervisor type of the image.
- Id string
The provider-assigned unique ID for this managed resource.
- Image
Id string The ID of the AMI. Should be the same as the resource
id.- Image
Location string The location of the AMI.
- Image
Owner stringAlias The AWS account alias (for example,
amazon,self) or the AWS account ID of the AMI owner.- Image
Type string The type of image.
- Kernel
Id string The kernel associated with the image, if any. Only applicable for machine images.
- Name string
The name of the AMI that was provided during image creation.
- Owner
Id string The AWS account ID of the image owner.
- Owners List<string>
- Platform string
The value is Windows for
WindowsAMIs; otherwise blank.- Product
Codes List<GetAmi Product Code> Any product codes associated with the AMI. *
product_codes.#.product_code_id- The product code. *product_codes.#.product_code_type- The type of product code.- Public bool
trueif the image has public launch permissions.- Ramdisk
Id string The RAM disk associated with the image, if any. Only applicable for machine images.
- Root
Device stringName The device name of the root device.
- Root
Device stringType The type of root device (ie:
ebsorinstance-store).- Root
Snapshot stringId The snapshot id associated with the root device, if any (only applies to
ebsroot devices).- Sriov
Net stringSupport Specifies whether enhanced networking is enabled.
- State string
The current state of the AMI. If the state is
available, the image is successfully registered and can be used to launch an instance.- State
Reason Dictionary<string, string> Describes a state change. Fields are
UNSETif not available. *state_reason.code- The reason code for the state change. *state_reason.message- The message for the state change.- Dictionary<string, string>
Any tags assigned to the image. *
tags.#.key- The key name of the tag. *tags.#.value- The value of the tag.- Virtualization
Type string The type of virtualization of the AMI (ie:
hvmorparavirtual).- Executable
Users List<string> - Filters
List<Get
Ami Filter> - Most
Recent bool - Name
Regex string
- Architecture string
The OS architecture of the AMI (ie:
i386orx86_64).- Arn string
The ARN of the AMI.
- Block
Device []GetMappings Ami Block Device Mapping The block device mappings of the AMI. *
block_device_mappings.#.device_name- The physical name of the device. *block_device_mappings.#.ebs.delete_on_termination-trueif the EBS volume will be deleted on termination. *block_device_mappings.#.ebs.encrypted-trueif the EBS volume is encrypted. *block_device_mappings.#.ebs.iops-0if the EBS volume is not a provisioned IOPS image, otherwise the supported IOPS count. *block_device_mappings.#.ebs.snapshot_id- The ID of the snapshot. *block_device_mappings.#.ebs.volume_size- The size of the volume, in GiB. *block_device_mappings.#.ebs.volume_type- The volume type. *block_device_mappings.#.no_device- Suppresses the specified device included in the block device mapping of the AMI. *block_device_mappings.#.virtual_name- The virtual device name (for instance stores).- Creation
Date string The date and time the image was created.
- Description string
The description of the AMI that was provided during image creation.
- Hypervisor string
The hypervisor type of the image.
- Id string
The provider-assigned unique ID for this managed resource.
- Image
Id string The ID of the AMI. Should be the same as the resource
id.- Image
Location string The location of the AMI.
- Image
Owner stringAlias The AWS account alias (for example,
amazon,self) or the AWS account ID of the AMI owner.- Image
Type string The type of image.
- Kernel
Id string The kernel associated with the image, if any. Only applicable for machine images.
- Name string
The name of the AMI that was provided during image creation.
- Owner
Id string The AWS account ID of the image owner.
- Owners []string
- Platform string
The value is Windows for
WindowsAMIs; otherwise blank.- Product
Codes []GetAmi Product Code Any product codes associated with the AMI. *
product_codes.#.product_code_id- The product code. *product_codes.#.product_code_type- The type of product code.- Public bool
trueif the image has public launch permissions.- Ramdisk
Id string The RAM disk associated with the image, if any. Only applicable for machine images.
- Root
Device stringName The device name of the root device.
- Root
Device stringType The type of root device (ie:
ebsorinstance-store).- Root
Snapshot stringId The snapshot id associated with the root device, if any (only applies to
ebsroot devices).- Sriov
Net stringSupport Specifies whether enhanced networking is enabled.
- State string
The current state of the AMI. If the state is
available, the image is successfully registered and can be used to launch an instance.- State
Reason map[string]string Describes a state change. Fields are
UNSETif not available. *state_reason.code- The reason code for the state change. *state_reason.message- The message for the state change.- map[string]string
Any tags assigned to the image. *
tags.#.key- The key name of the tag. *tags.#.value- The value of the tag.- Virtualization
Type string The type of virtualization of the AMI (ie:
hvmorparavirtual).- Executable
Users []string - Filters
[]Get
Ami Filter - Most
Recent bool - Name
Regex string
- architecture string
The OS architecture of the AMI (ie:
i386orx86_64).- arn string
The ARN of the AMI.
- block
Device GetMappings Ami Block Device Mapping[] The block device mappings of the AMI. *
block_device_mappings.#.device_name- The physical name of the device. *block_device_mappings.#.ebs.delete_on_termination-trueif the EBS volume will be deleted on termination. *block_device_mappings.#.ebs.encrypted-trueif the EBS volume is encrypted. *block_device_mappings.#.ebs.iops-0if the EBS volume is not a provisioned IOPS image, otherwise the supported IOPS count. *block_device_mappings.#.ebs.snapshot_id- The ID of the snapshot. *block_device_mappings.#.ebs.volume_size- The size of the volume, in GiB. *block_device_mappings.#.ebs.volume_type- The volume type. *block_device_mappings.#.no_device- Suppresses the specified device included in the block device mapping of the AMI. *block_device_mappings.#.virtual_name- The virtual device name (for instance stores).- creation
Date string The date and time the image was created.
- description string
The description of the AMI that was provided during image creation.
- hypervisor string
The hypervisor type of the image.
- id string
The provider-assigned unique ID for this managed resource.
- image
Id string The ID of the AMI. Should be the same as the resource
id.- image
Location string The location of the AMI.
- image
Owner stringAlias The AWS account alias (for example,
amazon,self) or the AWS account ID of the AMI owner.- image
Type string The type of image.
- kernel
Id string The kernel associated with the image, if any. Only applicable for machine images.
- name string
The name of the AMI that was provided during image creation.
- owner
Id string The AWS account ID of the image owner.
- owners string[]
- platform string
The value is Windows for
WindowsAMIs; otherwise blank.- product
Codes GetAmi Product Code[] Any product codes associated with the AMI. *
product_codes.#.product_code_id- The product code. *product_codes.#.product_code_type- The type of product code.- public boolean
trueif the image has public launch permissions.- ramdisk
Id string The RAM disk associated with the image, if any. Only applicable for machine images.
- root
Device stringName The device name of the root device.
- root
Device stringType The type of root device (ie:
ebsorinstance-store).- root
Snapshot stringId The snapshot id associated with the root device, if any (only applies to
ebsroot devices).- sriov
Net stringSupport Specifies whether enhanced networking is enabled.
- state string
The current state of the AMI. If the state is
available, the image is successfully registered and can be used to launch an instance.- state
Reason {[key: string]: string} Describes a state change. Fields are
UNSETif not available. *state_reason.code- The reason code for the state change. *state_reason.message- The message for the state change.- {[key: string]: string}
Any tags assigned to the image. *
tags.#.key- The key name of the tag. *tags.#.value- The value of the tag.- virtualization
Type string The type of virtualization of the AMI (ie:
hvmorparavirtual).- executable
Users string[] - filters
Get
Ami Filter[] - most
Recent boolean - name
Regex string
- architecture str
The OS architecture of the AMI (ie:
i386orx86_64).- arn str
The ARN of the AMI.
- block_
device_ List[Getmappings Ami Block Device Mapping] The block device mappings of the AMI. *
block_device_mappings.#.device_name- The physical name of the device. *block_device_mappings.#.ebs.delete_on_termination-trueif the EBS volume will be deleted on termination. *block_device_mappings.#.ebs.encrypted-trueif the EBS volume is encrypted. *block_device_mappings.#.ebs.iops-0if the EBS volume is not a provisioned IOPS image, otherwise the supported IOPS count. *block_device_mappings.#.ebs.snapshot_id- The ID of the snapshot. *block_device_mappings.#.ebs.volume_size- The size of the volume, in GiB. *block_device_mappings.#.ebs.volume_type- The volume type. *block_device_mappings.#.no_device- Suppresses the specified device included in the block device mapping of the AMI. *block_device_mappings.#.virtual_name- The virtual device name (for instance stores).- creation_
date str The date and time the image was created.
- description str
The description of the AMI that was provided during image creation.
- hypervisor str
The hypervisor type of the image.
- id str
The provider-assigned unique ID for this managed resource.
- image_
id str The ID of the AMI. Should be the same as the resource
id.- image_
location str The location of the AMI.
- image_
owner_ stralias The AWS account alias (for example,
amazon,self) or the AWS account ID of the AMI owner.- image_
type str The type of image.
- kernel_
id str The kernel associated with the image, if any. Only applicable for machine images.
- name str
The name of the AMI that was provided during image creation.
- owner_
id str The AWS account ID of the image owner.
- owners List[str]
- platform str
The value is Windows for
WindowsAMIs; otherwise blank.- product_
codes List[GetAmi Product Code] Any product codes associated with the AMI. *
product_codes.#.product_code_id- The product code. *product_codes.#.product_code_type- The type of product code.- public bool
trueif the image has public launch permissions.- ramdisk_
id str The RAM disk associated with the image, if any. Only applicable for machine images.
- root_
device_ strname The device name of the root device.
- root_
device_ strtype The type of root device (ie:
ebsorinstance-store).- root_
snapshot_ strid The snapshot id associated with the root device, if any (only applies to
ebsroot devices).- sriov_
net_ strsupport Specifies whether enhanced networking is enabled.
- state str
The current state of the AMI. If the state is
available, the image is successfully registered and can be used to launch an instance.- state_
reason Dict[str, str] Describes a state change. Fields are
UNSETif not available. *state_reason.code- The reason code for the state change. *state_reason.message- The message for the state change.- Dict[str, str]
Any tags assigned to the image. *
tags.#.key- The key name of the tag. *tags.#.value- The value of the tag.- virtualization_
type str The type of virtualization of the AMI (ie:
hvmorparavirtual).- executable_
users List[str] - filters
List[Get
Ami Filter] - most_
recent bool - name_
regex str
Supporting Types
GetAmiBlockDeviceMapping
See the output API doc for this type.
See the output API doc for this type.
See the output API doc for this type.
- Device
Name string - Ebs Dictionary<string, string>
- No
Device string - Virtual
Name string
- Device
Name string - Ebs map[string]string
- No
Device string - Virtual
Name string
- device
Name string - ebs {[key: string]: string}
- no
Device string - virtual
Name string
- device_
name str - ebs Dict[str, str]
- no
Device str - virtual
Name str
GetAmiFilter
- Name string
The name of the AMI that was provided during image creation.
- Values List<string>
GetAmiProductCode
See the output API doc for this type.
See the output API doc for this type.
See the output API doc for this type.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.