getAmiIds

Use this data source to get a list of AMI IDs matching the specified criteria.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var ubuntu = Output.Create(Aws.Ec2.GetAmiIds.InvokeAsync(new Aws.Ec2.GetAmiIdsArgs
        {
            Filters = 
            {
                new Aws.Ec2.Inputs.GetAmiIdsFilterArgs
                {
                    Name = "name",
                    Values = 
                    {
                        "ubuntu/images/ubuntu-*-*-amd64-server-*",
                    },
                },
            },
            Owners = 
            {
                "099720109477",
            },
        }));
    }

}
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ec2.GetAmiIds(ctx, &ec2.GetAmiIdsArgs{
			Filters: []ec2.GetAmiIdsFilter{
				ec2.GetAmiIdsFilter{
					Name: "name",
					Values: []string{
						"ubuntu/images/ubuntu-*-*-amd64-server-*",
					},
				},
			},
			Owners: []string{
				"099720109477",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_aws as aws

ubuntu = aws.ec2.get_ami_ids(filters=[aws.ec2.GetAmiIdsFilterArgs(
        name="name",
        values=["ubuntu/images/ubuntu-*-*-amd64-server-*"],
    )],
    owners=["099720109477"])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const ubuntu = pulumi.output(aws.ec2.getAmiIds({
    filters: [{
        name: "name",
        values: ["ubuntu/images/ubuntu-*-*-amd64-server-*"],
    }],
    owners: ["099720109477"],
}, { async: true }));

Using getAmiIds

function getAmiIds(args: GetAmiIdsArgs, opts?: InvokeOptions): Promise<GetAmiIdsResult>
def get_ami_ids(executable_users: Optional[Sequence[str]] = None,
                filters: Optional[Sequence[GetAmiIdsFilter]] = None,
                name_regex: Optional[str] = None,
                owners: Optional[Sequence[str]] = None,
                sort_ascending: Optional[bool] = None,
                opts: Optional[InvokeOptions] = None) -> GetAmiIdsResult
func GetAmiIds(ctx *Context, args *GetAmiIdsArgs, opts ...InvokeOption) (*GetAmiIdsResult, error)

Note: This function is named GetAmiIds in the Go SDK.

public static class GetAmiIds {
    public static Task<GetAmiIdsResult> InvokeAsync(GetAmiIdsArgs 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).
ExecutableUsers List<string>
Limit search to users with explicit launch permission on the image. Valid items are the numeric account ID or self.
Filters List<GetAmiIdsFilter>
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].
NameRegex 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.
SortAscending bool
Used to sort AMIs by creation time.
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).
ExecutableUsers []string
Limit search to users with explicit launch permission on the image. Valid items are the numeric account ID or self.
Filters []GetAmiIdsFilter
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].
NameRegex 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.
SortAscending bool
Used to sort AMIs by creation time.
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).
executableUsers string[]
Limit search to users with explicit launch permission on the image. Valid items are the numeric account ID or self.
filters GetAmiIdsFilter[]
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].
nameRegex 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.
sortAscending boolean
Used to sort AMIs by creation time.
owners Sequence[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 Sequence[str]
Limit search to users with explicit launch permission on the image. Valid items are the numeric account ID or self.
filters Sequence[GetAmiIdsFilter]
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].
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.
sort_ascending bool
Used to sort AMIs by creation time.

getAmiIds Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
Ids List<string>
Owners List<string>
ExecutableUsers List<string>
Filters List<GetAmiIdsFilter>
NameRegex string
SortAscending bool
Id string
The provider-assigned unique ID for this managed resource.
Ids []string
Owners []string
ExecutableUsers []string
Filters []GetAmiIdsFilter
NameRegex string
SortAscending bool
id string
The provider-assigned unique ID for this managed resource.
ids string[]
owners string[]
executableUsers string[]
filters GetAmiIdsFilter[]
nameRegex string
sortAscending boolean
id str
The provider-assigned unique ID for this managed resource.
ids Sequence[str]
owners Sequence[str]
executable_users Sequence[str]
filters Sequence[GetAmiIdsFilter]
name_regex str
sort_ascending bool

Supporting Types

GetAmiIdsFilter

Name string
Values List<string>
Name string
Values []string
name string
values string[]
name str
values Sequence[str]

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.