Try AWS Native preview for resources not in the classic version.
AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi
aws.ec2.getAmiIds
Explore with Pulumi AI
Try AWS Native preview for resources not in the classic version.
AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi
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)
// Output-based functions aren't available in Java yet
fn::invoke:
function: aws:ec2/getAmiIds:getAmiIds
arguments:
# arguments dictionary
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 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 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.
- Sort
Ascending 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
). - 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 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 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.
- 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
). - 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 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 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
. - name
Regex 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.
- sort
Ascending 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
). - 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 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 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
. - name
Regex 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.
- sort
Ascending 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[Get
Ami 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
). - 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<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].
- include
Deprecated 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
. - name
Regex 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.
- sort
Ascending 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>
- Executable
Users List<string> - Filters
List<Get
Ami Ids Filter> - Include
Deprecated bool - Name
Regex string - Sort
Ascending bool
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids []string
- Owners []string
- Executable
Users []string - Filters
[]Get
Ami Ids Filter - Include
Deprecated bool - Name
Regex string - Sort
Ascending bool
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- owners List<String>
- executable
Users List<String> - filters
List<Get
Ami Ids Filter> - include
Deprecated Boolean - name
Regex String - sort
Ascending Boolean
- id string
- The provider-assigned unique ID for this managed resource.
- ids string[]
- owners string[]
- executable
Users string[] - filters
Get
Ami Ids Filter[] - include
Deprecated boolean - name
Regex string - sort
Ascending boolean
- id str
- The provider-assigned unique ID for this managed resource.
- ids Sequence[str]
- owners Sequence[str]
- executable_
users Sequence[str] - filters
Sequence[Get
Ami 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>
- executable
Users List<String> - filters List<Property Map>
- include
Deprecated Boolean - name
Regex String - sort
Ascending Boolean
Supporting Types
GetAmiIdsFilter
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.
Try AWS Native preview for resources not in the classic version.
AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi