簡體   English   中英

如何使用 AWS CLI 獲取包含給定字符串的 S3 存儲桶的全名?

[英]How do I get the full name of an S3 bucket which contains a given string using AWS CLI?

Terraform 使用名稱前綴部署 S3 存儲桶。

如何通過向 AWS CLI 命令提供名稱前綴來獲取 S3 存儲桶的全名?

aws s3api list-buckets --query 'Buckets[*].[Name]' --output text | grep "admin-passwords"

使用上述 AWS CLI 命令並向 grep 命令提供名稱前綴/字符串/標識符,我們可以實現所需的 output。

Output:

admin-passwords202104262231251212001

您可以使用 AWS 命令的組合列出所有存儲桶和 grep 來自該命令的 output 的字符串/標識符。 由於所有存儲桶名稱都是唯一的,因此它應該很容易工作。 例如 -

aws s3 ls | grep "my-bucket-identifier"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM