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

后端 未结 6 2094
粉色の甜心
粉色の甜心 2021-02-19 22:28

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

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

Either active or not.

* Added late

6条回答
  •  你的背包
    2021-02-19 22:41

    With dynamodb cli you can do it very simple as follows:

    aws dynamodb describe-table --table-name "my-table"
    

    If the table exists it returns

    0 -- Command was successful. There were no errors thrown by either the CLI or by the service the request was made to.
    

    If the table does not exist it returns

    255 -- Command failed. There were errors thrown by either the CLI or by the service the request was made to.
    

    See also:

    • http://docs.aws.amazon.com/cli/latest/reference/dynamodb/describe-table.html
    • http://docs.aws.amazon.com/cli/latest/topic/return-codes.html

提交回复
热议问题