[GO SDK V2] NAT gateway - get availability zone
I'm trying to determine the availability zone of a NAT gateway in an account, not just for one, but for a list of NAT gateways one after another.
As far as I understand, when calling
ec2Client.DescribeNatGateways() the NAT's availability zone is not provided.
In order to get the AZ, I'm doing another API call to
ec2Client.DescribeSubnets with the NAT's subnet ID,
Only then the AZ is in the output.
As I'm making a multiple API calls, this could be time-consuming.
I was wondering what is the most efficient way to determine the NAT's AZ?
You can pull the list of AZs from the ENIs. Here is the CLI:
aws ec2 describe-network-interfaces --filters Name=interface-type,Values=nat_gateway --query NetworkInterfaces[*].AvailabilityZone
The response to
DescribeNatGateways does include the subnet id which can be used with
DescribeSubnets to determine the availability zone.
Control Tower Cost IncreaseAccepted Answerasked 3 years ago
[GO SDK V2] NAT gateway - get availability zoneAccepted Answerasked a month ago
My lambda function is able to access internet sometimes and times out sometimes even after configuring with NAT gatewayAccepted Answerasked 5 months ago
Static IP for all outbound calls from LambdaAccepted Answerasked 3 months ago
Converting NAT gateway to NAT instance to save costAccepted Answerasked 17 days ago
NAT Gateway w/ Elastic IP in Public + Private VPC with AWS Workspaces ..asked 2 years ago
EC2 instance in private subnet shows IPv4 address of NAT instanceasked 3 years ago
Transit Gateway attachment cost to VPC and subnetsAccepted Answerasked 2 years ago
cloud-init not setting default route to NAT Gatewayasked 2 years ago
Public ALB - NAT Gatewayasked 3 years ago