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.
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.
Once the script execution completes, it will generate a CSV file output like below screenshot: