AWS v6.73.0 published on Wednesday, Mar 19, 2025 by Pulumi
aws.ec2.getAmiIds
Explore with Pulumi AI
Use this data source to get a list of AMI IDs matching the specified criteria.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const ubuntu = aws.ec2.getAmiIds({
    owners: ["099720109477"],
    filters: [{
        name: "name",
        values: ["ubuntu/images/ubuntu-*-*-amd64-server-*"],
    }],
});
import pulumi
import pulumi_aws as aws
ubuntu = aws.ec2.get_ami_ids(owners=["099720109477"],
    filters=[{
        "name": "name",
        "values": ["ubuntu/images/ubuntu-*-*-amd64-server-*"],
    }])
package main
import (
	"github.com/pulumi/pulumi-aws/sdk/v6/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{
			Owners: []string{
				"099720109477",
			},
			Filters: []ec2.GetAmiIdsFilter{
				{
					Name: "name",
					Values: []string{
						"ubuntu/images/ubuntu-*-*-amd64-server-*",
					},
				},
			},
		}, nil)
		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 ubuntu = Aws.Ec2.GetAmiIds.Invoke(new()
    {
        Owners = new[]
        {
            "099720109477",
        },
        Filters = new[]
        {
            new Aws.Ec2.Inputs.GetAmiIdsFilterInputArgs
            {
                Name = "name",
                Values = new[]
                {
                    "ubuntu/images/ubuntu-*-*-amd64-server-*",
                },
            },
        },
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Ec2Functions;
import com.pulumi.aws.ec2.inputs.GetAmiIdsArgs;
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) {
        final var ubuntu = Ec2Functions.getAmiIds(GetAmiIdsArgs.builder()
            .owners("099720109477")
            .filters(GetAmiIdsFilterArgs.builder()
                .name("name")
                .values("ubuntu/images/ubuntu-*-*-amd64-server-*")
                .build())
            .build());
    }
}
variables:
  ubuntu:
    fn::invoke:
      function: aws:ec2:getAmiIds
      arguments:
        owners:
          - '099720109477'
        filters:
          - name: name
            values:
              - ubuntu/images/ubuntu-*-*-amd64-server-*
Using getAmiIds
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getAmiIds(args: GetAmiIdsArgs, opts?: InvokeOptions): Promise<GetAmiIdsResult>
function getAmiIdsOutput(args: GetAmiIdsOutputArgs, opts?: InvokeOptions): Output<GetAmiIdsResult>def get_ami_ids(executable_users: Optional[Sequence[str]] = None,
                filters: Optional[Sequence[GetAmiIdsFilter]] = None,
                include_deprecated: Optional[bool] = None,
                name_regex: Optional[str] = None,
                owners: Optional[Sequence[str]] = None,
                sort_ascending: Optional[bool] = None,
                opts: Optional[InvokeOptions] = None) -> GetAmiIdsResult
def get_ami_ids_output(executable_users: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetAmiIdsFilterArgs]]]] = None,
                include_deprecated: Optional[pulumi.Input[bool]] = None,
                name_regex: Optional[pulumi.Input[str]] = None,
                owners: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                sort_ascending: Optional[pulumi.Input[bool]] = None,
                opts: Optional[InvokeOptions] = None) -> Output[GetAmiIdsResult]func GetAmiIds(ctx *Context, args *GetAmiIdsArgs, opts ...InvokeOption) (*GetAmiIdsResult, error)
func GetAmiIdsOutput(ctx *Context, args *GetAmiIdsOutputArgs, opts ...InvokeOption) GetAmiIdsResultOutput> Note: This function is named GetAmiIds in the Go SDK.
public static class GetAmiIds 
{
    public static Task<GetAmiIdsResult> InvokeAsync(GetAmiIdsArgs args, InvokeOptions? opts = null)
    public static Output<GetAmiIdsResult> Invoke(GetAmiIdsInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetAmiIdsResult> getAmiIds(GetAmiIdsArgs args, InvokeOptions options)
public static Output<GetAmiIdsResult> getAmiIds(GetAmiIdsArgs args, InvokeOptions options)
fn::invoke:
  function: aws:ec2/getAmiIds:getAmiIds
  arguments:
    # arguments dictionaryThe 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<GetAmi Ids 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].
- IncludeDeprecated bool
- If true, all deprecated AMIs are included in the response.
If false, no deprecated AMIs are included in the response. If no value is specified, the default value is false.
- NameRegex string
- 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. Combine this with other options to narrow down the list AWS returns.
- SortAscending bool
- Used to sort AMIs by creation time.
If no value is specified, the default value is false.
- 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
[]GetAmi Ids 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].
- IncludeDeprecated bool
- If true, all deprecated AMIs are included in the response.
If false, no deprecated AMIs are included in the response. If no value is specified, the default value is false.
- NameRegex string
- 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. Combine this with other options to narrow down the list AWS returns.
- SortAscending bool
- Used to sort AMIs by creation time.
If no value is specified, the default value is false.
- 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<GetAmi Ids 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].
- includeDeprecated Boolean
- If true, all deprecated AMIs are included in the response.
If false, no deprecated AMIs are included in the response. If no value is specified, the default value is false.
- nameRegex String
- 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. Combine this with other options to narrow down the list AWS returns.
- sortAscending Boolean
- Used to sort AMIs by creation time.
If no value is specified, the default value is false.
- 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
GetAmi Ids 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].
- includeDeprecated boolean
- If true, all deprecated AMIs are included in the response.
If false, no deprecated AMIs are included in the response. If no value is specified, the default value is false.
- nameRegex string
- 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. Combine this with other options to narrow down the list AWS returns.
- sortAscending boolean
- Used to sort AMIs by creation time.
If no value is specified, the default value is false.
- 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[GetAmi Ids 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].
- include_deprecated bool
- If true, all deprecated AMIs are included in the response.
If false, no deprecated AMIs are included in the response. If no value is specified, the default value is false.
- name_regex str
- 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. Combine this with other options to narrow down the list AWS returns.
- sort_ascending bool
- Used to sort AMIs by creation time.
If no value is specified, the default value is false.
- 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<Property Map>
- 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].
- includeDeprecated Boolean
- If true, all deprecated AMIs are included in the response.
If false, no deprecated AMIs are included in the response. If no value is specified, the default value is false.
- nameRegex String
- 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. Combine this with other options to narrow down the list AWS returns.
- sortAscending Boolean
- Used to sort AMIs by creation time.
If no value is specified, the default value is false.
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<GetAmi Ids Filter> 
- IncludeDeprecated bool
- NameRegex string
- SortAscending bool
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids []string
- Owners []string
- ExecutableUsers []string
- Filters
[]GetAmi Ids Filter 
- IncludeDeprecated bool
- NameRegex string
- SortAscending bool
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- owners List<String>
- executableUsers List<String>
- filters
List<GetAmi Ids Filter> 
- includeDeprecated Boolean
- nameRegex String
- sortAscending Boolean
- id string
- The provider-assigned unique ID for this managed resource.
- ids string[]
- owners string[]
- executableUsers string[]
- filters
GetAmi Ids Filter[] 
- includeDeprecated boolean
- 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[GetAmi Ids Filter] 
- include_deprecated bool
- name_regex str
- sort_ascending bool
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- owners List<String>
- executableUsers List<String>
- filters List<Property Map>
- includeDeprecated Boolean
- nameRegex String
- sortAscending Boolean
Supporting Types
GetAmiIdsFilter   
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the awsTerraform Provider.