0

I am trying to create aws tables and I have saved the command within a string. Now I get an error aws: error: argument --key-schema is required because it sees --key-schema as part of the table attribute. How do I handle this?

Bash Script

table_name="test"

table_attributes="--attribute-definitions 
AttributeName=Artist,AttributeType=S 
AttributeName=SongTitle,AttributeType=S --key-schema 
AttributeName=Artist,KeyType=HASH 
AttributeName=SongTitle,KeyType=RANGE --provisioned-throughput 
ReadCapacityUnits=5,WriteCapacityUnits=5"

e.g

aws dynamodb create-table --table-name $table_name $table_attributes
neau
  • 48
  • 8
Hopez
  • 141
  • 1
  • 9
  • aws=amazon web services? If so, then use the tag amazon-web-services. – myradio May 08 '19 at 15:54
  • For debugging, try `printf '%s\n' $table_attributes`, which will print each argument on a separate line, and see if it's what you expect. For example maybe the `AttributeName`s are supposed to be in one argument. I can't suggest anything else cause I don't have `aws` installed. Maybe you could reproduce the problem with a more common program? C.f. [mcve] – wjandrea May 08 '19 at 15:55
  • 2
    Don't use strings to store shell commands, period. See [BashFAQ #50](http://mywiki.wooledge.org/BashFAQ/050). – Charles Duffy May 08 '19 at 15:56
  • More duplicates: [How to execute a bash command stored as a string with quotes and asterisk](https://stackoverflow.com/q/2005192/4518341) - see [this answer](https://stackoverflow.com/a/32280085/4518341), and [How to store a command in a variable in a shell script?](https://stackoverflow.com/q/5615717/4518341) - see [this answer](https://stackoverflow.com/a/44055875/4518341) – wjandrea May 08 '19 at 16:29

0 Answers0