0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

CLIでAWSにS3バケットを作成・削除する

Last updated at Posted at 2025-01-11

CLIでAWSにS3バケットを作成したい時に初期設定から作成までを手順としてまとめたものです。

実行環境

macOS Sonoma 14.6.1

準備

  1. Homebrewのインストール

  2. awscliのインストールする

    brew install awscli
    
  3. AWS S3を作成するためのクレデンシャルを用意
    以下の6種類がありますが、1の短期クレデンシャルが公式には推奨されています

    1. IAM Identity Centerユーザーの短期クレデンシャル(推奨)
    2. IAMユーザーの短期クレデンシャル
    3. EC2インスタンス上のIAMもしくはIAM Identity Centerユーザー
    4. 権限のあるロールへの切り替え
    5. IAMユーザーの長期クレデンシャル(非推奨)
    6. 外部ストレージに保存したIAMもしくはIAM Identityユーザーのクレデンシャル(非推奨)

    今回は 1 の方法を使用しますので、事前にSSOログインしてください

S3バケットを作成

% aws s3 mb s3://sample.hapoon.com --region ap-northeast-1
make_bucket: sample.hapoon.com

作成先のリージョンがus-east-1以外、かつリージョンの指定がprofileもしくは環境変数にない場合は --region でリージョンを指定してください

S3バケットの確認

% aws s3 ls
2025-01-12 06:22:19 sample.hapoon.com

S3バケットの削除

% aws s3 rb s3://sample.hapoon.com --region ap-northeast-1
remove_bucket: sample.hapoon.com
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?