AWS S3 Pre-signed URL via CLI

匿名 (未验证) 提交于 2019-12-03 08:54:24

问题:

Is there a way to create pre-signed url for objects in S3 bucket using AWS CLI?

I know that could be done using SDK, but is it possible with CLI?

I found this on one of the AWS docs, but can't complete the command:

s3cmd signurl s3://BUCKET/OBJECT <expiry_epoch|+expiry_offset> 

Any help?

回答1:

Did you try aws s3 presign?

Generate a pre-signed URL for an Amazon S3 object. This allows anyone who receives the pre-signed URL to retrieve the S3 object with an HTTP GET request. For sigv4 requests the region needs to be configured explicitly.

This will generate a URL that will expire in 3600 seconds (default)

aws s3 presign s3://mybucket/myobject 

This will generate a URL that will expire in 300 seconds

aws s3 presign s3://mybucket/myobject  --expires-in 300 

Output

https://mybucket.s3.amazonaws.com/myobject?AWSAccessKeyId=AKIAJXXXXXXXXXXXXXXX&Expires=1503602631&Signature=ibOGfAovnhIF13DALdAgsdtg2s%3D 


回答2:

So the command for pre-signed URL is:

aws s3 presign s3://bucket-address/  --expires-in 300 

But the caveat is; we can have pre-signed URL's that works for individual file/object level and not on directory level.

Happy to be corrected if wrong.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!