1
1
#! /bin/bash
2
2
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- # SPDX-License-Identifier: Apache-2.0
3
+ # SPDX-License-Identifier: Apache-2.0
4
4
5
5
# ##############################################################################
6
6
#
@@ -24,36 +24,33 @@ source ./awsdocs_general.sh
24
24
# -n table_name -- The name of the table to create.
25
25
# -a attribute_definitions -- JSON file path of a list of attributes and their types.
26
26
# -k key_schema -- JSON file path of a list of attributes and their key types.
27
- # -p provisioned_throughput -- Provisioned throughput settings for the table.
28
27
#
29
28
# Returns:
30
29
# 0 - If successful.
31
30
# 1 - If it fails.
32
31
# ##############################################################################
33
32
function dynamodb_create_table() {
34
- local table_name attribute_definitions key_schema provisioned_throughput response
33
+ local table_name attribute_definitions key_schema response
35
34
local option OPTARG # Required to use getopts command in a function.
36
35
37
36
# ######################################
38
37
# Function usage explanation
39
38
# ######################################
40
39
function usage() {
41
40
echo " function dynamodb_create_table"
42
- echo " Creates an Amazon DynamoDB table."
41
+ echo " Creates an Amazon DynamoDB table with on-demand billing ."
43
42
echo " -n table_name -- The name of the table to create."
44
43
echo " -a attribute_definitions -- JSON file path of a list of attributes and their types."
45
44
echo " -k key_schema -- JSON file path of a list of attributes and their key types."
46
- echo " -p provisioned_throughput -- Provisioned throughput settings for the table."
47
45
echo " "
48
46
}
49
47
50
48
# Retrieve the calling parameters.
51
- while getopts " n:a:k:p: h" option; do
49
+ while getopts " n:a:k:h" option; do
52
50
case " ${option} " in
53
51
n) table_name=" ${OPTARG} " ;;
54
52
a) attribute_definitions=" ${OPTARG} " ;;
55
53
k) key_schema=" ${OPTARG} " ;;
56
- p) provisioned_throughput=" ${OPTARG} " ;;
57
54
h)
58
55
usage
59
56
return 0
@@ -85,24 +82,17 @@ function dynamodb_create_table() {
85
82
return 1
86
83
fi
87
84
88
- if [[ -z " $provisioned_throughput " ]]; then
89
- errecho " ERROR: You must provide a provisioned throughput json file path the -p parameter."
90
- usage
91
- return 1
92
- fi
93
-
94
85
iecho " Parameters:\n"
95
86
iecho " table_name: $table_name "
96
87
iecho " attribute_definitions: $attribute_definitions "
97
88
iecho " key_schema: $key_schema "
98
- iecho " provisioned_throughput: $provisioned_throughput "
99
89
iecho " "
100
90
101
91
response=$( aws dynamodb create-table \
102
92
--table-name " $table_name " \
103
93
--attribute-definitions file://" $attribute_definitions " \
104
- --key-schema file:// " $key_schema " \
105
- --provisioned-throughput " $provisioned_throughput " )
94
+ --billing-mode PAY_PER_REQUEST \
95
+ --key-schema file:// " $key_schema " )
106
96
107
97
local error_code=${?}
108
98
0 commit comments