[英]How do I get the full name of an S3 bucket which contains a given string using AWS CLI?
Terraform deploys an S3 bucket using a name prefix. Terraform 使用名称前缀部署 S3 存储桶。
How do I get the full name of an S3 bucket by providing name prefix to the AWS CLI command?如何通过向 AWS CLI 命令提供名称前缀来获取 S3 存储桶的全名?
aws s3api list-buckets --query 'Buckets[*].[Name]' --output text | grep "admin-passwords"
Using the above AWS CLI command and providing the name prefix/string/identifier to the grep command we can achieve the desired output.使用上述 AWS CLI 命令并向 grep 命令提供名称前缀/字符串/标识符,我们可以实现所需的 output。
Output: Output:
admin-passwords202104262231251212001
You can use a combination of AWS command to list all the buckets and grep your string/identifier from the output of that command.您可以使用 AWS 命令的组合列出所有存储桶和 grep 来自该命令的 output 的字符串/标识符。 Since all the buckets names are unique, it should work easily.
由于所有存储桶名称都是唯一的,因此它应该很容易工作。 For example -
例如 -
aws s3 ls | grep "my-bucket-identifier"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.