AWS CLI備忘録 S3バケット作成
前提
- AWS Cliがインストールされており、アプリケーションからコマンドが実行可能なこと
- 実行環境にAWSアカウントのアクセスキーが設定されてること
'aws configure' で設定する必要あり
- アクセスキーの取得元アカウントにS3の権限が付与されていること
S3バケット生成
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/using-s3-commands.html
任意のバケット名で S3バケットを生成する
aws s3 mb s3://bucket-name
S3 バケット存在チェック
aws s3 ls s3://bucket-name
※作成直後だと空なので戻り値無し。
バケットが無いと以下のエラーが返る
An error occurred (NoSuchBucket) when calling the ListObjects operation: The specified bucket does not exist
S3バケット ウェブホスティング設定
ウェブホスティングの設定はポリシーではなく以下のコマンド
aws s3 website s3://bucket-name --index-document index.html
S3バケット ポリシー設定
ウェブホスティングのポリシー適用
```
aws s3api put-bucket-policy --bucket bucket-name --policy file://policy.json
policy.json:
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadGetObject",
"Effect":"Allow",
"Principal": "",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::bucket-name/"]
}]
}
```
以後、CloudFrontのディストリビューション作成、Route53の登録までCLIで実行してみる。
Author And Source
この問題について(AWS CLI備忘録 S3バケット作成), 我々は、より多くの情報をここで見つけました https://qiita.com/chiku_chu/items/ba9f5fd84b3711c671b6著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .