Repository: getmoto/moto

Issue:
mock_dynamodb2 Table.global_secondary_indexes lacks some properties
Hello,

I've used Pip3.7 to install the following versions:
Python3.7
moto==1.3.14
coverage==5.0.3
pycobertura==0.10.5
pytest==5.4.1
pytest-mock==2.0.0
boto3==1.12.21

Problem:
`DynamoDB.Table.global_secondary_indexes` list is lacking some properties as described in boto3 [documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Table.global_secondary_indexes).

Moto is used as Python mocks.

How to reproduce:
```python
def create_table(table_name):
    dynamodb = boto3.resource('dynamodb', 'us-west-2')
    create_response = dynamodb.create_table(
        TableName=table_name,
        KeySchema=[
            {
                'AttributeName': 'KEY_1',
                'KeyType': 'HASH'
            },
            {
                'AttributeName': 'KEY_2',
                'KeyType': 'RANGE'
            },
        ],
        AttributeDefinitions=[
            {
                'AttributeName': 'KEY_1',
                'AttributeType': 'S'
            },
            {
                'AttributeName': 'KEY_2',
                'AttributeType': 'S'
            },
            {
                'AttributeName': 'KEY_3',
                'AttributeType': 'S'
            }
        ],
        GlobalSecondaryIndexes=[
            {
                'IndexName': f'{KEY_3}-index',
                'KeySchema': [
                    {
                        'AttributeName': 'KEY_3',
                        'KeyType': 'HASH'
                    },
                    {
                        'AttributeName': 'KEY_2',
                        'KeyType': 'RANGE'
                    },
                ],
                'Projection': {
                    'ProjectionType': 'ALL'
                }
            }
        ]
    )

@mock_dynamodb2
def test method(mocker):
    mocker.patch.dict(os.environ, {
        'AWS_REGION': 'us-west-2',
        'TABLE_NAME': 'COOL_TABLE'
    })

    table_name = os.getenv('TABLE_NAME')
    create_table(table_name)
    load_mock_data(act_id, table_name)
    dynamodb = boto3.resource('dynamodb', 'us-west-2')
    table = dynamodb.Table(table_name)

    # Following line will throw KeyError
    assert table.global_secondary_indexes[0].get('IndexStatus') != None
```

Expected:
Expected missing attributes to exist.
Also welcome different way to test that the index is ready.
**UPDATE** : ATM, as I'm using `pytest`, I've added a check for `os.getenv('PYTEST_CURRENT_TEST') is None` on my index-readiness related code.

Sanitized StackTrace:
```python
>           if not table.global_secondary_indexes or table.global_secondary_indexes[0]['IndexStatus'] != 'ACTIVE':
E           KeyError: 'IndexStatus'
```

Thank you,
Yarden


Discussion:

Resolving patch:
diff --git a/moto/dynamodb2/models.py b/moto/dynamodb2/models.py
--- a/moto/dynamodb2/models.py
+++ b/moto/dynamodb2/models.py
@@ -679,6 +679,10 @@ def __init__(
         self.throughput["NumberOfDecreasesToday"] = 0
         self.indexes = indexes
         self.global_indexes = global_indexes if global_indexes else []
+        for index in self.global_indexes:
+            index[
+                "IndexStatus"
+            ] = "ACTIVE"  # One of 'CREATING'|'UPDATING'|'DELETING'|'ACTIVE'
         self.created_at = datetime.datetime.utcnow()
         self.items = defaultdict(dict)
         self.table_arn = self._generate_arn(table_name)


Test patch:
diff --git a/tests/test_dynamodb2/test_dynamodb_table_with_range_key.py b/tests/test_dynamodb2/test_dynamodb_table_with_range_key.py
--- a/tests/test_dynamodb2/test_dynamodb_table_with_range_key.py
+++ b/tests/test_dynamodb2/test_dynamodb_table_with_range_key.py
@@ -574,6 +574,7 @@ def test_create_with_global_indexes():
                     "ReadCapacityUnits": 6,
                     "WriteCapacityUnits": 1,
                 },
+                "IndexStatus": "ACTIVE",
             }
         ]
     )