简体   繁体   English

如何使用 AWS CLI 获取包含给定字符串的 S3 存储桶的全名?

[英]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.

相关问题 如何使用 AWS CLI 将名称每天更改的文件移动到 AWS S3 存储桶? - How do I move files whose name changes daily to AWS S3 bucket using AWS CLI? 如何使用 AWS CLI 找到我的 AWS S3 存储桶的确切字节数? - How do I find the exact number of bytes of my AWS S3 bucket using AWS CLI? 如何使用 CLI 删除 AWS S3 中的版本化存储桶? - How do I delete a versioned bucket in AWS S3 using the CLI? 如何使用 AWS CLI 仅复制 S3 存储桶中与给定字符串模式匹配的文件 - How to use AWS CLI to only copy files in S3 bucket that match a given string pattern 如何使用 AWS CLI 将匹配名称模式的多个文件复制到 AWS S3 存储桶? - How to copy multiple files matching name pattern to AWS S3 bucket using AWS CLI? 有没有办法使用 aws s3 ls cli 将 S3 存储桶名称添加到存储桶的递归列表中? - Is there a way to add the S3 bucket name to the recursive list of a bucket using aws s3 ls cli? 使用 aws cli 获取 S3 Bucket 的 ARN - Get ARN of S3 Bucket with aws cli 获取AWS S3存储桶的CLI配置 - Get the CLI Config for an AWS S3 Bucket 使用 aws cli 将 S3 object url 上传到存储桶后,如何获取它? - How to get S3 object url after it's been uploaded to a bucket using aws cli? 如何使用 aws cli 为 s3 存储桶指定默认加密? - How to specify default encryption for s3 bucket using aws cli?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM