S3 を使ったファイルの読み書き 

 

まずBucketと呼ばれるデータの格納領域を、次のコマンドで作成する。

「$ bucketName="mybucket-$(openssl rand -hex 12)" 」

「$ echo $bucketName 」

「$ aws s3 mb "s3://${bucketName}"」

 

次に作成したバケットを確認するためには

「$ aws s3 ls」

を実行する。これでバケットの一覧を確認することができる。

 

そのバケットにファイルをアップロードするには

「$ echo "Hello world!" > hello_world.txt 」

「$ aws s3 cp hello_world.txt "s3://${bucketName}/hello_world.txt"」

を実行する。

 

使い終わったバケットを削除するには、

「$ aws s3 rb "s3://${bucketName}" --force」

を実行することで出来る。