ModifyConditionally.sh 666 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. TABLE_NAME='elaborate_employee_table'
  3. # aws \
  4. # dynamodb \
  5. # put-item \
  6. # --table-name ${TABLE_NAME} \
  7. # --item file://modify_conditionally_item_overwrite.json \
  8. # --condition-expression "attribute_not_exists(id)" \
  9. # --return-values ALL_OLD | jq .
  10. aws \
  11. dynamodb \
  12. update-item \
  13. --table-name ${TABLE_NAME} \
  14. --key '{"id":{"N":"10"}}' \
  15. --expression-attribute-values file://modify_conditionally_values.json \
  16. --expression-attribute-names file://modify_conditionally_names.json \
  17. --update-expression "SET #ec = :ecn" \
  18. --condition-expression "attribute_not_exists(#ec) and attribute_exists(#ad.#st) and #ct = :ctv" \
  19. --return-values UPDATED_NEW | jq .