|
Size: 100
Comment:
|
Size: 1455
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 4: | Line 4: |
| * [[https://docs.getmoto.org/en/latest/| get moto]] * [[https://docs.getmoto.org/en/latest/docs/getting_started.html|getting started with moto]] == Install AWS CLI == {{{#!highlight shell # Install aws cli cd ~/Downloads curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install aws --version }}} == Create S3 bucket == {{{#!highlight shell export AWS_ACCESS_KEY_ID='testing' export AWS_SECRET_ACCESS_KEY='testing' export AWS_SECURITY_TOKEN='testing' export AWS_SESSION_TOKEN='testing' export AWS_DEFAULT_REGION='us-east-1' export AWS_ENDPOINT_URL="http://localhost:4000" docker run --rm -p 4000:4000 --name moto motoserver/moto:latest }}} compose.yaml {{{#!highlight yaml services: motoserver: image: motoserver/moto:latest ports: - "4000:4000" environment: - MOTO_PORT=4000 # set moto listener port with env var }}} {{{#!highlight shell docker compose up docker compose exec motoserver sh aws s3 ls aws s3api create-bucket --bucket my-bucket # https://docs.aws.amazon.com/cli/latest/reference/s3api/ echo "test" > test.txt aws s3api put-object --bucket my-bucket --key dir-1/test.txt --body test.txt aws s3api get-object --bucket my-bucket --key dir-1/test.txt test2.txt cat test2.txt aws s3 ls }}} |
moto
A python library that allows you to easily mock out tests based on AWS infrastructure.
Install AWS CLI
Create S3 bucket
1 export AWS_ACCESS_KEY_ID='testing'
2 export AWS_SECRET_ACCESS_KEY='testing'
3 export AWS_SECURITY_TOKEN='testing'
4 export AWS_SESSION_TOKEN='testing'
5 export AWS_DEFAULT_REGION='us-east-1'
6 export AWS_ENDPOINT_URL="http://localhost:4000"
7
8 docker run --rm -p 4000:4000 --name moto motoserver/moto:latest
compose.yaml
1 docker compose up
2 docker compose exec motoserver sh
3
4 aws s3 ls
5 aws s3api create-bucket --bucket my-bucket
6 # https://docs.aws.amazon.com/cli/latest/reference/s3api/
7 echo "test" > test.txt
8 aws s3api put-object --bucket my-bucket --key dir-1/test.txt --body test.txt
9 aws s3api get-object --bucket my-bucket --key dir-1/test.txt test2.txt
10 cat test2.txt
11 aws s3 ls
