Skip to content

Commit e82b84d

Browse files
S3 bucket names rename project (#4291)
* S3 bucket name change project Our doc standard now requires the use of specific, reserved, bucket names throughout documentation and code examples. This commit replaces every bucket name I could find with one of those reserved names. --------- Co-authored-by: Nate Prewitt <[email protected]>
1 parent 9ba416f commit e82b84d

18 files changed

+100
-98
lines changed

docs/source/guide/clients.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ from its list of possible waiters::
105105
Then to actually start waiting, you must call the waiter's ``wait()`` method
106106
with the method's appropriate parameters passed in::
107107

108-
# Begin waiting for the S3 bucket, mybucket, to exist
109-
s3_bucket_exists_waiter.wait(Bucket='mybucket')
108+
# Begin waiting for the S3 bucket, amzn-s3-demo-bucket, to exist
109+
s3_bucket_exists_waiter.wait(Bucket='amzn-s3-demo-bucket')
110110

111111
Multithreading or multiprocessing with clients
112112
----------------------------------------------

docs/source/guide/collections.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ the following conditions:
3434

3535
* **Batch actions (see below)**::
3636

37-
s3.Bucket('my-bucket').objects.delete()
37+
s3.Bucket('amzn-s3-demo-bucket').objects.delete()
3838

3939
Filtering
4040
---------
@@ -124,11 +124,11 @@ Some collections support batch actions, which are actions that operate
124124
on an entire page of results at a time. They will automatically handle
125125
pagination::
126126

127-
# S3 delete everything in `my-bucket`
127+
# S3 delete everything in `amzn-s3-demo-bucket`
128128
s3 = boto3.resource('s3')
129-
s3.Bucket('my-bucket').objects.delete()
129+
s3.Bucket('amzn-s3-demo-bucket').objects.delete()
130130

131131
.. danger::
132132

133-
The above example will **completely erase all data** in the ``my-bucket``
134-
bucket! Please be careful with batch actions.
133+
The above example will **completely erase all data** in the
134+
``amzn-s3-demo-bucket`` bucket! Please be careful with batch actions.

docs/source/guide/error-handling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ Using Amazon S3 as an example resource service, you can use the client’s excep
231231
client = boto3.resource('s3')
232232
233233
try:
234-
client.create_bucket(BucketName='myTestBucket')
234+
client.create_bucket(BucketName='amzn-s3-demo-bucket')
235235
236236
except client.meta.client.exceptions.BucketAlreadyExists as err:
237237
print("Bucket {} already exists!".format(err.response['Error']['BucketName']))

docs/source/guide/events.rst

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ Boto3's event system.
1414
An introduction to the event system
1515
-----------------------------------
1616

17-
Boto3's event system allows users to register a function to
18-
a specific event. Then once the running program reaches a line that
19-
emits that specific event, Boto3 will call every function
20-
registered to the event in the order in which they were registered.
21-
When Boto3 calls each of these registered functions,
22-
it will call each of them with a specific set of
23-
keyword arguments that are associated with that event.
24-
Then once the registered function
25-
is called, the function may modify the keyword arguments passed to that
26-
function or return a value.
27-
Here is an example of how the event system works::
17+
Boto3's event system allows users to register a function to a specific event.
18+
Then once the running program reaches a line that emits that specific event,
19+
Boto3 will call every function registered to the event in the order in which
20+
they were registered.
21+
22+
When Boto3 calls each of these registered functions, it will call each of them
23+
with a specific set of keyword arguments that are associated with that event.
24+
Then once the registered function is called, the function may modify the
25+
keyword arguments passed to that function or return a value. Here is an
26+
example of how the event system works::
2827

2928
import boto3
3029

@@ -37,19 +36,19 @@ Here is an example of how the event system works::
3736
def add_my_bucket(params, **kwargs):
3837
# Add the name of the bucket you want to default to.
3938
if 'Bucket' not in params:
40-
params['Bucket'] = 'mybucket'
39+
params['Bucket'] = 'amzn-s3-demo-bucket'
4140

4241
# Register the function to an event
4342
event_system.register('provide-client-params.s3.ListObjectsV2', add_my_bucket)
4443

4544
response = s3.list_objects_v2()
4645

47-
In this example, the handler ``add_my_bucket``
48-
is registered such that the handler will inject the
49-
value ``'mybucket'`` for the ``Bucket`` parameter whenever the
50-
``list_objects_v2`` client call is made without the ``Bucket`` parameter. Note
51-
that if the same ``list_objects_v2`` call is made without the ``Bucket``
52-
parameter and the registered handler, it will result in a validation error.
46+
In this example, the handler ``add_my_bucket`` is registered such that the
47+
handler will inject the value ``'amzn-s3-demo-bucket'`` for the ``Bucket``
48+
parameter whenever the ``list_objects_v2`` client call is made without the
49+
``Bucket`` parameter. Note that if the same ``list_objects_v2`` call is made
50+
without the ``Bucket`` parameter and the registered handler, it will result in
51+
a validation error.
5352

5453
Here are the takeaways from this example:
5554

@@ -103,11 +102,11 @@ its hierarchical structure::
103102

104103
def add_my_general_bucket(params, **kwargs):
105104
if 'Bucket' not in params:
106-
params['Bucket'] = 'mybucket'
105+
params['Bucket'] = 'amzn-s3-demo-bucket1'
107106

108107
def add_my_specific_bucket(params, **kwargs):
109108
if 'Bucket' not in params:
110-
params['Bucket'] = 'myspecificbucket'
109+
params['Bucket'] = 'amzn-s3-demo-bucket2'
111110

112111
event_system.register('provide-client-params.s3', add_my_general_bucket)
113112
event_system.register('provide-client-params.s3.ListObjectsV2', add_my_specific_bucket)
@@ -116,17 +115,18 @@ its hierarchical structure::
116115
put_obj_response = s3.put_object(Key='mykey', Body=b'my body')
117116

118117
In this example, the ``list_objects_v2`` method call will use the
119-
``'myspecificbucket'`` for the bucket instead of ``'mybucket'`` because
120-
the ``add_my_specific_bucket`` method was registered to the
121-
``'provide-client-params.s3.ListObjectsV2'`` event which is more specific than
122-
the ``'provide-client-params.s3'`` event. Thus, the
118+
``'amzn-s3-demo-bucket2'`` for the bucket instead of
119+
``'amzn-s3-demo-bucket1'`` because the ``add_my_specific_bucket`` method was
120+
registered to the ``'provide-client-params.s3.ListObjectsV2'`` event which is
121+
more specific than the ``'provide-client-params.s3'`` event. Thus, the
123122
``add_my_specific_bucket`` function is called before the
124123
``add_my_general_bucket`` function is called when the event is emitted.
125124

126-
However for the ``put_object`` call, the bucket used is ``'mybucket'``. This
127-
is because the event emitted for the ``put_object`` client call is
128-
``'provide-client-params.s3.PutObject'`` and the ``add_my_general_bucket``
129-
method is called via its registration to ``'provide-client-params.s3'``. The
125+
However for the ``put_object`` call, the bucket used is
126+
``'amzn-s3-demo-bucket1'``. This is because the event emitted for the
127+
``put_object`` client call is ``'provide-client-params.s3.PutObject'`` and the
128+
``add_my_general_bucket`` method is called via its registration to
129+
``'provide-client-params.s3'``. The
130130
``'provide-client-params.s3.ListObjectsV2'`` event is never emitted so the
131131
registered ``add_my_specific_bucket`` function is never called.
132132

@@ -147,7 +147,7 @@ of using wildcards in the event system::
147147

148148
def add_my_wildcard_bucket(params, **kwargs):
149149
if 'Bucket' not in params:
150-
params['Bucket'] = 'mybucket'
150+
params['Bucket'] = 'amzn-s3-demo-bucket'
151151

152152
event_system.register('provide-client-params.s3.*', add_my_wildcard_bucket)
153153
response = s3.list_objects_v2()
@@ -184,11 +184,11 @@ to another client's event system::
184184

185185
def add_my_bucket(params, **kwargs):
186186
if 'Bucket' not in params:
187-
params['Bucket'] = 'mybucket'
187+
params['Bucket'] = 'amzn-s3-demo-bucket1'
188188

189189
def add_my_other_bucket(params, **kwargs):
190190
if 'Bucket' not in params:
191-
params['Bucket'] = 'myotherbucket'
191+
params['Bucket'] = 'amzn-s3-demo-bucket2'
192192

193193
client1.meta.events.register(
194194
'provide-client-params.s3.ListObjectsV2', add_my_bucket)
@@ -200,10 +200,10 @@ to another client's event system::
200200

201201

202202
Thanks to the isolation of clients' event systems, ``client1`` will inject
203-
``'mybucket'`` for its ``list_objects_v2`` method call while ``client2`` will
204-
inject ``'myotherbucket'`` for its ``list_objects_v2`` method call because
205-
``add_my_bucket`` was registered to ``client1`` while ``add_my_other_bucket``
206-
was registered to ``client2``.
203+
``'amzn-s3-demo-bucket1'`` for its ``list_objects_v2`` method call while
204+
``client2`` will inject ``'amzn-s3-demo-bucket2'`` for its ``list_objects_v2``
205+
method call because ``add_my_bucket`` was registered to ``client1`` while
206+
``add_my_other_bucket`` was registered to ``client2``.
207207

208208

209209
Boto3 specific events
@@ -212,13 +212,14 @@ Boto3 specific events
212212
Boto3 emits a set of events that users can register to
213213
customize clients or resources and modify the behavior of method calls.
214214

215-
Here is a table of events that users of Boto3 can register handlers to. More information
216-
about each event can be found in the corresponding sections below:
215+
Here is a table of events that users of Boto3 can register handlers to. More
216+
information about each event can be found in the corresponding sections below:
217217

218218
.. note::
219219

220-
Events with a ``*`` in their order number are conditionally emitted while all others are always emitted.
221-
An explanation of all 3 conditional events is provided below.
220+
Events with a ``*`` in their order number are conditionally emitted while
221+
all others are always emitted. An explanation of all 3 conditional events is
222+
provided below.
222223

223224
``2 *`` - ``creating-resource-class`` is emitted ONLY when using a service resource.
224225

@@ -440,7 +441,7 @@ about each event can be found in the corresponding sections below:
440441
def add_my_bucket(params, **kwargs):
441442
# Add the name of the bucket you want to default to.
442443
if 'Bucket' not in params:
443-
params['Bucket'] = 'mybucket'
444+
params['Bucket'] = 'amzn-s3-demo-bucket'
444445

445446
# Register the function to an event
446447
event_system.register('provide-client-params.s3.ListObjectsV2', add_my_bucket)
@@ -551,13 +552,13 @@ about each event can be found in the corresponding sections below:
551552
# Register the function to an event
552553
event_system.register('request-created.s3.ListObjectsV2', inspect_request_created)
553554

554-
response = s3.list_objects_v2(Bucket='my-bucket')
555+
response = s3.list_objects_v2(Bucket='amzn-s3-demo-bucket')
555556

556557
This should output::
557558

558559
Request Info:
559560
method: GET
560-
url: https://my-bucket.s3 ...
561+
url: https://amzn-s3-demo-bucket.s3 ...
561562
data: ...
562563
params: { ... }
563564
auth_path: ...
@@ -682,9 +683,9 @@ about each event can be found in the corresponding sections below:
682683
``'after-call.service-name.operation-name'``
683684

684685
:Description:
685-
This event is emitted just after the service client makes an API call.
686-
This event allows developers to postprocess or inspect the API response according to the
687-
specific requirements of their application if needed.
686+
This event is emitted just after the service client makes an API call. This
687+
event allows developers to postprocess or inspect the API response according
688+
to the specific requirements of their application if needed.
688689

689690
:Keyword Arguments Emitted:
690691

@@ -720,7 +721,7 @@ about each event can be found in the corresponding sections below:
720721
# Register the function to an event
721722
event_system.register('after-call.s3.ListObjectsV2', print_after_call_args)
722723

723-
s3.list_objects_v2(Bucket='my-bucket')
724+
s3.list_objects_v2(Bucket='amzn-s3-demo-bucket')
724725

725726
This should output::
726727

docs/source/guide/migration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ Second, while every service now uses the runtime-generated low-level client, som
3434
# High-level connections & resource objects
3535
from boto.s3.bucket import Bucket
3636
s3_conn = boto.connect_s3()
37-
boto2_bucket = Bucket('mybucket')
37+
boto2_bucket = Bucket('amzn-s3-demo-bucket')
3838

3939
s3 = boto3.resource('s3')
40-
boto3_bucket = s3.Bucket('mybucket')
40+
boto3_bucket = s3.Bucket('amzn-s3-demo-bucket')
4141

4242
Installation and configuration
4343
------------------------------

docs/source/guide/migrations3.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ Creating a bucket
2121
Creating a bucket in Boto 2 and Boto3 is very similar, except that in Boto3 all action parameters must be passed via keyword arguments and a bucket configuration must be specified manually::
2222

2323
# Boto 2.x
24-
s3_connection.create_bucket('mybucket')
25-
s3_connection.create_bucket('mybucket', location=Location.USWest)
24+
s3_connection.create_bucket('amzn-s3-demo-bucket')
25+
s3_connection.create_bucket('amzn-s3-demo-bucket', location=Location.USWest)
2626

2727
# Boto3
28-
s3.create_bucket(Bucket='mybucket')
29-
s3.create_bucket(Bucket='mybucket', CreateBucketConfiguration={
28+
s3.create_bucket(Bucket='amzn-s3-demo-bucket')
29+
s3.create_bucket(Bucket='amzn-s3-demo-bucket', CreateBucketConfiguration={
3030
'LocationConstraint': 'us-west-1'})
3131

3232
Storing data
@@ -39,23 +39,23 @@ Storing data from a file, stream, or string is easy::
3939
key.set_contents_from_file('/tmp/hello.txt')
4040

4141
# Boto3
42-
s3.Object('mybucket', 'hello.txt').put(Body=open('/tmp/hello.txt', 'rb'))
42+
s3.Object('amzn-s3-demo-bucket', 'hello.txt').put(Body=open('/tmp/hello.txt', 'rb'))
4343

4444

4545
Accessing a bucket
4646
------------------
4747
Getting a bucket is easy with Boto3's resources, however these do not automatically validate whether a bucket exists::
4848

4949
# Boto 2.x
50-
bucket = s3_connection.get_bucket('mybucket', validate=False)
51-
exists = s3_connection.lookup('mybucket')
50+
bucket = s3_connection.get_bucket('amzn-s3-demo-bucket', validate=False)
51+
exists = s3_connection.lookup('amzn-s3-demo-bucket')
5252

5353
# Boto3
5454
import botocore
55-
bucket = s3.Bucket('mybucket')
55+
bucket = s3.Bucket('amzn-s3-demo-bucket')
5656
exists = True
5757
try:
58-
s3.meta.client.head_bucket(Bucket='mybucket')
58+
s3.meta.client.head_bucket(Bucket='amzn-s3-demo-bucket')
5959
except botocore.exceptions.ClientError as e:
6060
# If a client error is thrown, then check that it was a 404 error.
6161
# If it was a 404 error, then the bucket does not exist.

docs/source/guide/paginators.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ underlying API operation. The ``paginate`` method then returns an iterable
3232
paginator = client.get_paginator('list_objects_v2')
3333

3434
# Create a PageIterator from the Paginator
35-
page_iterator = paginator.paginate(Bucket='my-bucket')
35+
page_iterator = paginator.paginate(Bucket='amzn-s3-demo-bucket')
3636

3737
for page in page_iterator:
3838
print(page['Contents'])
@@ -47,7 +47,7 @@ the pages of API operation results. The ``paginate`` method accepts a
4747
pagination::
4848

4949
paginator = client.get_paginator('list_objects_v2')
50-
page_iterator = paginator.paginate(Bucket='my-bucket',
50+
page_iterator = paginator.paginate(Bucket='amzn-s3-demo-bucket',
5151
PaginationConfig={'MaxItems': 10})
5252

5353
``MaxItems``
@@ -82,7 +82,7 @@ to the client::
8282
8383
client = boto3.client('s3', region_name='us-west-2')
8484
paginator = client.get_paginator('list_objects_v2')
85-
operation_parameters = {'Bucket': 'my-bucket',
85+
operation_parameters = {'Bucket': 'amzn-s3-demo-bucket',
8686
'Prefix': 'foo/baz'}
8787
page_iterator = paginator.paginate(**operation_parameters)
8888
for page in page_iterator:
@@ -103,7 +103,7 @@ JMESPath expressions that are applied to each page of results through the
103103
104104
client = boto3.client('s3', region_name='us-west-2')
105105
paginator = client.get_paginator('list_objects_v2')
106-
page_iterator = paginator.paginate(Bucket='my-bucket')
106+
page_iterator = paginator.paginate(Bucket='amzn-s3-demo-bucket')
107107
filtered_iterator = page_iterator.search("Contents[?Size > `100`][]")
108108
for key_data in filtered_iterator:
109109
print(key_data)

docs/source/guide/quickstart.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,13 @@ Now that you have an ``s3`` resource, you can make send requests to the service.
140140
for bucket in s3.buckets.all():
141141
print(bucket.name)
142142

143-
You can also upload and download binary data. For example, the following uploads a new file to S3,
144-
assuming that the bucket ``my-bucket`` already exists::
143+
You can also upload and download binary data. For example, the following
144+
uploads a new file to S3, assuming that the bucket ``amzn-s3-demo-bucket``
145+
already exists::
145146

146147
# Upload a new file
147148
with open('test.jpg', 'rb') as data:
148-
s3.Bucket('my-bucket').put_object(Key='test.jpg', Body=data)
149+
s3.Bucket('amzn-s3-demo-bucket').put_object(Key='test.jpg', Body=data)
149150

150151
:ref:`guide_resources` and :ref:`guide_collections` are covered in more detail in the following
151152
sections.

docs/source/guide/resources.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ instantiation will result in an exception. Examples of identifiers::
4848
print(queue.url)
4949

5050
# S3 Object (bucket_name and key are identifiers)
51-
obj = s3.Object(bucket_name='boto3', key='test.py')
51+
obj = s3.Object(bucket_name='amzn-s3-demo-bucket', key='test.py')
5252
print(obj.bucket_name)
5353
print(obj.key)
5454

5555
# Raises exception, missing identifier: key!
56-
obj = s3.Object(bucket_name='boto3')
56+
obj = s3.Object(bucket_name='amzn-s3-demo-bucket')
5757

5858
Identifiers may also be passed as positional arguments::
5959

@@ -70,9 +70,9 @@ Identifiers also play a role in resource instance equality. For two
7070
instances of a resource to be considered equal, their identifiers must
7171
be equal::
7272

73-
>>> bucket1 = s3.Bucket('boto3')
74-
>>> bucket2 = s3.Bucket('boto3')
75-
>>> bucket3 = s3.Bucket('some-other-bucket')
73+
>>> bucket1 = s3.Bucket('amzn-s3-demo-bucket1')
74+
>>> bucket2 = s3.Bucket('amzn-s3-demo-bucket1')
75+
>>> bucket3 = s3.Bucket('amzn-s3-demo-bucket3')
7676

7777
>>> bucket1 == bucket2
7878
True
@@ -128,7 +128,7 @@ of actions::
128128
message.delete()
129129

130130
# S3 Object
131-
obj = s3.Object(bucket_name='boto3', key='test.py')
131+
obj = s3.Object(bucket_name='amzn-s3-demo-bucket', key='test.py')
132132
response = obj.get()
133133
data = response['Body'].read()
134134

0 commit comments

Comments
 (0)