Skip to content

Instantly share code, notes, and snippets.

@af-inet
Created January 24, 2019 17:14
Show Gist options
  • Select an option

  • Save af-inet/08c4778ba866a2cc008ccd41b8d7181a to your computer and use it in GitHub Desktop.

Select an option

Save af-inet/08c4778ba866a2cc008ccd41b8d7181a to your computer and use it in GitHub Desktop.
Create a credstash table with the appropriate attributes.
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