Amazon DynamoDB is a cloud based no-SQL key-value and document database. It is a very high performance and scalable database service from Amazon. Please refer here for more information.
Refer my post here if you are want to generate an inventory of Relational Database System(RDS) by Amazon.
The script I am providing below will help you to generate a quick inventory of Amazon DynamoDB database deployed in your account, and provide result in csv file format. I tried to include all properties you might need as part of any standard DynamoDB inventory. However, you may 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 working system. Refer to following documents if you have not set your system to run AWS CLI or having difficulties to set:
- https://docs.aws.amazon.com/powershell/latest/userguide/specifying-your-aws-credentials.html
- https://aws.amazon.com/powershell/
Leave a comment if you face any issue running the script. Hope this is helpful!
$date = Get-Date -UFormat "%m-%d-%Y"
$currentDir = $(Get-Location).Path
$oFile = "$($currentDir)\DynamoDB_Details_$($date).csv"
if(Test-Path $oFile){Remove-Item $oFile -Force}
"DB Table Name,Creation Time,Global SecondaryIndex,Item Count, Table Size Bytes,Table Status" | Out-File $oFile -Append -Encoding ascii
Get-DDBTableList | ForEach-Object {
$dbTableName = $createDate = $glbSecIndex = $count = $tblSizeBytes = $tblStatus = $tblARN = ""
$db = Get-DDBTable -TableName $_
$dbTableName = $db.TableName
$createDate = $db.CreationDateTime
foreach($i in $db.GlobalSecondaryIndexes){
$glbSecIndex += $i.IndexName +";"
}
$glbSecIndex = $glbSecIndex.trimEnd(";")
$count = $db.ItemCount
$tblSizeBytes = $db.TableSizeBytes
$tblStatus = $db.TableStatus
$tblARN = $db.TableArn
#Here we have associated Tags with the DynamoDB Tables. You may use it to further parse Tags.
$tags = Get-DDBResourceTag -ResourceArn $tblARN
"$dbTableName,$createDate,$glbSecIndex,$count,$tblSizeBytes, $tblStatus" | 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: