What is the best way to check if table exists in DynamoDB

0 votes

What is the best way to check if table exists in DynamoDb?

I would appreciate it if the code would be in PHP.

Nov 30, 2018 in AWS by datageek
• 3,090 points
6,335 views

1 answer to this question.

0 votes

This function gives you a nice boolean to use in scripts.

use Aws\DynamoDb\Exception\ResourceNotFoundException; // <-- make sure this line is at the top

    public function TableExists($tableName) {

    $ddb = DynamoDbClient::factory(array('region' => 'us-east-1')); // EC2 role security

    try {
        $result = $ddb->describeTable(array(
            "TableName" => $tableName
        ));
    } catch (ResourceNotFoundException $e) {
        // if this exception is thrown, the table doesn't exist
        return false;
    }

    // no exception thrown? table exists!
    return true;
}

Hopefully this complete working code helps some of you.

answered Nov 30, 2018 by Archana
• 5,640 points

Related Questions In AWS

0 votes
1 answer

What happens to data if the data center goes down in AWS?

When it comes to the security and ...READ MORE

answered Jul 13, 2018 in AWS by Priyaj
• 58,090 points

edited Jul 13, 2018 by Priyaj 2,173 views
0 votes
1 answer

I'm trying to integrate Bitbucket into AWS Code Pipeline? What is the best approach?

You can integrate Bitbucket with AWS CodePipeline ...READ MORE

answered Aug 17, 2018 in AWS by Priyaj
• 58,090 points
2,129 views
0 votes
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,503 views
+2 votes
1 answer
0 votes
1 answer

Is there a limit on the number of attributes in DynamoDB Table?

Actually, there is no limit to the ...READ MORE

answered Feb 21, 2019 in AWS by Archana
• 5,640 points
4,043 views
0 votes
1 answer

What is the maximum storage capacity of a node in Redshift?

You can create a cluster using either ...READ MORE

answered Oct 26, 2018 in AWS by Archana
• 5,640 points
1,707 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP