list_nat_gateways
Retrieve NAT Gateways with their state and public IP addresses to monitor network connectivity and manage AWS infrastructure. Optionally filter by VPC ID.
Instructions
Lists NAT Gateways with their state and public IP.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vpc_id | No | Optional: Filter by VPC ID. |
Implementation Reference
- src/index.ts:1418-1436 (handler)Handler implementation for the 'list_nat_gateways' tool. It optionally filters by VPC ID, calls DescribeNatGatewaysCommand via ec2Client, maps the response to a simplified format including ID, VPC, subnet, state, public IP, and name tag, and returns as JSON.if (name === "list_nat_gateways") { const vpcId = (args as any)?.vpc_id; const input: any = {}; if (vpcId) input.Filter = [{ Name: "vpc-id", Values: [vpcId] }]; const command = new DescribeNatGatewaysCommand(input); const response = await ec2Client.send(command); const nats = response.NatGateways?.map(nat => ({ NatGatewayId: nat.NatGatewayId, VpcId: nat.VpcId, SubnetId: nat.SubnetId, State: nat.State, PublicIp: nat.NatGatewayAddresses?.[0]?.PublicIp, Name: nat.Tags?.find(t => t.Key === "Name")?.Value })) || []; return { content: [{ type: "text", text: JSON.stringify(nats, null, 2) }] }; }
- src/index.ts:331-339 (registration)Tool registration in the ListTools response, including name, description, and input schema (optional vpc_id).name: "list_nat_gateways", description: "Lists NAT Gateways with their state and public IP.", inputSchema: { type: "object", properties: { vpc_id: { type: "string", description: "Optional: Filter by VPC ID." } } } },
- src/index.ts:331-339 (schema)Input schema definition for the 'list_nat_gateways' tool as part of its registration.name: "list_nat_gateways", description: "Lists NAT Gateways with their state and public IP.", inputSchema: { type: "object", properties: { vpc_id: { type: "string", description: "Optional: Filter by VPC ID." } } } },
- src/index.ts:19-19 (helper)Import of DescribeNatGatewaysCommand and EC2Client used by the handler.import { EC2Client, DescribeInstancesCommand, DescribeSecurityGroupsCommand, DescribeAddressesCommand, DescribeVolumesCommand, DescribeVpcsCommand, DescribeSubnetsCommand, DescribeRouteTablesCommand, DescribeInternetGatewaysCommand, DescribeNatGatewaysCommand } from "@aws-sdk/client-ec2";
- src/index.ts:53-53 (helper)Initialization of the shared EC2Client instance used by the list_nat_gateways handler.const ec2Client = new EC2Client({});