0

I have a DynamoDB JSON file that looks like this:

{
    "AttributeDefinitions": [
        {
            "AttributeName": "pk",
            "AttributeType": "S"
        },
        {
            "AttributeName": "sk",
            "AttributeType": "S"
        }
    ],
    "TableName": "MYTABLE",
    "KeySchema": [
        {
            "AttributeName": "pk",
            "KeyType": "HASH"
        },
        {
            "AttributeName": "sk",
            "KeyType": "RANGE"
        }
    ],
    "GlobalSecondaryIndexes": [
        {
            "IndexName": "GSIReverseIndex",
            "KeySchema": [
                {
                    "AttributeName": "pk",
                    "KeyType": "RANGE"
                },
                {
                    "AttributeName": "sk",
                    "KeyType": "RANGE"
                }
            ],
            "Projection": {
                "ProjectionType": "ALL",
                "NonKeyAttributes": [
                    ""
                ]
            },
            "ProvisionedThroughput": {
                "ReadCapacityUnits": 1,
                "WriteCapacityUnits": 1
            }
        }
    ],
    "BillingMode": "PROVISIONED",
    "ProvisionedThroughput": {
        "ReadCapacityUnits": 1,
        "WriteCapacityUnits": 1
    },
    "StreamSpecification": {
        "StreamEnabled": true,
        "StreamViewType": "NEW_AND_OLD_IMAGES"
    },
    "TableClass": "STANDARD"
}

I am trying to create the corresponding DynamoDB table in Localstack by running the following command:

aws dynamodb create-table --endpoint-url http://localhost:4566 --region us-east-1 --cli-input-file file:///MY_TABLE.json

However, when I run this command I get an error saying:

aws: error: the following arguments are required: --attribute-definitions, --table-name, --key-schema

All of those items are present in the JSON file. Why doesn't the cli like the command?

1 Answer 1

1

It seems that the option --cli-input-file is not supported.

You should use --cli-input-json or --cli-input-yaml instead:

aws dynamodb create-table \
 --endpoint-url http://localhost:4566 \
 --region us-east-1 \
 --cli-input-json file://MY_TABLE.json

Note that:

  • I removed a leading slash in the input file path
  • Your table schema is still incorrect, you have to define a non-empty list of NonKeyAttributes for GSI projection
Sign up to request clarification or add additional context in comments.

1 Comment

That did it. Looks like the site I was copying this command from was incorrect. Great catch!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.