-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update guide documentation to include browser documentation
- Loading branch information
Showing
17 changed files
with
954 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
--plugin sitemap | ||
-t flasky_sphinx_guide | ||
-p doc-src/templates | ||
--title "AWS SDK for Node.js" | ||
--title "AWS SDK for JavaScript" | ||
--no-highlight | ||
-o doc-guide | ||
--readme doc-src/guide/Introduction.md | ||
--readme doc-src/guide/index.md | ||
- | ||
doc-src/guide/Introduction.md | ||
doc-src/guide/Installing.md | ||
doc-src/guide/Configuring.md | ||
doc-src/guide/Services.md | ||
doc-src/guide/MakingRequests.md | ||
doc-src/guide/Examples.md | ||
UPGRADING.md | ||
doc-src/guide/browser-intro.md | ||
doc-src/guide/browser-configuring.md | ||
doc-src/guide/browser-services.md | ||
doc-src/guide/browser-making-requests.md | ||
doc-src/guide/browser-examples.md | ||
doc-src/guide/browser-building.md | ||
doc-src/guide/node-intro.md | ||
doc-src/guide/node-configuring.md | ||
doc-src/guide/node-services.md | ||
doc-src/guide/node-making-requests.md | ||
doc-src/guide/node-examples.md |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# @title Building the SDK for the Browser | ||
|
||
# Building the SDK for Use in the Browser | ||
|
||
If you are working with the SDK outside of an environment that enforces CORS | ||
in your browser and want access to the full gamut of services provided by the | ||
**AWS SDK for JavaScript**, it is possible to build a custom copy of the SDK | ||
locally by cloning the repository and running the same build tools used to | ||
generate the default hosted version of the SDK. This chapter outlines the steps | ||
to build the SDK on your own with extra services and API versions. | ||
|
||
## Setting Up | ||
|
||
In order to build the SDK, you first need to clone the Git repository containing | ||
the SDK source. These instructions assume you have [Git](http://git-scm.org) and | ||
a version of [Node.js](http://nodejs.org) installed on your machine. | ||
|
||
First, clone the repository from GitHub and cd into the directory: | ||
|
||
```bash | ||
git clone git://github.com/aws/aws-sdk-js | ||
cd aws-sdk-js | ||
``` | ||
|
||
After you have cloned the repository, you need to download the dependency modules | ||
for both the SDK and build tool: | ||
|
||
```bash | ||
npm install --production && cd dist-tools && npm install --production && cd .. | ||
``` | ||
|
||
You should now be able to build a packaged version of the SDK. | ||
|
||
## Building | ||
|
||
The builder tool is found in `dist-tools/browser-builder.js`. You can run | ||
this script by typing: | ||
|
||
```bash | ||
node dist-tools/browser-builder.js > aws-sdk.js | ||
``` | ||
|
||
This will build to the file `aws-sdk.js`. By default this package includes | ||
only the services documented in the {file:browser-services.md Working With Services} | ||
chapter. Building custom services is discussed later in this chapter. Note | ||
also that by default, this file is uncompressed. | ||
|
||
### Minifying Output | ||
|
||
The builder tool can also compress output. To do this, set the `MINIFY` | ||
environment variable like so: | ||
|
||
```bash | ||
MINIFY=1 node dist-tools/browser-builder.js > aws-sdk.js | ||
``` | ||
|
||
### Building Specific Services and API Versions | ||
|
||
#### Selecting Services to Build | ||
|
||
When building via the builder tool, you can select which services you want to | ||
build into the SDK. To select services, specify the names of the services | ||
delimited by commas as arguments to the tool on the command-line. For example, | ||
to build only Amazon S3 and Amazon EC2, use the following command: | ||
|
||
```bash | ||
node dist-tools/browser-builder.js s3,ec2 > aws-sdk-s3-ec2.js | ||
``` | ||
|
||
#### Selecting API Versions | ||
|
||
You can also select specific API versions of services when building | ||
by suffixing the version name after the service identifier. For example, to | ||
build both API versions of Amazon DynamoDB, you could use the following | ||
command: | ||
|
||
```bash | ||
node dist-tools/browser-builder.js dynamodb-2011-12-05,dynamodb-2012-08-10 | ||
``` | ||
|
||
#### Building All Services | ||
|
||
Finally, you can build **all services** (and API versions) by passing "all" | ||
as a command-line argument: | ||
|
||
```bash | ||
node dist-tools/browser-builder.js all > aws-sdk-full.js | ||
``` | ||
|
||
## The Build Server | ||
|
||
The `dist-tools` directory also comes with a utility server that can bundle | ||
and serve the SDK over HTTP. To launch the server, type: | ||
|
||
```bash | ||
node dist-tools/server.js | ||
``` | ||
|
||
You can then access a bundled version of the SDK by hitting either: | ||
|
||
```no-highlight | ||
http://localhost:8080/aws-sdk.js | ||
``` | ||
|
||
or | ||
|
||
```no-highlight | ||
http://localhost:8080/aws-sdk.min.js | ||
``` | ||
|
||
For the uncompressed or compressed versions. | ||
|
||
### Loading Specific Services | ||
|
||
The build server can also bundle custom services by accepting a query string | ||
to the respecitve bundle URLs with the services and API versions to be used. | ||
The syntax for this is the same as the builder tool syntax on the command-line, | ||
but you can also use a conventional query string syntax. An example to load | ||
the DynamoDB 2011-12-05 API version and latest S3 service would look like: | ||
|
||
```no-highlight | ||
http://localhost:8080/aws-sdk.min.js?dynamodb=2011-12-05&s3 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# @title Configuring the SDK in the Browser | ||
|
||
# Configuring the SDK in the Browser | ||
|
||
The SDK requires two settings to be configured in order to make requests, | ||
a region for the service(s) being used, and credentials to access the resources. | ||
|
||
In addition to configuring these settings in the application, you may also have | ||
to configure permissions on the resources you control on AWS. We will discuss | ||
the basics of this at the end of this chapter. | ||
|
||
## The Global Configuration Object (`AWS.config`) | ||
|
||
By default, you can set global configuration by updating the `AWS.config` object with | ||
new settings. The most common settings are: | ||
|
||
1. `credentials` — the credentials object that contains authentication keys. | ||
2. `region` — to set the region for requests | ||
3. `sslEnabled` — whether SSL is enabled or not | ||
4. `maxRetries` — to control the number of retries for a request | ||
5. `logger` — a logger object to write debug information to. Set to `process.stdout` | ||
to get logging information about service requests. | ||
|
||
More configuration settings can be found in the | ||
[API reference documentation](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/frames.html). | ||
|
||
If you have multiple service objects that work in different regions, you can | ||
look at the *Service-Specific Configuration* section below to see how to pass | ||
the region to each individual service. | ||
|
||
### Loading Credentials in the Client's Browser | ||
|
||
<p class="note">Never hard-code credentials to your web application unless the | ||
credentials are scoped to an | ||
<a href="http://aws.amazon.com/iam/faqs/#What_is_a_user">IAM user</a> | ||
with read-only permissions to very specific resources. Remember that when | ||
developing a client-side application in the browser, all source code you | ||
write is downloaded and available to be inspected by your users, so you | ||
should never put secrets inside of your application. | ||
</p> | ||
|
||
Credentials are the most important thing you need to set when using any AWS SDK. | ||
Credentials can be set globally on the `AWS.config` object or per service by | ||
passing the credential information to the service object directly. | ||
|
||
There are a few ways to load credentials. Here they are, in order of | ||
recommendation: | ||
|
||
1. Loaded from environment variables, | ||
2. Loaded from a JSON file on disk, | ||
3. Loaded from EC2 metadata service, | ||
4. Hardcoded in your application | ||
|
||
We recommend you not hard-code your AWS credentials in your application; | ||
however, it is reasonable to temporarily hard-code credential information | ||
in small personal scripts or for testing purposes. | ||
|
||
#### Using Web Identity Federation to Authenticate Users | ||
|
||
TODO | ||
|
||
#### Hard-Coding Credentials | ||
|
||
<p class="note">If you hard-code credentials in your application, ensure that | ||
the credentials you are vending in your application are scoped to an | ||
<a href="http://aws.amazon.com/iam/faqs/#What_is_a_user">IAM user</a> | ||
with read-only permissions to very specific resources. Remember that when | ||
hard-coding credentials in your application, you are allowing all of your | ||
users access to the secret key in plain text. | ||
</p> | ||
|
||
You can hard-code credentials by passing the credential information to the | ||
configuration object using `AWS.config.update()`: | ||
|
||
```js | ||
AWS.config.update({accessKeyId: 'akid', secretAccessKey: 'secret'}); | ||
``` | ||
|
||
### Setting the Region | ||
|
||
The AWS SDK for JavaScript doesn't select the region by default. You can choose | ||
a region by setting the `region` property on the global configuration object, | ||
or by setting it per-service. The following code sets the region globally for | ||
all subsequent service objects: | ||
|
||
```js | ||
AWS.config.region = 'us-west-1'; | ||
``` | ||
|
||
## Service-Specific Configuration | ||
|
||
Occasionally, you might want to apply configuration only to one service. | ||
For instance, you want to use multiple EC2 objects in different regions. | ||
You can do this by passing configuration data directly to the service object | ||
constructor: | ||
|
||
```js | ||
var s3 = new AWS.S3({region: 'ap-southeast-2', maxRetries: 15}); | ||
``` | ||
|
||
Note that the constructor takes all of the same configuration data as the | ||
`AWS.config` object described above, including credential information. | ||
|
||
## Configuring Resources and Permissions | ||
|
||
### CORS | ||
|
||
TODO | ||
|
||
### Permissions for IAM Roles | ||
|
||
WIF INFO HERE |
Oops, something went wrong.