private String getDbInstanceResourceName ( ) { String userArn = this . identityManagement . getUser ( ) . getUser ( ) . getArn ( ) ; AmazonResourceName userResourceName = AmazonResourceName . fromString ( userArn ) ; AmazonResourceName dbResourceArn = new AmazonResourceName . Builder ( ) . withService ( "rds" ) . withRegion ( getRegion ( ) ) . withAccount ( userResourceName . getAccount ( ) ) . withResourceType ( "db" ) . withResourceName ( getDbInstanceIdentifier ( ) ) . withResourceTypeDelimiter ( ":" ) . build ( ) ; return dbResourceArn . toString ( ) ; }
Unfortunately Amazon AWS mandates to use ARN notation to get the tags . Therefore we first need to get the account number through the IAM service and then construct the ARN out of the account no and region