In Amazon S3 am I charged whenever I perform a get_key or when I actually get its contents?

wuxiekeji

i.e. will this code cause it to appear as 2 GET requests in my bill, or only 1?

key = bucket.get_key('some_invalid_key')
key = bucket.get_key('some_valid_key')
string = key.get_contents_to_string()
Jan Vlcinsky

By default, get_key validate existence of the key on the bucket by HEAD request (which is rather small one, but the request counts to number of requests you do).

If you do not want to make this validation, set validate=False and boto will not make the request.

Docstring for get_key:

Type:        instancemethod
String form: <bound method Bucket.get_key of <Bucket: tmpdistributionplatform>>
File:        /home/javl/Envs/so/local/lib/python2.7/site-packages/boto/s3/bucket.py
Definition:  bucket.get_key(self, key_name, headers=None, version_id=None, response_headers=None, validate=True)
Docstring:
Check to see if a particular key exists within the bucket.  This
method uses a HEAD request to check for the existance of the key.
Returns: An instance of a Key object or None

:param key_name: The name of the key to retrieve
:type key_name: string

:param headers: The headers to send when retrieving the key
:type headers: dict

:param version_id:
:type version_id: string

:param response_headers: A dictionary containing HTTP
    headers/values that will override any headers associated
    with the stored object in the response.  See
    http://goo.gl/EWOPb for details.
:type response_headers: dict

:param validate: Verifies whether the key exists. If ``False``, this
    will not hit the service, constructing an in-memory object.
    Default is ``True``.
:type validate: bool

:rtype: :class:`boto.s3.key.Key`
:returns: A Key object from this bucket.

Conclusions

  • By default get_key generates one HEAD requests and you are charged for it.
  • You are allowed to prevent this request by setting validate=False
  • Amount of data transferred is anyway very small as HEAD only checks basic metadata and does not attempt to download all the content.
  • HEAD request falls into category GET and all others and cost $0.004 per 10,000 requests (as of now for US Standard zone), so generally it is negligible unless you do a lot of these requests.
  • to your question: your code will generate 2 HEAD and one GET requests and all three will be counted.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

What actually happens when I perform a downcast?

From Dev

Peformance of Amazon EC2, what do I actually get?

From Dev

I am using jupyter notebook, ipython 3 on windows. Whenever i am starting my python 3, i get the "Kernel Dead" message

From Dev

How do I get Amazon s3 private uploads/downloads working in my django views when they work in the admin?

From Dev

How can I get notification when my laptop battery gets fully charged?

From Dev

I get no animation when I perform the segue programmatically

From Dev

InDesign: How can I get paragraph contents with its characterStyles?

From Dev

In Azure do i get charged for both a virtual machine and cloud services?

From Dev

How can i solved eslint warning -- 'component' is declared but its value is never read -- when i am actually using the component

From Dev

When using RestSharp, I am getting MethodNotFound on a POST but the response thinks its a GET?

From Dev

When using RestSharp, I am getting MethodNotFound on a POST but the response thinks its a GET?

From Dev

Whenever I am trying to get username from Firebase it returns value but is not updated in String

From Dev

When do functions actually get called? How do I control it?

From Dev

In Amazon S3, what permissions do I need to get HEAD on an object?

From Dev

How can I get query strings in my Amazon S3 static website?

From Dev

How do I get the last modified date of a directory in Amazon S3?

From Dev

In Amazon S3, what permissions do I need to get HEAD on an object?

From Dev

How could I get file size, time and md5 from amazon s3?

From Dev

Am I charged for bandwidth between an AppEngine app and Compute Engine instance?

From Dev

Why am I getting an error when I try to print the contents of a file I am searching for?

From Dev

PHP: Whenever I use if !isset I get this error: "undefined index"

From Dev

I get an error whenever I try to add myself to sudoers

From Dev

I get an error whenever I try to connect database

From Dev

Amazon S3 bucket policy, what am I doing wrong?

From Dev

I get errors when trying to perform a second query

From Dev

When i trying to copy folder from amazon ec2 to s3 .I got an error

From Dev

I am trying to create a socket in python 3 but i get this error, even when i copy code stragte from the web

From Dev

I am trying to make a GUI for a app I am working on but when I try print a global variable I get an error. Why?

From Dev

Get teams I am member of

Related Related

  1. 1

    What actually happens when I perform a downcast?

  2. 2

    Peformance of Amazon EC2, what do I actually get?

  3. 3

    I am using jupyter notebook, ipython 3 on windows. Whenever i am starting my python 3, i get the "Kernel Dead" message

  4. 4

    How do I get Amazon s3 private uploads/downloads working in my django views when they work in the admin?

  5. 5

    How can I get notification when my laptop battery gets fully charged?

  6. 6

    I get no animation when I perform the segue programmatically

  7. 7

    InDesign: How can I get paragraph contents with its characterStyles?

  8. 8

    In Azure do i get charged for both a virtual machine and cloud services?

  9. 9

    How can i solved eslint warning -- 'component' is declared but its value is never read -- when i am actually using the component

  10. 10

    When using RestSharp, I am getting MethodNotFound on a POST but the response thinks its a GET?

  11. 11

    When using RestSharp, I am getting MethodNotFound on a POST but the response thinks its a GET?

  12. 12

    Whenever I am trying to get username from Firebase it returns value but is not updated in String

  13. 13

    When do functions actually get called? How do I control it?

  14. 14

    In Amazon S3, what permissions do I need to get HEAD on an object?

  15. 15

    How can I get query strings in my Amazon S3 static website?

  16. 16

    How do I get the last modified date of a directory in Amazon S3?

  17. 17

    In Amazon S3, what permissions do I need to get HEAD on an object?

  18. 18

    How could I get file size, time and md5 from amazon s3?

  19. 19

    Am I charged for bandwidth between an AppEngine app and Compute Engine instance?

  20. 20

    Why am I getting an error when I try to print the contents of a file I am searching for?

  21. 21

    PHP: Whenever I use if !isset I get this error: "undefined index"

  22. 22

    I get an error whenever I try to add myself to sudoers

  23. 23

    I get an error whenever I try to connect database

  24. 24

    Amazon S3 bucket policy, what am I doing wrong?

  25. 25

    I get errors when trying to perform a second query

  26. 26

    When i trying to copy folder from amazon ec2 to s3 .I got an error

  27. 27

    I am trying to create a socket in python 3 but i get this error, even when i copy code stragte from the web

  28. 28

    I am trying to make a GUI for a app I am working on but when I try print a global variable I get an error. Why?

  29. 29

    Get teams I am member of

HotTag

Archive