getNatGateways function
This resource can be useful for getting back a list of NAT gateway ids to be referenced elsewhere.
Example Usage
The following returns all NAT gateways in a specified VPC that are marked as available
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const ngws = aws.ec2.getNatGateways({
filters: [{
name: "state",
values: ["available"],
}],
vpcId: vpcId,
});
const ngw = .map(__index => (aws.ec2.getNatGateway({
id: _arg0_.ids[__index],
})));
import pulumi
import pulumi_aws as aws
ngws = aws.ec2.get_nat_gateways(filters=[{
"name": "state",
"values": ["available"],
}],
vpc_id=vpc_id)
ngw = [aws.ec2.get_nat_gateway(id=ngws.ids[__index]) for __index in len(ngws.ids).apply(lambda length: range(length))]
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var ngws = Aws.Ec2.GetNatGateways.Invoke(new()
{
Filters = new[]
{
new Aws.Ec2.Inputs.GetNatGatewaysFilterInputArgs
{
Name = "state",
Values = new[]
{
"available",
},
},
},
VpcId = vpcId,
});
var ngw = ;
});
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_ec2_getnatgateways" "ngws" {
filters {
name = "state"
values = ["available"]
}
vpc_id = vpcId
}
data "aws_ec2_getnatgateway" "invoke_1" {
for_each = toset(range(length(data.aws_ec2_getnatgateways.ngws.ids)))
id = data.aws_ec2_getnatgateways.ngws.ids[each.value]
}
locals {
ngw = [for __index in range(length(data.aws_ec2_getnatgateways.ngws.ids)) : data.aws_ec2_getnatgateway.invoke_1[__index]]
}
args Arguments passed to this invoke. Arguments for getNatGateways.
options Invoke options controlling this call.
Implementation
Future<GetNatGatewaysResult> getNatGateways(
GetNatGatewaysArgs args, {
pulumi.InvokeOptions? options,
}) async {
final deployment = pulumi.Deployment.instance;
final result = await deployment.invoke<Map<String, dynamic>>(
'aws:ec2/getNatGateways:getNatGateways',
args.toMap(),
options: pulumi.toDeploymentInvokeOptions(options),
);
return GetNatGatewaysResult.fromMap(result);
}