NQE - AWS Hosts / Instances with MACs

  • 17 January 2024
  • 0 replies
  • 33 views

Userlevel 3

Forward Networks NQE is very powerful.  The information is there.  The examples are clearly written for copying and pasting to create or combine new queries.  

This NQE lists the AWS Hosts / Instances with MAC address(es).  Listing the instance type (ex: t2.micro) enables sorting by size.  Or, finding whether the instance is up or down.  Or simply listing all instances across all accounts.  
 

/**
* @intent List all AWS Hosts and MAC Addresses
* @description List all AWS Hosts and MAC Addresses
*/

foreach cloudAccount in network.cloudAccounts
foreach vpc in cloudAccount.vpcs
foreach computeInstance in vpc.computeInstances
foreach iface in computeInstance.instanceIfaces
foreach subnet in vpc.subnets
where subnet.id == iface.subnetId
foreach subnetIface in subnet.ifaces
where subnetIface.id == iface.ifaceId
select {
cloudAccountName: cloudAccount.name,
vpcId: vpc.id,
computeInstanceId: computeInstance.id,
name: computeInstance.name,
tags: computeInstance.tags,
isUp: computeInstance.isUp,
imageName: computeInstance.imageName,
instanceType: computeInstance.instanceType,
ifaceSubnet: iface.subnetId,
ifaceID: iface.ifaceId,
subnetAddresses: subnet.addresses,
subnetIfaceAddresses: subnetIface.ipAddresses,
ifaceMacs: subnetIface.macAddress
}

 


0 replies

Be the first to reply!

Reply