Search code examples
amazon-web-servicesdockeramazon-s3docker-composeaws-cli

How run `aws s3 sync` during docker compose?


Here is snippet for aws s3 sync command:

version: '3.8'
services:
  amazon-aws-cli-download-test-data:  
    image: amazon/aws-cli:2.13.0 # <- newest version for today
    command:
#       | `aws` main command was also tried and error was the same
#      \/ 
#     - aws s3 sync s3://mybucket/myfolder/ /s3/mybucket/myfolder/ --delete
      - s3 sync s3://mybucket/myfolder/ /s3/mybucket/myfolder/ --delete
    environment:
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
      - AWS_REGION
    volumes:
      - './test-data/s3:/s3'

The error:

aws: error: argument command: Invalid choice, valid choices are:

The s3 command is the oldest that definitely present in all aws cli's. What is wrong? How execute some s3 syncing during containmer start up?


Solution

  • Changes to

    command: s3 sync s3://mybucket/myfolder/ /s3/mybucket/myfolder/ --delete
    

    fixed the issue