Amazon Elastic IP address is static IPV4 Address in aws account. Any back-end failure of instance or software can be remapped with another instance or software by keeping same IP address. Refer here for more information about aws Elastic IP Address.
Following script generates inventory of EIP in an aws account. It assumes, you have already setup your aws credentials and aws powershell SDK. Refer following documents if you face any issue:
- https://docs.aws.amazon.com/powershell/latest/userguide/specifying-your-aws-credentials.html
- https://aws.amazon.com/powershell/
Let me know if this is helpful!
$date = Get-Date -UFormat "%m-%d-%Y"
$currentDir = $(Get-Location).Path
$oFile = "$($currentDir)\EIP_Details_$($date).csv"
if(Test-Path $oFile){Remove-Item $oFile -Force}
"Public IP,Public IP Name,Allocation ID,Domain,Instance ID, Network Interface ID,PublicIpv4Pool" | Out-File $oFile -Append -Encoding ascii
Get-EC2Address | ForEach-Object {
$pubIp = $pubIpName = $allocId = $domain = $InstanceId = $netInterfaceId = $pubIpPool = ""
$pubIp = $_.PublicIp
$allocId = $_.AllocationId
$tags = $_.Tags
if(!([string]::IsNullOrEmpty($tags))){
if($tags.Key -eq "Name"){$pubIpName = $tags | Where-Object { $_.Key -eq "Name" } | Select-Object -expand Value}
}
$domain = $_.Domain
$InstanceId = $_.InstanceId
$netInterfaceId = $_.NetworkInterfaceId
$pubIpPool = $_.PublicIpv4Pool
"$pubIp,$pubIpName ,$allocId, $domain, $InstanceId, $netInterfaceId ,$pubIpPool" | Out-File $oFile -Append -Encoding ascii
}
Exit
Before running aws scripts, set up your aws credentials following provided documentation above.
Download above script and save it with a .ps1 file extension. After that, open aws powershell sdk tool console. Once, it is open run the script saved previously.
Once the script execution completes, it will generate a CSV file output like below screenshot: