2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS CLIでS3オブジェクトにタグを付与する

Last updated at Posted at 2019-02-17

S3オブジェクト配置のタイミングでタグを付与する

$ aws s3api put-object \
    --bucket hoge-bucket \
    --key fuga-object.txt \
    --body fuga-object.txt \
    --tagging "key=value"

--taggingオプションは複数与えても最後に指定したオプションしか効かない。

S3オブジェクト単位でタグを確認する

$ aws s3api get-object-tagging \
    --bucket hoge-bucket \
    --key fuga-object.txt

jsonで返ってくるのが嫌な場合は--output textを指定するとよい。

既存のS3オブジェクトにタグを付与する

$ aws s3api put-object-tagging \
    --bucket hoge-bucket \
    --key fuga-object.txt \
    --tagging 'TagSet=[{Key=keyA,Value=valueA},{Key=keyB,Value=valueB}]'

タグ複数を一括で設定できる。

S3オブジェクトからタグを削除する

$ aws s3api delete-object-tagging \
    --bucket hoge-bucket \
    --key fuga-object.txt
2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?