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

AWS DynamoDB complete inventory using Powershell

Posted on August 21, 2019February 27, 2022

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.

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

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

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
July 2025
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  
« 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