aws-sdk 2.0.1 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +20 -0
- package/.gitignore +10 -0
- package/.travis.yml +20 -0
- package/.yardopts +20 -0
- package/.yardopts_guide +21 -0
- package/Gemfile +16 -0
- package/Gemfile.lock +34 -0
- package/README.md +5 -6
- package/Rakefile +14 -0
- package/UPGRADING.md +9 -4
- package/configuration.sample +5 -0
- package/dist/BUNDLE_LICENSE.txt +96 -0
- package/dist/aws-sdk.js +9594 -0
- package/dist/aws-sdk.min.js +21 -0
- package/dist-tools/.eslintrc +10 -0
- package/dist-tools/browser-builder.js +142 -0
- package/dist-tools/strategies/cache.js +68 -0
- package/dist-tools/strategies/default.js +165 -0
- package/dist-tools/test/browser-builder.mocha.spec.coffee +182 -0
- package/dist-tools/test/helpers.coffee +16 -0
- package/doc-src/guide/browser-building.md +93 -0
- package/doc-src/guide/browser-configuring-wif.md +287 -0
- package/doc-src/guide/browser-configuring.md +218 -0
- package/doc-src/guide/browser-examples.md +220 -0
- package/doc-src/guide/browser-intro.md +46 -0
- package/doc-src/guide/browser-making-requests.md +279 -0
- package/doc-src/guide/browser-services.md +75 -0
- package/doc-src/guide/index.md +41 -0
- package/doc-src/guide/node-configuring.md +272 -0
- package/doc-src/guide/node-examples.md +341 -0
- package/doc-src/guide/node-intro.md +32 -0
- package/doc-src/guide/node-making-requests.md +309 -0
- package/doc-src/guide/node-services.md +159 -0
- package/doc-src/templates/api-versions/model_documentor.rb +366 -0
- package/doc-src/templates/api-versions/plugin.rb +230 -0
- package/doc-src/templates/api-versions/templates/default/class/html/setup.rb +9 -0
- package/doc-src/templates/api-versions/templates/default/class/html/waiter_details_list.erb +7 -0
- package/doc-src/templates/api-versions/templates/default/class/html/waiter_summary.erb +7 -0
- package/doc-src/templates/api-versions/templates/default/docstring/html/experimental.erb +4 -0
- package/doc-src/templates/api-versions/templates/default/docstring/setup.rb +9 -0
- package/doc-src/templates/api-versions/templates/default/fulldoc/html/css/common.css +6 -0
- package/doc-src/templates/api-versions/templates/default/fulldoc/html/setup.rb +62 -0
- package/doc-src/templates/api-versions/templates/default/layout/html/services.erb +10 -0
- package/doc-src/templates/api-versions/templates/default/layout/html/setup.rb +28 -0
- package/doc-src/templates/api-versions/templates/default/module/html/box_info.erb +45 -0
- package/doc-src/templates/api-versions/templates/default/module/html/children.erb +8 -0
- package/doc-src/templates/api-versions/templates/default/tags/setup.rb +3 -0
- package/doc-src/templates/api-versions/templates/default/waiter_details/html/method_signature.erb +3 -0
- package/doc-src/templates/api-versions/templates/default/waiter_details/html/setup.rb +5 -0
- package/doc-src/templates/default/layout/html/footer.erb +31 -0
- package/doc-src/templates/default/layout/html/layout.erb +23 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/css/highlight.github.css +127 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/css/style.css +1192 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/img/logo.png +0 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/app.js +33 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/highlight.pack.js +27 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/AUTHORS +55 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/LICENSE +25 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/doctools.js +247 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/file.png +0 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/searchtools.js +568 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/underscore.js +23 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/search.erb +29 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/search_index.erb +1 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/setup.rb +75 -0
- package/doc-src/templates/flasky_sphinx_guide/layout/html/layout.erb +93 -0
- package/doc-src/templates/flasky_sphinx_guide/layout/html/setup.rb +9 -0
- package/doc-src/templates/flasky_sphinx_guide/layout/html/sidebar.erb +45 -0
- package/doc-src/templates/flasky_sphinx_guide/onefile/html/layout.erb +51 -0
- package/doc-src/templates/flasky_sphinx_guide/onefile/html/setup.rb +1 -0
- package/eslint-rules/no-require-in-service.js +10 -0
- package/features/autoscaling/autoscaling.feature +21 -0
- package/features/autoscaling/step_definitions/autoscaling.js +49 -0
- package/features/cloudformation/cloudformation.feature +22 -0
- package/features/cloudformation/step_definitions/cloudformation.js +26 -0
- package/features/cloudfront/cloudfront.feature +28 -0
- package/features/cloudfront/step_definitions/cloudfront-latest.js +54 -0
- package/features/cloudfront/step_definitions/cloudfront.js +21 -0
- package/features/cloudsearch/cloudsearch.feature +34 -0
- package/features/cloudsearch/step_definitions/cloudsearch.js +42 -0
- package/features/cloudtrail/cloudtrail.feature +17 -0
- package/features/cloudtrail/step_definitions/cloudtrail.js +14 -0
- package/features/cloudwatch/cloudwatch.feature +15 -0
- package/features/cloudwatch/step_definitions/cloudwatch.js +48 -0
- package/features/datapipeline/datapipeline.feature +23 -0
- package/features/datapipeline/step_definitions/datapipeline.js +79 -0
- package/features/directconnect/directconnect.feature +20 -0
- package/features/directconnect/step_definitions/directconnect.js +44 -0
- package/features/dynamodb/crc32.feature +18 -0
- package/features/dynamodb/step_definitions/dynamodb.js +154 -0
- package/features/dynamodb/tables.feature +50 -0
- package/features/ec2/ec2.feature +28 -0
- package/features/ec2/step_definitions/ec2.js +65 -0
- package/features/elasticache/elasticache.feature +20 -0
- package/features/elasticache/step_definitions/elasticache.js +34 -0
- package/features/elasticbeanstalk/elasticbeanstalk.feature +22 -0
- package/features/elasticbeanstalk/step_definitions/elasticbeanstalk.js +38 -0
- package/features/elastictranscoder/elastictranscoder.feature +24 -0
- package/features/elastictranscoder/step_definitions/elastictranscoder.js +56 -0
- package/features/elb/elb.feature +19 -0
- package/features/elb/step_definitions/elb.js +37 -0
- package/features/emr/emr.feature +16 -0
- package/features/emr/step_definitions/emr.js +45 -0
- package/features/extra/assertions.js +29 -0
- package/features/extra/dummy.feature +0 -0
- package/features/extra/fixtures/testfile.txt +1 -0
- package/features/extra/helpers.js +113 -0
- package/features/extra/hooks.js +107 -0
- package/features/extra/world.js +12 -0
- package/features/glacier/glacier.feature +47 -0
- package/features/glacier/step_definitions/glacier.js +112 -0
- package/features/iam/iam.feature +24 -0
- package/features/iam/step_definitions/iam.js +66 -0
- package/features/importexport/importexport.feature +53 -0
- package/features/importexport/step_definitions/importexport.js +42 -0
- package/features/kinesis/kinesis.feature +9 -0
- package/features/kinesis/step_definitions/kinesis.js +10 -0
- package/features/opsworks/opsworks.feature +26 -0
- package/features/opsworks/step_definitions/opsworks.js +42 -0
- package/features/rds/rds.feature +32 -0
- package/features/rds/step_definitions/rds.js +72 -0
- package/features/redshift/redshift.feature +20 -0
- package/features/redshift/step_definitions/redshift.js +33 -0
- package/features/route53/route53.feature +41 -0
- package/features/route53/step_definitions/route53.js +97 -0
- package/features/s3/buckets.feature +40 -0
- package/features/s3/objects.feature +122 -0
- package/features/s3/step_definitions/buckets.js +136 -0
- package/features/s3/step_definitions/hooks.js +39 -0
- package/features/s3/step_definitions/objects.js +204 -0
- package/features/s3/step_definitions/proxy.js +44 -0
- package/features/ses/ses.feature +20 -0
- package/features/ses/step_definitions/ses.js +22 -0
- package/features/simpledb/simpledb.feature +29 -0
- package/features/simpledb/step_definitions/simpledb.js +46 -0
- package/features/sns/sns.feature +15 -0
- package/features/sns/step_definitions/sns.js +33 -0
- package/features/sqs/messages.feature +21 -0
- package/features/sqs/queues.feature +18 -0
- package/features/sqs/step_definitions/messages.js +46 -0
- package/features/sqs/step_definitions/queues.js +33 -0
- package/features/sqs/step_definitions/sqs.js +7 -0
- package/features/storagegateway/step_definitions/storagegateway.js +16 -0
- package/features/storagegateway/storagegateway.feature +13 -0
- package/features/sts/step_definitions/sts.js +35 -0
- package/features/sts/sts.feature +29 -0
- package/features/support/step_definitions/support.js +35 -0
- package/features/support/support.feature +18 -0
- package/features/swf/step_definitions/swf.js +38 -0
- package/features/swf/swf.feature +15 -0
- package/index.js +2 -0
- package/lib/core.js +2 -2
- package/lib/credentials/shared_ini_file_credentials.js +0 -1
- package/lib/event_listeners.js +13 -1
- package/lib/http/node.js +19 -30
- package/lib/model/resource_waiter.js +0 -4
- package/lib/model/shape.js +2 -1
- package/lib/protocol/rest_xml.js +1 -1
- package/lib/region_config.js +31 -0
- package/lib/region_config.json +56 -0
- package/lib/request.js +37 -45
- package/lib/sequential_executor.js +17 -34
- package/lib/service.js +17 -44
- package/lib/services/cloudsearchdomain.js +69 -0
- package/lib/services/route53.js +0 -12
- package/lib/services/s3.js +3 -19
- package/lib/signers/v4.js +2 -1
- package/lib/util.js +28 -3
- package/package.json +3 -3
- package/scripts/console +11 -3
- package/scripts/coverage +126 -0
- package/tasks/apis.rake +122 -0
- package/tasks/browser.rake +89 -0
- package/tasks/docs.rake +36 -0
- package/tasks/lib/cucumber_generator.rb +40 -0
- package/tasks/util.rake +33 -0
- package/test/browser/js/jasmine-1.3.1.js +2600 -0
- package/test/browser/js/jasmine-html.js +681 -0
- package/test/browser/runner.html +109 -0
- package/test/browser/runner.js +92 -0
- package/test/browser/sample/appinfo.sample.js +15 -0
- package/test/browser/sample/console.html +429 -0
- package/test/browser/sample/css/smoothness/images/animated-overlay.gif +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/jquery-ui-1.10.1.custom.css +1175 -0
- package/test/browser/sample/css/smoothness/jquery-ui-1.10.1.custom.min.css +5 -0
- package/test/browser/sample/img/loading.gif +0 -0
- package/test/browser/sample/js/jquery-1.9.1.js +9597 -0
- package/test/browser/sample/js/jquery-ui-1.10.1.custom.js +14903 -0
- package/test/browser/sample/js/jquery-ui-1.10.1.custom.min.js +6 -0
- package/test/browser/sample/s3upload.html +111 -0
- package/test/browser.spec.coffee +207 -0
- package/test/config.spec.coffee +202 -0
- package/test/credential_provider_chain.spec.coffee +90 -0
- package/test/credentials.spec.coffee +452 -0
- package/test/endpoint.spec.coffee +80 -0
- package/test/event_listeners.spec.coffee +493 -0
- package/test/helpers.coffee +150 -0
- package/test/http_request.spec.coffee +55 -0
- package/test/json/builder.spec.coffee +129 -0
- package/test/json/parser.spec.coffee +108 -0
- package/test/metadata_service.spec.coffee +54 -0
- package/test/model/api.spec.coffee +67 -0
- package/test/model/shape.spec.coffee +23 -0
- package/test/node_http_client.spec.coffee +40 -0
- package/test/param_validator.spec.coffee +456 -0
- package/test/protocol/json.spec.coffee +167 -0
- package/test/protocol/query.spec.coffee +191 -0
- package/test/protocol/rest.spec.coffee +237 -0
- package/test/protocol/rest_json.spec.coffee +255 -0
- package/test/protocol/rest_xml.spec.coffee +329 -0
- package/test/query/query_param_serializer.spec.coffee +327 -0
- package/test/region_config.spec.coffee +50 -0
- package/test/request.spec.coffee +316 -0
- package/test/resource_waiter.spec.coffee +89 -0
- package/test/response.spec.coffee +81 -0
- package/test/sequential_executor.spec.coffee +118 -0
- package/test/service.spec.coffee +230 -0
- package/test/services/cloudfront.spec.coffee +44 -0
- package/test/services/cloudsearchdomain.spec.coffee +23 -0
- package/test/services/dynamodb.spec.coffee +32 -0
- package/test/services/ec2.spec.coffee +78 -0
- package/test/services/elastictranscoder.spec.coffee +43 -0
- package/test/services/glacier.spec.coffee +61 -0
- package/test/services/rds.spec.coffee +38 -0
- package/test/services/route53.spec.coffee +77 -0
- package/test/services/s3.spec.coffee +538 -0
- package/test/services/simpledb.spec.coffee +12 -0
- package/test/services/sqs.spec.coffee +130 -0
- package/test/services/sts.spec.coffee +72 -0
- package/test/services/swf.spec.coffee +6 -0
- package/test/signers/presign.spec.coffee +36 -0
- package/test/signers/s3.spec.coffee +297 -0
- package/test/signers/v2.spec.coffee +68 -0
- package/test/signers/v4.spec.coffee +135 -0
- package/test/util.spec.coffee +510 -0
- package/test/xml/builder.spec.coffee +529 -0
- package/test/xml/parser.spec.coffee +587 -0
- package/lib/services/simpledb.js +0 -15
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# @title Configuring the SDK in Node.js
|
|
2
|
+
|
|
3
|
+
# Configuring the SDK in Node.js
|
|
4
|
+
|
|
5
|
+
## The Configuration Object
|
|
6
|
+
|
|
7
|
+
Configuration in the SDK can be done in two ways:
|
|
8
|
+
|
|
9
|
+
1. Global configuration on `AWS.config`, or,
|
|
10
|
+
2. Passing extra configuration to a service object
|
|
11
|
+
|
|
12
|
+
Setting global configuration with `AWS.config` is often easier to get up
|
|
13
|
+
and running with, but service level configuration can provide much more control
|
|
14
|
+
over your requests. Both of these configuration mechanisms are discussed.
|
|
15
|
+
|
|
16
|
+
## Global Configuration (`AWS.config`)
|
|
17
|
+
|
|
18
|
+
By default, you can set global configuration by updating the `AWS.config` object with
|
|
19
|
+
new settings. The most common settings are:
|
|
20
|
+
|
|
21
|
+
1. `accessKeyId`, `secretAccessKey`, `sessionToken` — for credential management
|
|
22
|
+
2. `region` — to set the region for requests
|
|
23
|
+
3. `sslEnabled` — whether SSL is enabled or not
|
|
24
|
+
4. `maxRetries` — to control the number of retries for a request
|
|
25
|
+
5. `logger` — a logger object to write debug information to. Set to `process.stdout`
|
|
26
|
+
to get logging information about service requests.
|
|
27
|
+
|
|
28
|
+
More configuration settings can be found in the
|
|
29
|
+
[API reference documentation](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/frames.html).
|
|
30
|
+
|
|
31
|
+
The only things you *need* to set in order to use the SDK are credentials and
|
|
32
|
+
the region value. Let's discuss how to do that.
|
|
33
|
+
|
|
34
|
+
### Setting AWS Credentials
|
|
35
|
+
|
|
36
|
+
<p class="note">Remember, if you set your AWS credentials in the shared
|
|
37
|
+
credentials file or via environment variables, the AWS SDK for Node.js will
|
|
38
|
+
automatically detect them, and you will not need to perform any manual
|
|
39
|
+
credential configuration in your application.
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
Credentials are the most important thing you need to set when using any AWS SDK.
|
|
43
|
+
Credentials can be set globally on the `AWS.config` object or per service by
|
|
44
|
+
passing the credential information to the service object directly.
|
|
45
|
+
|
|
46
|
+
There are a few ways to load credentials. Here they are, in order of
|
|
47
|
+
recommendation:
|
|
48
|
+
|
|
49
|
+
1. Loaded from IAM Roles for Amazon EC2 (if running on EC2),
|
|
50
|
+
2. Loaded from the shared credentials file (`~/.aws/credentials`),
|
|
51
|
+
3. Loaded from environment variables,
|
|
52
|
+
4. Loaded from a JSON file on disk,
|
|
53
|
+
5. Hardcoded in your application
|
|
54
|
+
|
|
55
|
+
We do not recommend that you hard-code your AWS credentials in your application;
|
|
56
|
+
however, it is reasonable to temporarily hard-code credential information
|
|
57
|
+
in small personal scripts or for testing purposes.
|
|
58
|
+
|
|
59
|
+
#### Credentials from the Shared Credentials File (`~/.aws/credentials`)
|
|
60
|
+
|
|
61
|
+
By default, the SDK will automatically search the shared credentials file
|
|
62
|
+
for credentials when loading. If you use this file for other SDKs and tools
|
|
63
|
+
(like the CLI), you do not need to take any extra steps to configure
|
|
64
|
+
credentials in the SDK.
|
|
65
|
+
|
|
66
|
+
You may configure credentials for multiple access keys in the same shared
|
|
67
|
+
configuration file using *profiles*. This is discussed in the last part of
|
|
68
|
+
this section.
|
|
69
|
+
|
|
70
|
+
##### Creating the Shared Credentials File
|
|
71
|
+
|
|
72
|
+
If you do not already have a shared credentials file, you can create one in
|
|
73
|
+
your home directory, specifically inside of `~/.aws/credentials`. Create and
|
|
74
|
+
open the file, and add the following text, filling in the
|
|
75
|
+
`<YOUR_ACCESS_KEY_ID>` and `<YOUR_SECRET_ACCESS_KEY>` values:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
[default]
|
|
79
|
+
aws_access_key_id = <YOUR_ACCESS_KEY_ID>
|
|
80
|
+
aws_secret_access_key = <YOUR_SECRET_ACCESS_KEY>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The `[default]` heading defines credentials for the "default" profile. You
|
|
84
|
+
can define credentials for other profiles too. This is discussed in the next
|
|
85
|
+
section.
|
|
86
|
+
|
|
87
|
+
Once this file is saved, the SDK will load these credentials without any
|
|
88
|
+
extra configuration.
|
|
89
|
+
|
|
90
|
+
##### Using Profiles with the SDK
|
|
91
|
+
|
|
92
|
+
It is possible to have credential information for multiple access keys in the
|
|
93
|
+
same shared configuration file. You can make use of different credentials
|
|
94
|
+
through the use of "profiles". Each profile maps to a set of credentials.
|
|
95
|
+
For example, multiple profiles could be configured like so:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
[default] ; the default profile
|
|
99
|
+
aws_access_key_id = ...
|
|
100
|
+
aws_secret_access_key = ...
|
|
101
|
+
|
|
102
|
+
[personal-account] ; my "personal-account" profile
|
|
103
|
+
aws_access_key_id = ...
|
|
104
|
+
aws_secret_access_key = ...
|
|
105
|
+
|
|
106
|
+
[work-stuff] ; work profile
|
|
107
|
+
aws_access_key_id = ...
|
|
108
|
+
aws_secret_access_key = ...
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
By default, the SDK checks the `AWS_PROFILE` environment variable for the
|
|
112
|
+
profile name to use. If no `AWS_PROFILE` variable is set in your environment,
|
|
113
|
+
the SDK will use the "default" profile.
|
|
114
|
+
|
|
115
|
+
In the above case, we could use `AWS_PROFILE=work-stuff`
|
|
116
|
+
to load our work credentials when using the SDK. If we had some `script.js`
|
|
117
|
+
file that used the SDK, we could run it with those credentials by typing:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
$ AWS_PROFILE=work-stuff node script.js
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
It is also possible to explicitly select the profile using the SDK, either
|
|
124
|
+
by setting `process.env.AWS_PROFILE` prior to loading the SDK, or by selecting
|
|
125
|
+
the credential provider manually:
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
var credentials = new AWS.SharedIniFileCredentials({profile: 'work-stuff'});
|
|
129
|
+
AWS.config.credentials = credentials;
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Credentials from Environment Variables
|
|
133
|
+
|
|
134
|
+
By default, the SDK will automatically detect AWS credentials
|
|
135
|
+
set in your environment and use them for requests. This means that if you
|
|
136
|
+
properly set your environment variables, you do not need to manage credentials
|
|
137
|
+
in your application at all.
|
|
138
|
+
|
|
139
|
+
The keys that the SDK looks for are as follows:
|
|
140
|
+
|
|
141
|
+
```plain
|
|
142
|
+
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN (optional)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Alternately, the SDK can accept the `AMAZON_` prefix instead:
|
|
146
|
+
|
|
147
|
+
```plain
|
|
148
|
+
AMAZON_ACCESS_KEY_ID, AMAZON_SECRET_ACCESS_KEY, AMAZON_SESSION_TOKEN (optional)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### Credentials from Disk
|
|
152
|
+
|
|
153
|
+
You can also load configuration and credentials from disk using
|
|
154
|
+
`AWS.config.loadFromPath` by passing a file to a JSON document
|
|
155
|
+
containing the configuration data. For example, if you had a file
|
|
156
|
+
named 'config.json' with the contents:
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
{ "accessKeyId": "akid", "secretAccessKey": "secret", "region": "us-east-1" }
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
You can load the JSON data using the command:
|
|
163
|
+
|
|
164
|
+
```javascript
|
|
165
|
+
AWS.config.loadFromPath('./config.json');
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Note that the `loadFromPath` method clobbers all existing configuration on
|
|
169
|
+
the object. If you are adding extra configuration, make sure you add it
|
|
170
|
+
after this call.
|
|
171
|
+
|
|
172
|
+
#### Hard-Coding Credentials
|
|
173
|
+
|
|
174
|
+
<p class="note">We recommend you <strong>not</strong> hard-code
|
|
175
|
+
credentials inside an application. Use this method only for
|
|
176
|
+
small personal scripts or for testing purposes.
|
|
177
|
+
</p>
|
|
178
|
+
|
|
179
|
+
You can hard-code credentials by passing the credential information to the
|
|
180
|
+
configuration object using `AWS.config.update()`:
|
|
181
|
+
|
|
182
|
+
```javascript
|
|
183
|
+
AWS.config.update({accessKeyId: 'akid', secretAccessKey: 'secret'});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Setting the Region
|
|
187
|
+
|
|
188
|
+
The AWS SDK for Node.js doesn't select the region by default. You can choose
|
|
189
|
+
a region similarly to setting credentials by either loading from disk or
|
|
190
|
+
using `AWS.config.update()`:
|
|
191
|
+
|
|
192
|
+
```javascript
|
|
193
|
+
AWS.config.update({region: 'us-west-1'});
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Locking API Versions
|
|
197
|
+
|
|
198
|
+
<p class="note">For more information on API version locking in the SDK, see the
|
|
199
|
+
{file:node-services.md Working With Services} section.
|
|
200
|
+
</p>
|
|
201
|
+
|
|
202
|
+
You can globally configure a set of API versions to use for each service by
|
|
203
|
+
specifying the `apiVersions` parameter in `AWS.config`. For example,
|
|
204
|
+
you can choose to set specific versions of the DynamoDB and EC2 services,
|
|
205
|
+
while selecting the "latest" version of Redshift:
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
AWS.config.apiVersions = {
|
|
209
|
+
dynamodb: '2011-12-05',
|
|
210
|
+
ec2: '2013-02-01',
|
|
211
|
+
redshift: 'latest'
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Note that by default, the SDK will use the "latest" available API version
|
|
216
|
+
when constructing a service.
|
|
217
|
+
|
|
218
|
+
You can also lock all services at a specific point in time by using a "fuzzy
|
|
219
|
+
version":
|
|
220
|
+
|
|
221
|
+
```javascript
|
|
222
|
+
// Try to use latest available APIs before this date
|
|
223
|
+
AWS.config.apiVersion = '2012-05-04';
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Configuring a Proxy
|
|
227
|
+
|
|
228
|
+
If you cannot connect to the internet directly, the SDK supports the use of
|
|
229
|
+
HTTP or HTTPS proxies through global or per-service configuration options. To
|
|
230
|
+
set a proxy, pass the `proxy` option to the `httpOptions` setting of your
|
|
231
|
+
config object. This is how you could set a global proxy:
|
|
232
|
+
|
|
233
|
+
```javascript
|
|
234
|
+
AWS.config.update({
|
|
235
|
+
httpOptions: {
|
|
236
|
+
proxy: 'http://localhost:8080'
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
var s3 = new AWS.S3();
|
|
241
|
+
s3.getObject({Bucket: 'bucket', Key: 'key'}, function (err, data) {
|
|
242
|
+
console.log(err, data);
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Service-Specific Configuration
|
|
247
|
+
|
|
248
|
+
Occasionally, you might want to apply configuration only to one service.
|
|
249
|
+
For instance, you want to use multiple EC2 objects in different regions.
|
|
250
|
+
You can do this by passing configuration data directly to the service object
|
|
251
|
+
constructor:
|
|
252
|
+
|
|
253
|
+
```javascript
|
|
254
|
+
var ec2 = new AWS.EC2({region: 'ap-southeast-2', maxRetries: 15});
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Note that the constructor takes all of the same configuration data as the
|
|
258
|
+
`AWS.config` object described above, including credential information.
|
|
259
|
+
|
|
260
|
+
## Immutable Configuration Data
|
|
261
|
+
|
|
262
|
+
Global configuration changes apply to all requests for all *newly* created
|
|
263
|
+
services. Any newly created service will merge its local options on top of
|
|
264
|
+
the global configuration data at the time of creation. This means that any
|
|
265
|
+
future updates to the global `AWS.config` object will *not* apply to existing
|
|
266
|
+
service objects. These services would have to be manually updated with the new
|
|
267
|
+
configuration data, or recreated using the following command (assuming an
|
|
268
|
+
existing `s3` service object):
|
|
269
|
+
|
|
270
|
+
```javascript
|
|
271
|
+
s3 = new AWS.S3(s3.config);
|
|
272
|
+
```
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# @title Examples Using Node.js
|
|
2
|
+
|
|
3
|
+
# Examples Using Node.js
|
|
4
|
+
|
|
5
|
+
All of these examples assume that the AWS library is required,
|
|
6
|
+
credentials are loaded via environment variables (`AWS_ACCESS_KEY_ID`
|
|
7
|
+
and `AWS_SECRET_ACCESS_KEY`), and the region is set via
|
|
8
|
+
`AWS.config.update({region: 'us-west-2'});` or the `AWS_REGION` environment
|
|
9
|
+
variable.
|
|
10
|
+
|
|
11
|
+
The common preamble code can be summarized as follows:
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
var AWS = require('aws-sdk');
|
|
15
|
+
AWS.config.region = 'us-west-2';
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Basic Usage Example
|
|
19
|
+
|
|
20
|
+
The following example shows basic usage of the SDK:
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
// Load the AWS SDK for Node.js
|
|
24
|
+
var AWS = require('aws-sdk');
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Don't hard-code your credentials!
|
|
28
|
+
* Export the following environment variables instead:
|
|
29
|
+
*
|
|
30
|
+
* export AWS_ACCESS_KEY_ID='AKID'
|
|
31
|
+
* export AWS_SECRET_ACCESS_KEY='SECRET'
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
// Set your region for future requests.
|
|
35
|
+
AWS.config.region = 'us-west-2';
|
|
36
|
+
|
|
37
|
+
// Create a bucket using bound parameters and put something in it.
|
|
38
|
+
// Make sure to change the bucket name from "myBucket" to something unique.
|
|
39
|
+
var s3bucket = new AWS.S3({params: {Bucket: 'myBucket'}});
|
|
40
|
+
s3bucket.createBucket(function() {
|
|
41
|
+
var data = {Key: 'myKey', Body: 'Hello!'};
|
|
42
|
+
s3bucket.putObject(data, function(err, data) {
|
|
43
|
+
if (err) {
|
|
44
|
+
console.log("Error uploading data: ", err);
|
|
45
|
+
} else {
|
|
46
|
+
console.log("Successfully uploaded data to myBucket/myKey");
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Amazon Elastic Compute Cloud (Amazon EC2)
|
|
53
|
+
|
|
54
|
+
### Amazon EC2: Creating an Instance with Tags (`runInstances`, `createTags`)
|
|
55
|
+
|
|
56
|
+
The Amazon EC2 API has two distinct operations for creating instances and
|
|
57
|
+
attaching tags to instances. In order to create an instance with tags, you can
|
|
58
|
+
call both of these operations in series. The following example adds a "Name"
|
|
59
|
+
tag to a new instance, which the Amazon EC2 console recognizes and displays
|
|
60
|
+
in the Name field of the instance list.
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
var ec2 = new AWS.EC2();
|
|
64
|
+
|
|
65
|
+
var params = {
|
|
66
|
+
ImageId: 'ami-1624987f', // Amazon Linux AMI x86_64 EBS
|
|
67
|
+
InstanceType: 't1.micro',
|
|
68
|
+
MinCount: 1, MaxCount: 1
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Create the instance
|
|
72
|
+
ec2.runInstances(params, function(err, data) {
|
|
73
|
+
if (err) { console.log("Could not create instance", err); return; }
|
|
74
|
+
|
|
75
|
+
var instanceId = data.Instances[0].InstanceId;
|
|
76
|
+
console.log("Created instance", instanceId);
|
|
77
|
+
|
|
78
|
+
// Add tags to the instance
|
|
79
|
+
params = {Resources: [instanceId], Tags: [
|
|
80
|
+
{Key: 'Name', Value: instanceName}
|
|
81
|
+
]};
|
|
82
|
+
ec2.createTags(params, function(err) {
|
|
83
|
+
console.log("Tagging instance", err ? "failure" : "success");
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Note that you can add up to 10 tags to an instance, and they can be all added
|
|
89
|
+
in a single call to `createTags`.
|
|
90
|
+
|
|
91
|
+
## Amazon Simple Storage Service (Amazon S3)
|
|
92
|
+
|
|
93
|
+
### Amazon S3: List All of Your Buckets (listBuckets)
|
|
94
|
+
|
|
95
|
+
The following example lists all buckets associated with your AWS account:
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
var s3 = new AWS.S3();
|
|
99
|
+
s3.listBuckets(function(err, data) {
|
|
100
|
+
for (var index in data.Buckets) {
|
|
101
|
+
var bucket = data.Buckets[index];
|
|
102
|
+
console.log("Bucket: ", bucket.Name, ' : ', bucket.CreationDate);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Amazon S3: Create a New Bucket and Object (createBucket, putObject)
|
|
108
|
+
|
|
109
|
+
The following example puts the string 'Hello!' inside the
|
|
110
|
+
object 'myKey' of bucket 'myBucket':
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
var s3 = new AWS.S3({params: {Bucket: 'myBucket', Key: 'myKey'}});
|
|
114
|
+
s3.createBucket(function() {
|
|
115
|
+
s3.putObject({Body: 'Hello!'}, function() {
|
|
116
|
+
console.log("Successfully uploaded data to myBucket/myKey");
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Amazon S3: Streaming Objects to Files on Disk (getObject)
|
|
122
|
+
|
|
123
|
+
You can use the `createReadStream()` method on a request object to
|
|
124
|
+
get a handle to a stream object which supports piping raw HTTP
|
|
125
|
+
body data to a file. This is especially useful when streaming
|
|
126
|
+
objects to streams like filesystem objects. The following example
|
|
127
|
+
shows how you can stream an object from Amazon S3 directly to a file
|
|
128
|
+
on disk:
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
var s3 = new AWS.S3();
|
|
132
|
+
var params = {Bucket: 'myBucket', Key: 'myImageFile.jpg'};
|
|
133
|
+
var file = require('fs').createWriteStream('/path/to/file.jpg');
|
|
134
|
+
s3.getObject(params).createReadStream().pipe(file);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Alternatively, you can register an 'httpData' event listener on
|
|
138
|
+
the request object to access each chunk of data received across
|
|
139
|
+
the wire (as Buffer objects):
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
var s3 = new AWS.S3();
|
|
143
|
+
var params = {Bucket: 'myBucket', Key: 'myImageFile.jpg'};
|
|
144
|
+
var file = require('fs').createWriteStream('/path/to/file.jpg');
|
|
145
|
+
|
|
146
|
+
s3.getObject(params).
|
|
147
|
+
on('httpData', function(chunk) { file.write(chunk); }).
|
|
148
|
+
on('httpDone', function() { file.end(); }).
|
|
149
|
+
send();
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Amazon S3: Getting a pre-signed URL for a getObject operation (getSignedUrl)
|
|
153
|
+
|
|
154
|
+
A pre-signed URL allows you to give one-off access to other users who may not
|
|
155
|
+
have direct access to execute the operations. Pre-signing generates a valid
|
|
156
|
+
URL signed with your credentials that any user can access. By default, the SDK
|
|
157
|
+
sets all URLs to expire within 15 minutes, but this value can be adjusted.
|
|
158
|
+
|
|
159
|
+
To generate a simple pre-signed URL that allows any user to view the contents
|
|
160
|
+
of a private object in a bucket you own, you can use the following call to
|
|
161
|
+
`getSignedUrl()`:
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
var params = {Bucket: 'myBucket', Key: 'myKey'};
|
|
165
|
+
s3.getSignedUrl('getObject', params, function (err, url) {
|
|
166
|
+
console.log("The URL is", url);
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
The `getSignedUrl()` operation can also be called synchronously, when the
|
|
171
|
+
callback is omitted. When it is called without a callback, the return value is
|
|
172
|
+
the pre-signed URL. The above example can be re-written synchronously as:
|
|
173
|
+
|
|
174
|
+
```javascript
|
|
175
|
+
var params = {Bucket: 'myBucket', Key: 'myKey'};
|
|
176
|
+
var url = s3.getSignedUrl('getObject', params);
|
|
177
|
+
console.log("The URL is", url);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Note that this method should only be called synchronously if you can guarantee
|
|
181
|
+
that your credentials are already loaded (or defined statically). In general,
|
|
182
|
+
it is safe to use this method synchronously unless you are using EC2 IAM roles
|
|
183
|
+
or another custom asynchronous credential provider.
|
|
184
|
+
|
|
185
|
+
### Amazon S3: Getting a pre-signed URL for a PUT operation with a specific payload
|
|
186
|
+
|
|
187
|
+
If a Body parameter is passed to the payload of a pre-signed PUT object
|
|
188
|
+
operation and checksums are being computed, the SDK will generate the URL
|
|
189
|
+
with a Content-MD5 representing the expected payload contents. You can use
|
|
190
|
+
this functionality to generate pre-signed PUT operations that require a specific
|
|
191
|
+
payload to be uploaded by the consumer of the URL. To generate such a URL,
|
|
192
|
+
simply provide a Body property to the parameter list:
|
|
193
|
+
|
|
194
|
+
```javascript
|
|
195
|
+
var s3 = new AWS.S3({computeChecksums: true}); // this is the default setting
|
|
196
|
+
var params = {Bucket: 'myBucket', Key: 'myKey', Body: 'EXPECTED CONTENTS'};
|
|
197
|
+
var url = s3.getSignedUrl('putObject', params);
|
|
198
|
+
console.log("The URL is", url);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
You can also omit the Body parameter to generate a URL that allows a user to
|
|
202
|
+
write any contents to the given object:
|
|
203
|
+
|
|
204
|
+
```javascript
|
|
205
|
+
var params = {Bucket: 'myBucket', Key: 'myKey'};
|
|
206
|
+
var url = s3.getSignedUrl('putObject', params);
|
|
207
|
+
console.log("The URL is", url);
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Amazon S3: Controlling Expires time with pre-signed URLs
|
|
211
|
+
|
|
212
|
+
As mentioned above, pre-signed URLs will expire in 15 minutes by default
|
|
213
|
+
when generated by the SDK. This value is adjustable with the `Expires`
|
|
214
|
+
parameter, an integer representing the number of seconds that the URL will be
|
|
215
|
+
valid, and can be set with any call to `getSignedUrl()`:
|
|
216
|
+
|
|
217
|
+
```javascript
|
|
218
|
+
// This URL will expire in one minute (60 seconds)
|
|
219
|
+
var params = {Bucket: 'myBucket', Key: 'myKey', Expires: 60};
|
|
220
|
+
var url = s3.getSignedUrl('getObject', params);
|
|
221
|
+
console.log("The URL is", url);
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Amazon DynamoDB
|
|
225
|
+
|
|
226
|
+
### Amazon DynamoDB: Listing Tables (listTables)
|
|
227
|
+
|
|
228
|
+
The following example will list all tables in a DynamoDB instance:
|
|
229
|
+
|
|
230
|
+
```javascript
|
|
231
|
+
var db = new AWS.DynamoDB();
|
|
232
|
+
db.listTables(function(err, data) {
|
|
233
|
+
console.log(data.TableNames);
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Amazon Glacier
|
|
238
|
+
|
|
239
|
+
### Amazon Glacier: Creating a Vault
|
|
240
|
+
|
|
241
|
+
The following example creates a vault named "YOUR_VAULT_NAME":
|
|
242
|
+
|
|
243
|
+
```javascript
|
|
244
|
+
var glacier = new AWS.Glacier();
|
|
245
|
+
glacier.createVault({vaultName: 'YOUR_VAULT_NAME'}, function(err) {
|
|
246
|
+
if (!err) console.log("Created vault!")
|
|
247
|
+
});
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Amazon Glacier: Uploading an Archive
|
|
251
|
+
|
|
252
|
+
<p class="note"><em>Note: this example assumes you have already created a vault
|
|
253
|
+
named "YOUR_VAULT_NAME".</em>
|
|
254
|
+
</p>
|
|
255
|
+
|
|
256
|
+
The following example will upload a single Buffer object as an entire archive.
|
|
257
|
+
The SDK will automatically compute the tree hash checksum for the data being
|
|
258
|
+
uploaded, though you can override it by passing your own `checksum` parameter.
|
|
259
|
+
|
|
260
|
+
```javascript
|
|
261
|
+
var glacier = new AWS.Glacier(),
|
|
262
|
+
vaultName = 'YOUR_VAULT_NAME',
|
|
263
|
+
buffer = new Buffer(2.5 * 1024 * 1024); // 2.5MB buffer
|
|
264
|
+
|
|
265
|
+
var params = {vaultName: vaultName, body: buffer};
|
|
266
|
+
glacier.uploadArchive(params, function(err, data) {
|
|
267
|
+
if (err) console.log("Error uploading archive!", err);
|
|
268
|
+
else console.log("Archive ID", data.archiveId);
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Amazon Glacier: Multi-part Upload
|
|
273
|
+
|
|
274
|
+
<p class="note">
|
|
275
|
+
<em>Note: this example assumes you have already created a vault
|
|
276
|
+
named "YOUR_VAULT_NAME".</em>
|
|
277
|
+
</p>
|
|
278
|
+
|
|
279
|
+
The following example will create a multi-part upload out of 1MB chunks of a
|
|
280
|
+
Buffer object. Note that a complete SHA-256 tree hash is manually computed
|
|
281
|
+
using the `computeChecksums` method:
|
|
282
|
+
|
|
283
|
+
```javascript
|
|
284
|
+
var glacier = new AWS.Glacier(),
|
|
285
|
+
vaultName = 'YOUR_VAULT_NAME',
|
|
286
|
+
buffer = new Buffer(2.5 * 1024 * 1024), // 2.5MB buffer
|
|
287
|
+
partSize = 1024 * 1024, // 1MB chunks,
|
|
288
|
+
numPartsLeft = Math.ceil(buffer.length / partSize),
|
|
289
|
+
startTime = new Date(),
|
|
290
|
+
params = {vaultName: vaultName, partSize: partSize.toString()};
|
|
291
|
+
|
|
292
|
+
// Compute the complete SHA-256 tree hash so we can pass it
|
|
293
|
+
// to completeMultipartUpload request at the end
|
|
294
|
+
var treeHash = glacier.computeChecksums(buffer).treeHash;
|
|
295
|
+
|
|
296
|
+
// Initiate the multi-part upload
|
|
297
|
+
console.log('Initiating upload to', vaultName);
|
|
298
|
+
glacier.initiateMultipartUpload(params, function (mpErr, multipart) {
|
|
299
|
+
if (mpErr) { console.log('Error!', mpErr.stack); return; }
|
|
300
|
+
console.log("Got upload ID", multipart.uploadId);
|
|
301
|
+
|
|
302
|
+
// Grab each partSize chunk and upload it as a part
|
|
303
|
+
for (var i = 0; i < buffer.length; i += partSize) {
|
|
304
|
+
var end = Math.min(i + partSize, buffer.length),
|
|
305
|
+
partParams = {
|
|
306
|
+
vaultName: vaultName,
|
|
307
|
+
uploadId: multipart.uploadId,
|
|
308
|
+
range: 'bytes ' + i + '-' + (end-1) + '/*',
|
|
309
|
+
body: buffer.slice(i, end)
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
// Send a single part
|
|
313
|
+
console.log('Uploading part', i, '=', partParams.range);
|
|
314
|
+
glacier.uploadMultipartPart(partParams, function(multiErr, mData) {
|
|
315
|
+
if (multiErr) return;
|
|
316
|
+
console.log("Completed part", this.request.params.range);
|
|
317
|
+
if (--numPartsLeft > 0) return; // complete only when all parts uploaded
|
|
318
|
+
|
|
319
|
+
var doneParams = {
|
|
320
|
+
vaultName: vaultName,
|
|
321
|
+
uploadId: multipart.uploadId,
|
|
322
|
+
archiveSize: buffer.length.toString(),
|
|
323
|
+
checksum: treeHash // the computed tree hash
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
console.log("Completing upload...");
|
|
327
|
+
glacier.completeMultipartUpload(doneParams, function(err, data) {
|
|
328
|
+
if (err) {
|
|
329
|
+
console.log("An error occurred while uploading the archive");
|
|
330
|
+
console.log(err);
|
|
331
|
+
} else {
|
|
332
|
+
var delta = (new Date() - startTime) / 1000;
|
|
333
|
+
console.log('Completed upload in', delta, 'seconds');
|
|
334
|
+
console.log('Archive ID:', data.archiveId);
|
|
335
|
+
console.log('Checksum: ', data.checksum);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @title AWS SDK for Node.js
|
|
2
|
+
|
|
3
|
+
# Getting Started with the SDK in Node.js
|
|
4
|
+
|
|
5
|
+
## Installing with npm
|
|
6
|
+
|
|
7
|
+
The preferred way to install the AWS SDK for JavaScript in Node.js is to
|
|
8
|
+
use the [npm](http://npmjs.org) package manager for Node.js. To install the SDK,
|
|
9
|
+
simply type the following into a terminal window:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install aws-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Loading the SDK
|
|
16
|
+
|
|
17
|
+
After you've installed the SDK, you can require the AWS package in your node
|
|
18
|
+
application using `require()`:
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
var AWS = require('aws-sdk');
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Next Steps
|
|
25
|
+
|
|
26
|
+
Now that you have installed and loaded the SDK, continue on to learn how to
|
|
27
|
+
configure and use the SDK to make requests to API operations on services.
|
|
28
|
+
|
|
29
|
+
* {file:node-configuring.md Configuring the SDK}
|
|
30
|
+
* {file:node-services.md Working with Services}
|
|
31
|
+
* {file:node-making-requests.md Making Requests}
|
|
32
|
+
* {file:node-examples.md Common Examples}
|