Created
January 24, 2019 17:14
-
-
Save af-inet/08c4778ba866a2cc008ccd41b8d7181a to your computer and use it in GitHub Desktop.
Create a credstash table with the appropriate attributes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import argparse | |
| import boto3 | |
| def parse_args(): | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('name', action='store', type=str, help='name of the credstash table you would like to create') | |
| args = parser.parse_args() | |
| return args | |
| def main(): | |
| args = parse_args() | |
| client = boto3.client('dynamodb') | |
| response = client.create_table( | |
| TableName=args.name, | |
| AttributeDefinitions=[ | |
| { | |
| 'AttributeName': 'name', | |
| 'AttributeType': 'S' | |
| }, | |
| { | |
| 'AttributeName': 'version', | |
| 'AttributeType': 'S' | |
| } | |
| ], | |
| KeySchema=[ | |
| { | |
| 'AttributeName': 'name', | |
| 'KeyType': 'HASH' | |
| }, | |
| { | |
| 'AttributeName': 'version', | |
| 'KeyType': 'RANGE' | |
| } | |
| ], | |
| ProvisionedThroughput={ | |
| 'ReadCapacityUnits': 1, | |
| 'WriteCapacityUnits': 1 | |
| }, | |
| ) | |
| print(json.dumps(response, indent=2, default=lambda x: str(x))) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment