Skip to content
Menu
Tech Automation Blog
  • About Author
  • Contact
Tech Automation Blog

AWS RDS complete inventory using Powershell

Posted on August 21, 2019February 27, 2022

Following definition of Amazon Relational Database Service (RDS) is taken from AWS documentation for RDS. Please refer here for more information – “Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. It provides cost-efficient and resizable capacity while automating time-consuming administration tasks such as hardware provisioning, database setup, patching and backups. It frees you to focus on your applications so you can give them the fast performance, high availability, security and compatibility they need.”

Below script will help you to generate an inventory of RDS Database tables in your Account. I tried to include all properties you might need. However, Feel free to add your stuff as require. This script assumes you have already setup your AWS credentials and AWS Powershell SDK to run this script on your system. If you face any issue setting those, please refer following documents to set those:

  • 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)\RDSDBInstances_Details_$($date).csv"
if(Test-Path $oFile){Remove-Item $oFile -Force}

"DBInstance Name,DB Size,Allocated Storage(GB),Storage Type,Availability Zone, Backup Retention Period,Database Engine,DBEngine Version,Creation Time,Licesne Model" | Out-File $oFile -Append -Encoding ascii 

$awsAccountId = @(get-ec2securitygroup -GroupNames "default")[0].OwnerId
Get-RDSDBInstance | ForEach-Object{
    $dbInstanceName = $dbSize = $allocatedStoage = $storageType = $avZone = $backupRet = $dbEngine = $dbEngineVer = $createDate = $licModel = ""
    $dbInstanceName = $_.DBInstanceIdentifier
    $dbSize = $_.DBInstanceClass
    $allocatedStoage = $_.AllocatedStorage
    $storageType = $_.StorageType
    $createDate = $_.InstanceCreateTime
    $avZone = $_.AvailabilityZone
    $backupRet = $_.BackupRetentionPeriod
    $dbEngine = $_.Engine
    $dbEngineVer = $_.EngineVersion
    $licModel = $_.LicenseModel
    $rdsARN = "arn:aws:rds:" + ($avZone.Substring(0,$avZone.Length -1))+":"+$awsAccountId+":db:"+$dbInstanceName
	
	#Here we have associated Tags with the ELB. You may use it to further parse Tags.
    $tags = Get-RDSTagForResource -ResourceName $rdsARN
	
"$dbInstanceName,$dbSize,$allocatedStoage,$storageType,$avZone,$backupRet,$dbEngine,$dbEngineVer,$createDate,$licModel" |  Out-File $oFile -Append -Encoding ascii 
}
Exit

Before running aws scripts, set up your aws credentials following provided documentation above.

This image has an empty alt attribute; its file name is image-22.png
aws credential sample file

Download above script and save it with a .ps1 file extension. Open aws powershell sdk tool console. Once, it is open run the script saved previously.

Run Powershell script

Once the script execution completes, it will generate a CSV file output like below screenshot:

Output CSV File(For me it’s blank as I don’t have any RDS deployed)

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn
May 2025
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  
« May    

Recent Posts

  • Monitor and alert Azure Service Health issues May 5, 2020
  • AWS IAM User access review May 3, 2020
  • Integrate Azure Security Center with Event Hub April 28, 2020
  • Add Tags to Azure Subscription April 24, 2020
  • Automate Azure billing report in Excel March 6, 2020

Categories

©2025 Tech Automation Blog | Powered by SuperbThemes