You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 15, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: doc_source/sample-cplusplus.rst
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
eifjccfvciuhdbchfggrcldbkkrhlrndvheelieckhfr
1
2
.. Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
3
3
4
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0
@@ -184,7 +185,8 @@ you must set up credentials management in your |env|. The |sdk-cpp| needs these
184
185
185
186
.. topic:: To build the |sdk-cpp|
186
187
187
-
.. note:: This step could take up to one or more hours to complete, depending on the computing resources available to your |EC2| instance or your own server.
188
+
.. note:: This step could take up to one or more hours to complete, depending on the computing resources available to your |EC2| instance or your own server and
189
+
how much of the |sdk-cpp| you choose to build.
188
190
189
191
#. Create a folder to build the |sdk-cpp| into.
190
192
@@ -204,6 +206,12 @@ you must set up credentials management in your |env|. The |sdk-cpp| needs these
204
206
205
207
cmake3 ../aws-sdk-cpp-master
206
208
209
+
.. note:: To build only the |S3| portion of the |sdk-cpp| and its dependencies, run this command instead:
210
+
211
+
.. code-block:: sh
212
+
213
+
cmake3 ../aws-sdk-cpp-master -DBUILD_ONLY="s3"
214
+
207
215
#. Build the |sdk-cpp| into this folder.
208
216
209
217
.. code-block:: sh
@@ -234,7 +242,7 @@ Step 5: Add AWS SDK Code
234
242
In this step, you add some more code, this time to interact with |s3| to create a bucket, list your available buckets, and then delete the bucket you just created. You
235
243
will run this code later.
236
244
237
-
#. In the |AC9IDE|, create a file with this content, and save the file with the name :file:`s3.cpp` at the root (:file:`/`) of your |env|.
245
+
#. In the |AC9IDE|, create a file with this content, and save the file with the name :file:`s3-demo.cpp` at the root (:file:`/`) of your |env|.
238
246
239
247
.. code-block:: cpp
240
248
@@ -391,7 +399,7 @@ Step 6: Build and Run the AWS SDK Code
.. note:: If you have Python 2 and 3 installed, and you want to use Python 3 but running the :command:`python --version` command outputs a version of Python 2, you can
62
+
use Python 3 in one or more of the following ways:
63
+
64
+
* Instead of running
59
65
60
66
For more information, see `Download Python <https://www.python.org/downloads/>`_ on the Python website and `Installing Packages <https://packaging.python.org/installing/>`_
61
67
in the :title:`Python Packaging User Guide`.
@@ -93,9 +99,11 @@ Step 3: Run the Code
93
99
====================
94
100
95
101
#. In the |AC9IDE|, on the menu bar, choose :menuselection:`Run, Run Configurations, New Run Configuration`.
96
-
#. On the :guilabel:`[New] - Idle` tab, choose :guilabel:`Runner: Auto`, and then choose :guilabel:`Python`.
102
+
#. On the :guilabel:`[New] - Idle` tab, choose :guilabel:`Runner: Auto`, and then choose :guilabel:`Python 2` or :guilabel:`Python 3`, depending
103
+
on which version of Python you want to use.
97
104
98
-
.. note:: If :guilabel:`Python` isn't available, you can create a custom runner for Python.
105
+
.. note:: If :guilabel:`Python 2` or :guilabel:`Python 3` isn't available, you can create a custom runner for the version of Python that is installed in
106
+
your |env|.
99
107
100
108
#. On the :guilabel:`[New] - Idle` tab, choose :guilabel:`Runner: Auto`, and then choose :guilabel:`New Runner`.
101
109
#. On the :guilabel:`My Runner.run` tab, replace the tab's contents with this code.
@@ -112,6 +120,9 @@ Step 3: Run the Code
112
120
#. On the :guilabel:`[New] - Idle` tab, choose :guilabel:`Runner: Auto`, and then choose :guilabel:`Python`.
113
121
#. Choose the :guilabel:`hello.py` tab to make it active.
114
122
123
+
To use a specific version of Python that is installed in your |env|, change :code:`python` to the path to the Python executable in the preceding custom runner
124
+
definition (for example, :code:`/usr/bin/python27`, :code:`/usr/bin/python36`, or similar).
125
+
115
126
#. For :guilabel:`Command`, type :kbd:`hello.py59`. In the code, :code:`5` represents :code:`sys.argv[1]`,
116
127
and :code:`9` represents :code:`sys.argv[2]`.
117
128
#. Choose the :guilabel:`Run` button, and compare your output.
@@ -183,9 +194,10 @@ In the |AC9IDE|, create a file with this content, and save the file with the nam
183
194
import sys
184
195
import botocore
185
196
197
+
region ='YOUR_REGION'
186
198
s3 = boto3.client(
187
199
's3',
188
-
region_name='YOUR_REGION'
200
+
region_name=region
189
201
)
190
202
191
203
bucket_name = sys.argv[1]
@@ -206,7 +218,11 @@ In the |AC9IDE|, create a file with this content, and save the file with the nam
206
218
# Create a new bucket.
207
219
try:
208
220
print("\nCreating a new bucket named '"+ bucket_name +"'...\n")
209
-
s3.create_bucket(Bucket= bucket_name)
221
+
s3.create_bucket(Bucket= bucket_name,
222
+
CreateBucketConfiguration= {
223
+
'LocationConstraint': region
224
+
}
225
+
)
210
226
except botocore.exceptions.ClientError as e:
211
227
if e.response['Error']['Code'] =='BucketAlreadyExists':
212
228
print("Cannot create the bucket. A bucket with the name '"+
@@ -230,7 +246,8 @@ Step 6: Run the AWS SDK Code
230
246
============================
231
247
232
248
#. On the menu bar, choose :menuselection:`Run, Run Configurations, New Run Configuration`.
233
-
#. On the :guilabel:`[New] - Idle` tab, choose :guilabel:`Runner: Auto`, and then choose :guilabel:`Python`.
249
+
#. On the :guilabel:`[New] - Idle` tab, choose :guilabel:`Runner: Auto`, and then choose :guilabel:`Python 2` or :guilabel:`Python 3`, depending
250
+
on which version of Python you want to use and is installed in your |env|.
234
251
#. For :guilabel:`Command`, type :samp:`s3.py {YOUR_BUCKET_NAME}`, where :samp:`{YOUR_BUCKET_NAME}` is the name of the bucket you want to create and then delete.
235
252
236
253
.. note:: |S3| bucket names must be unique across AWS |mdash| not just your AWS account.
0 commit comments