id
stringlengths 14
16
| text
stringlengths 1
2.43k
| source
stringlengths 99
229
|
---|---|---|
ea154d59e480-0 | For example, the home page of an e\-commerce website lets returning customers sign in\. Part of the benefit for customers who sign in is that, after signing in, the site then customizes itself to their particular preferences\. To make this happen:
1. The customer must log in and be validated with their user name and password\.
1. The customer's preferences are requested from a customer database\.
1. The database provides the customer's preferences that are used to customize the site before the page loads\.
If these tasks execute synchronously, then each must finish before the next can start\. The webpage would be unable to finish loading until the customer preferences return from the database\. However, after the database query is sent to the server, receipt of the customer data can be delayed or even fail due to network bottlenecks, exceptionally high database traffic, or a poor mobile device connection\.
To keep the website from freezing under those conditions, call the database asychronously\. After the database call executes, sending your asynchronous request, your code continues to execute as expected\. If you don't properly manage the response of an asynchronous call, your code can attempt to use information it expects back from the database when that data isn't available yet\.
![\[Showing difference between synchronous and asynchronous execution.\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/async-vs-sync.png) | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/making-asynchronous-calls.md |
b869ef50da99-0 | The following tutorials show you how to perform different tasks related to using the AWS SDK for JavaScript\.
**Topics**
+ [Tutorial: Setting Up Node\.js on an Amazon EC2 Instance](setting-up-node-on-ec2-instance.md)
+ [Tutorial: Creating and Using Lambda Functions](using-lambda-functions.md) | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/tutorials.md |
97853b5e47c0-0 | ![\[JavaScript code example that applies to browser execution\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/browsericon.png)
**This browser script example shows:**
+ How to capture scroll progress in a webpage with Amazon Kinesis as an example of streaming page usage metrics for later analysis\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/kinesis-examples-capturing-page-scrolling.md |
6cfb3042ce45-0 | In this example, a simple HTML page simulates the content of a blog page\. As the reader scrolls the simulated blog post, the browser script uses the SDK for JavaScript to record the scroll distance down the page and send that data to Kinesis using the [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Kinesis.html#putRecords-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Kinesis.html#putRecords-property) method of the Kinesis client class\. The streaming data captured by Amazon Kinesis Data Streams can then be processed by Amazon EC2 instances and stored in any of several data stores including Amazon DynamoDB and Amazon Redshift\.
![\[JavaScript in a browser script sending scroll data to Kinesis.\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/kinesis-examples.png) | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/kinesis-examples-capturing-page-scrolling.md |
61bbb3552dda-0 | To set up and run this example, you must first complete these tasks:
+ Create an Kinesis stream\. You need to include the stream's resource ARN in the browser script\. For more information about creating Amazon Kinesis Data Streams, see [Managing Kinesis Streams](https://docs.aws.amazon.com/streams/latest/dev/working-with-streams.html) in the *Amazon Kinesis Data Streams Developer Guide*\.
+ Create an Amazon Cognito identity pool with access enabled for unauthenticated identities\. You need to include the identity pool ID in the code to obtain credentials for the browser script\. For more information about Amazon Cognito identity pools, see [Identity Pools](https://docs.aws.amazon.com/cognito/latest/developerguide/identity-pools.html) in the *Amazon Cognito Developer Guide*\.
+ Create an IAM role whose policy grants permission to submit data to an Kinesis stream\. For more information about creating an IAM role, see [Creating a Role to Delegate Permissions to an AWS Service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html) in the *IAM User Guide*\.
Use the following role policy when creating the IAM role\.
```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"mobileanalytics:PutEvents", | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/kinesis-examples-capturing-page-scrolling.md |
61bbb3552dda-1 | {
"Effect": "Allow",
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:*"
],
"Resource": [
"*"
]
},
{
"Effect": "Allow",
"Action": [
"kinesis:Put*"
],
"Resource": [
"STREAM_RESOURCE_ARN"
]
}
]
}
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/kinesis-examples-capturing-page-scrolling.md |
61a48ae39de7-0 | The HTML for the blog page consists mainly of a series of paragraphs contained within a `<div>` element\. The scrollable height of this `<div>` is used to help calculate how far a reader has scrolled through the content as they read\. The HTML also contains a pair of `<script>` elements\. One of these elements adds the SDK for JavaScript to the page and the other adds the browser script that captures scroll progress on the page and reports it to Kinesis\.
```
<!DOCTYPE html>
<html>
<head>
<title>AWS SDK for JavaScript - Amazon Kinesis Application</title>
</head>
<body>
<div id="BlogContent" style="width: 60%; height: 800px; overflow: auto;margin: auto; text-align: center;">
<div>
<p> | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/kinesis-examples-capturing-page-scrolling.md |
61a48ae39de7-1 | <div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vitae nulla eget nisl bibendum feugiat. Fusce rhoncus felis at ultricies luctus. Vivamus fermentum cursus sem at interdum. Proin vel lobortis nulla. Aenean rutrum odio in tellus semper rhoncus. Nam eu felis ac augue dapibus laoreet vel in erat. Vivamus vitae mollis turpis. Integer sagittis dictum odio. Duis nec sapien diam. In imperdiet sem nec ante laoreet, vehicula facilisis sem placerat. Duis ut metus egestas, ullamcorper neque et, accumsan quam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
</p>
<!-- Additional paragraphs in the blog page appear here -->
</div>
</div>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.283.1.min.js"></script>
<script src="kinesis-example.js"></script>
</body>
</html>
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/kinesis-examples-capturing-page-scrolling.md |
202f3d26dd7e-0 | Obtain the credentials needed to configure the SDK by calling the `CognitoIdentityCredentials` method, providing the Amazon Cognito identity pool ID\. Upon success, create the Kinesis service object in the callback function\.
The following code snippet shows this step\. \(See [Capturing Webpage Scroll Progress Code](kinesis-examples-capturing-page-scrolling-full.md) for the full example\.\)
```
// Configure Credentials to use Cognito
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'IDENTITY_POOL_ID'
});
AWS.config.region = 'REGION';
// We're going to partition Amazon Kinesis records based on an identity.
// We need to get credentials first, then attach our event listeners.
AWS.config.credentials.get(function(err) {
// attach event listener
if (err) {
alert('Error retrieving credentials.');
console.error(err);
return;
}
// create Amazon Kinesis service object
var kinesis = new AWS.Kinesis({
apiVersion: '2013-12-02'
});
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/kinesis-examples-capturing-page-scrolling.md |
1d78cae3b84d-0 | Scroll progress is calculated using the `scrollHeight` and `scrollTop` properties of the `<div>` containing the content of the blog post\. Each scroll record is created in an event listener function for the `scroll` event and then added to an array of records for periodic submission to Kinesis\.
The following code snippet shows this step\. \(See [Capturing Webpage Scroll Progress Code](kinesis-examples-capturing-page-scrolling-full.md) for the full example\.\)
```
// Get the ID of the Web page element.
var blogContent = document.getElementById('BlogContent');
// Get Scrollable height
var scrollableHeight = blogContent.clientHeight;
var recordData = [];
var TID = null;
blogContent.addEventListener('scroll', function(event) {
clearTimeout(TID);
// Prevent creating a record while a user is actively scrolling
TID = setTimeout(function() {
// calculate percentage
var scrollableElement = event.target;
var scrollHeight = scrollableElement.scrollHeight;
var scrollTop = scrollableElement.scrollTop;
var scrollTopPercentage = Math.round((scrollTop / scrollHeight) * 100); | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/kinesis-examples-capturing-page-scrolling.md |
1d78cae3b84d-1 | var scrollTopPercentage = Math.round((scrollTop / scrollHeight) * 100);
var scrollBottomPercentage = Math.round(((scrollTop + scrollableHeight) / scrollHeight) * 100);
// Create the Amazon Kinesis record
var record = {
Data: JSON.stringify({
blog: window.location.href,
scrollTopPercentage: scrollTopPercentage,
scrollBottomPercentage: scrollBottomPercentage,
time: new Date()
}),
PartitionKey: 'partition-' + AWS.config.credentials.identityId
};
recordData.push(record);
}, 100);
});
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/kinesis-examples-capturing-page-scrolling.md |
f39e32b245b7-0 | Once each second, if there are records in the array, those pending records are sent to Kinesis\.
The following code snippet shows this step\. \(See [Capturing Webpage Scroll Progress Code](kinesis-examples-capturing-page-scrolling-full.md) for the full example\.\)
```
// upload data to Amazon Kinesis every second if data exists
setInterval(function() {
if (!recordData.length) {
return;
}
// upload data to Amazon Kinesis
kinesis.putRecords({
Records: recordData,
StreamName: 'NAME_OF_STREAM'
}, function(err, data) {
if (err) {
console.error(err);
}
});
// clear record data
recordData = [];
}, 1000);
});
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/kinesis-examples-capturing-page-scrolling.md |
bab7dc7b2719-0 | This AWS product or service follows the [shared responsibility model](https://aws.amazon.com/compliance/shared-responsibility-model/) through the specific Amazon Web Services \(AWS\) services it supports\. For AWS service security information, see the [AWS service security documentation page](https://docs.aws.amazon.com/security/?id=docs_gateway#aws-security) and [AWS services that are in scope of AWS compliance efforts by compliance program](https://aws.amazon.com/compliance/services-in-scope/)\.
The security and compliance of AWS services is assessed by third\-party auditors as part of multiple AWS compliance programs\. These include SOC, PCI, FedRAMP, HIPAA, and others\. AWS provides a frequently updated list of AWS services in scope of specific compliance programs at [AWS Services in Scope by Compliance Program](https://aws.amazon.com/compliance/services-in-scope/)\.
Third\-party audit reports are available for you to download using AWS Artifact\. For more information, see [Downloading Reports in AWS Artifact](https://docs.aws.amazon.com/artifact/latest/ug/downloading-documents.html)\.
For more information about AWS compliance programs, see [AWS Compliance Programs](https://aws.amazon.com/compliance/programs/)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/compliance-validation.md |
bab7dc7b2719-1 | For more information about AWS compliance programs, see [AWS Compliance Programs](https://aws.amazon.com/compliance/programs/)\.
Your compliance responsibility when using this AWS product or service to access an AWS service is determined by the sensitivity of your data, your organization’s compliance objectives, and applicable laws and regulations\. If your use of an AWS service is subject to compliance with standards such as HIPAA, PCI, or FedRAMP, AWS provides resources to help:
+ [Security and Compliance Quick Start Guides](https://aws.amazon.com/quickstart/?quickstart-all.sort-by=item.additionalFields.updateDate&quickstart-all.sort-order=desc&awsf.quickstart-homepage-filter=categories%23security-identity-compliance) – Deployment guides that discuss architectural considerations and provide steps for deploying security\-focused and compliance\-focused baseline environments on AWS\.
+ [Architecting for HIPAA Security and Compliance Whitepaper](https://d0.awsstatic.com/whitepapers/compliance/AWS_HIPAA_Compliance_Whitepaper.pdf) – A whitepaper that describes how companies can use AWS to create HIPAA\-compliant applications\.
+ [AWS Compliance Resources](https://aws.amazon.com/compliance/resources/) – A collection of workbooks and guides that might apply to your industry and location\.
+ [AWS Config](https://aws.amazon.com/config/) – A service that assesses how well your resource configurations comply with internal practices, industry guidelines, and regulations\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/compliance-validation.md |
bab7dc7b2719-2 | + [AWS Security Hub](https://aws.amazon.com/security-hub/) – A comprehensive view of your security state within AWS that helps you check your compliance with security industry standards and best practices\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/compliance-validation.md |
0b7ff8546434-0 | ![\[JavaScript code example that applies to Node.js execution\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/nodeicon.png)
**This Node\.js code example shows:**
+ How to create and update a rule used to trigger an event\.
+ How to define one or more targets to respond to an event\.
+ How to send events that are matched to targets for handling\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-sending-events.md |
7f63110adf6d-0 | CloudWatch Events delivers a near real\-time stream of system events that describe changes in Amazon Web Services \(AWS\) resources to any of various targets\. Using simple rules, you can match events and route them to one or more target functions or streams\.
In this example, a series of Node\.js modules are used to send events to CloudWatch Events\. The Node\.js modules use the SDK for JavaScript to manage instances using these methods of the `CloudWatchEvents` client class:
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchEvents.html#putRule-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchEvents.html#putRule-property)
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchEvents.html#putTargets-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchEvents.html#putTargets-property)
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchEvents.html#putEvents-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchEvents.html#putEvents-property) | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-sending-events.md |
7f63110adf6d-1 | For more information about CloudWatch Events, see [Adding Events with PutEvents](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/AddEventsPutEvents.html) in the *Amazon CloudWatch Events User Guide*\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-sending-events.md |
864b676ae3bd-0 | To set up and run this example, you must first complete these tasks:
+ Install Node\.js\. For more information about installing Node\.js, see the [Node\.js website](https://nodejs.org)\.
+ Create a shared configurations file with your user credentials\. For more information about providing a shared credentials file, see [Loading Credentials in Node\.js from the Shared Credentials File](loading-node-credentials-shared.md)\.
+ Create an AWS Lambda function using the **hello\-world** blueprint to serve as the target for events\. To learn how, see [ Step 1: Create an AWS Lambda function](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/LogEC2InstanceState.html) in the *Amazon CloudWatch Events User Guide*\.
+ Create an IAM role whose policy grants permission to CloudWatch Events and that includes `events.amazonaws.com` as a trusted entity\. For more information about creating an IAM role, see [ Creating a Role to Delegate Permissions to an AWS Service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html) in the *IAM User Guide*\.
Use the following role policy when creating the IAM role\.
```
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CloudWatchEventsFullAccess", | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-sending-events.md |
864b676ae3bd-1 | "Statement": [
{
"Sid": "CloudWatchEventsFullAccess",
"Effect": "Allow",
"Action": "events:*",
"Resource": "*"
},
{
"Sid": "IAMPassRoleForCloudWatchEvents",
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::*:role/AWS_Events_Invoke_Targets"
}
]
}
```
Use the following trust relationship when creating the IAM role\.
```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "events.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-sending-events.md |
e839f044e1a4-0 | Create a Node\.js module with the file name `cwe_putrule.js`\. Be sure to configure the SDK as previously shown\. To access CloudWatch Events, create an `AWS.CloudWatchEvents` service object\. Create a JSON object containing the parameters needed to specify the new scheduled rule, which include the following:
+ A name for the rule
+ The ARN of the IAM role you created previously
+ An expression to schedule triggering of the rule every five minutes
Call the `putRule` method to create the rule\. The callback returns the ARN of the new or updated rule\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create CloudWatchEvents service object
var cwevents = new AWS.CloudWatchEvents({apiVersion: '2015-10-07'});
var params = {
Name: 'DEMO_EVENT',
RoleArn: 'IAM_ROLE_ARN',
ScheduleExpression: 'rate(5 minutes)',
State: 'ENABLED'
};
cwevents.putRule(params, function(err, data) {
if (err) {
console.log("Error", err); | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-sending-events.md |
e839f044e1a4-1 | if (err) {
console.log("Error", err);
} else {
console.log("Success", data.RuleArn);
}
});
```
To run the example, type the following at the command line\.
```
node cwe_putrule.js
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/cloudwatch/cwe_putrule.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-sending-events.md |
7a8ebcd3cc4e-0 | Create a Node\.js module with the file name `cwe_puttargets.js`\. Be sure to configure the SDK as previously shown\. To access CloudWatch Events, create an `AWS.CloudWatchEvents` service object\. Create a JSON object containing the parameters needed to specify the rule to which you want to attach the target, including the ARN of the Lambda function you created\. Call the `putTargets` method of the `AWS.CloudWatchEvents` service object\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create CloudWatchEvents service object
var cwevents = new AWS.CloudWatchEvents({apiVersion: '2015-10-07'});
var params = {
Rule: 'DEMO_EVENT',
Targets: [
{
Arn: 'LAMBDA_FUNCTION_ARN',
Id: 'myCloudWatchEventsTarget',
}
]
};
cwevents.putTargets(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data);
} | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-sending-events.md |
7a8ebcd3cc4e-1 | } else {
console.log("Success", data);
}
});
```
To run the example, type the following at the command line\.
```
node cwe_puttargets.js
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/cloudwatch/cwe_puttargets.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-sending-events.md |
aa6c92dea6da-0 | Create a Node\.js module with the file name `cwe_putevents.js`\. Be sure to configure the SDK as previously shown\. To access CloudWatch Events, create an `AWS.CloudWatchEvents` service object\. Create a JSON object containing the parameters needed to send events\. For each event, include the source of the event, the ARNs of any resources affected by the event, and details for the event\. Call the `putEvents` method of the `AWS.CloudWatchEvents` service object\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create CloudWatchEvents service object
var cwevents = new AWS.CloudWatchEvents({apiVersion: '2015-10-07'});
var params = {
Entries: [
{
Detail: '{ \"key1\": \"value1\", \"key2\": \"value2\" }',
DetailType: 'appRequestSubmitted',
Resources: [
'RESOURCE_ARN',
],
Source: 'com.company.app'
}
]
};
cwevents.putEvents(params, function(err, data) { | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-sending-events.md |
aa6c92dea6da-1 | }
]
};
cwevents.putEvents(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.Entries);
}
});
```
To run the example, type the following at the command line\.
```
node cwe_putevents.js
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/cloudwatch/cwe_putevents.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-sending-events.md |
6612ca8a848b-0 | The JavaScript API supports most available AWS services\. Each service in the JavaScript API provides a client class with a `send` method that you use to to invoke every API the service supports\. For more information on service classes, operations, and parameters in the JavaScript API, see the [API reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/)\.
When using the SDK in Node\.js, you add the SDK package for each service you need to your application using `require`, which provides support for all current services\. The following example creates an Amazon S3 service object in the `us-west-1` Region\.
```
// Import the Amazon S3 service client
const S3 = require("@aws-sdk/client-s3");
// Create an S3 client in the us-west-1 Region
const s3Client = new S3.S3Client({
region: 'us-west-1'
});
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/creating-and-calling-service-objects.md |
657bae455f3a-0 | When calling a method of a service object, pass parameters in JSON as required by the API\. For example, in Amazon S3, to get an object for a specified bucket and key, pass the following parameters to the `GetObjectCommand` method\. For more information about passing JSON parameters, see [Working with JSON](working-with-json.md)\.
```
s3Client.send(new GetObjectCommand(
{Bucket: 'bucketName', Key: 'keyName'}
))
```
You can also call the `GetObject` method from the `S3Client` directly:
```
s3Client.getObject(
{Bucket: 'bucketName', Key: 'keyName'}
))
```
For more information about Amazon S3 parameters, see [Class: AWS\.S3](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html) in the API reference\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/creating-and-calling-service-objects.md |
7cbcaa7ce421-0 | This topic describes special considerations for using the AWS SDK for JavaScript in browser scripts\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/browser-js-considerations.md |
773c8837021c-0 | Cross\-origin resource sharing, or CORS, is a security feature of modern web browsers\. It enables web browsers to negotiate which domains can make requests of external websites or services\.
CORS is an important consideration when developing browser applications with the AWS SDK for JavaScript because most requests to resources are sent to an external domain, such as the endpoint for a web service\. If your JavaScript environment enforces CORS security, you must configure CORS with the service\.
CORS determines whether to allow sharing of resources in a cross\-origin request based on the following:
+ The specific domain that makes the request
+ The type of HTTP request being made \(GET, PUT, POST, DELETE and so on\) | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/browser-js-considerations.md |
d3da011c0f8d-0 | In the simplest case, your browser script makes a GET request for a resource from a server in another domain\. Depending on the CORS configuration of that server, if the request is from a domain that's authorized to submit GET requests, the cross\-origin server responds by returning the requested resource\.
If either the requesting domain or the type of HTTP request is not authorized, the request is denied\. However, CORS makes it possible to preflight the request before actually submitting it\. In this case, a preflight request is made in which the `OPTIONS` access request operation is sent\. If the cross\-origin server's CORS configuration grants access to the requesting domain, the server sends back a preflight response that lists all the HTTP request types that the requesting domain can make on the requested resource\.
![\[Process flow for CORS requests\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/cors-overview.png) | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/browser-js-considerations.md |
e8ae2e2e2fbb-0 | Amazon S3 buckets require CORS configuration before you can perform operations on them\. In some JavaScript environments CORS may not be enforced and therefore configuring CORS is unnecessary\. For example, if you host your application from an Amazon S3 bucket and access resources from `*.s3.amazonaws.com` or some other specific endpoint, your requests won't access an external domain\. Therefore, this configuration doesn't require CORS\. In this case, CORS is still used for services | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/browser-js-considerations.md |
e8ae2e2e2fbb-1 | this case, CORS is still used for services other than Amazon S3\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/browser-js-considerations.md |
5a1d8fdeeafa-0 | You can configure an Amazon S3 bucket to use CORS in the Amazon S3 console\.
1. In the Amazon S3 console, find the bucket you want to configure and select its check box\.
1. In the pane that opens, choose **Permissions**\.
1. On the **Permission** tab, choose **CORS Configuration**\.
1. Type your CORS configuration in the **CORS Configuration Editor**, and then choose **Save**\.
A CORS configuration is an XML file that contains a series of rules within a `<CORSRule>`\. A configuration can have up to 100 rules\. A rule is defined by one of the following tags:
+ `<AllowedOrigin>` – Specifies domain origins that you allow to make cross\-domain requests\.
+ `<AllowedMethod>` – Specifies a type of request you allow \(GET, PUT, POST, DELETE, HEAD\) in cross\-domain requests\.
+ `<AllowedHeader>` – Specifies the headers allowed in a preflight request\.
For example configurations, see [How Do I Configure CORS on My Bucket?](https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html#how-do-i-enable-cors) in the *Amazon Simple Storage Service Developer Guide*\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/browser-js-considerations.md |
d0f11b16d64b-0 | The following CORS configuration example allows a user to view, add, remove, or update objects inside of a bucket from the domain `example.org`\. However, we recommend that you scope the `<AllowedOrigin>` to the domain of your website\. You can specify `"*"` to allow any origin\.
```
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>https://example.org</AllowedOrigin>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
<ExposeHeader>ETag</ExposeHeader>
<ExposeHeader>x-amz-meta-custom-header</ExposeHeader>
</CORSRule>
</CORSConfiguration>
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/browser-js-considerations.md |
d0f11b16d64b-1 | </CORSRule>
</CORSConfiguration>
```
This configuration does not authorize the user to perform actions on the bucket\. It enables the browser's security model to allow a request to Amazon S3\. Permissions must be configured through bucket permissions or IAM role permissions\.
You can use `ExposeHeader` to let the SDK read response headers returned from Amazon S3\. For example, if you want to read the `ETag` header from a `PUT` or multipart upload, you need to include the `ExposeHeader` tag in your configuration, as shown in the previous example\. The SDK can only access headers that are exposed through CORS configuration\. If you set metadata on the object, values are returned as headers with the prefix `x-amz-meta-`, such as `x-amz-meta-my-custom-header`, and must also be exposed in the same way\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/browser-js-considerations.md |
d8f52e8e00ae-0 | An AWS Region is a named set of AWS resources in the same geographical area\. An example of a Region is `us-east-1`, which is the US East \(N\. Virginia\) Region\. You specify a Region when creating a service client in the SDK for JavaScript so that the SDK accesses the service in that Region\. Some services are available only in specific Regions\.
The SDK for JavaScript doesn't select a Region by default\. However, you can set the Region using an environment variable, a shared `config` file, or the global configuration object\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/setting-region.md |
762c221074e2-0 | When you instantiate a service object, you can specify the Region for that resource as part of the client class constructor, as shown here\.
```
const s3Client = new S3.S3Client({region: 'us-west-2'})
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/setting-region.md |
e9b35f1c0a68-0 | You can set the Region using the `AWS_REGION` environment variable\. If you define this variable, the SDK for JavaScript reads it and uses it\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/setting-region.md |
dcfd6577a6cc-0 | Much like the shared credentials file lets you store credentials for use by the SDK, you can keep your Region and other configuration settings in a shared file named `config` that is used by SDKs\. If the `AWS_SDK_LOAD_CONFIG` environment variable has been set to a truthy value, the SDK for JavaScript automatically searches for a `config` file when it loads\. Where you save the `config` file depends on your operating system:
+ Linux, macOS, or Unix users: `~/.aws/config`
+ Windows users: `C:\Users\USER_NAME\.aws\config`
If you don't already have a shared `config` file, you can create one in the designated directory\. In the following example, the `config` file sets both the Region and the output format\.
```
[default]
region=us-west-2
output=json
```
For more information about using shared config and credentials files, see [Loading Credentials in Node\.js from the Shared Credentials File](loading-node-credentials-shared.md) or [Configuration and Credential Files](https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html) in the *AWS Command Line Interface User Guide*\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/setting-region.md |
182275a06dbb-0 | The order of precedence for Region setting is as follows:
1. If a Region is passed to a client class constructor, that Region is used\.
1. Otherwise, if the `AWS_REGION` environment variable is a [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) value, that Region is used\.
1. Otherwise, if the `AMAZON_REGION` environment variable is a truthy value, that Region is used\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/setting-region.md |
8e5b8e54195f-0 | This section contains the full HTML and JavaScript code for the example in which photos are uploaded to an Amazon S3 photo album\. See the [parent section](s3-example-photo-album.md) for details and prerequisites\.
The HTML for the example:
```
<!DOCTYPE html>
<html>
<head>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.283.1.min.js"></script>
<script src="./app.js"></script>
<script>
function getHtml(template) {
return template.join('\n');
}
listAlbums();
</script>
</head>
<body>
<h1>My Photo Albums App</h1>
<div id="app"></div>
</body>
</html>
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/s3/s3_photoExample.html)\.
The browser script code for the example:
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/s3-example-photo-album-full.md |
8e5b8e54195f-1 | The browser script code for the example:
```
var albumBucketName = "BUCKET_NAME";
var bucketRegion = "REGION";
var IdentityPoolId = "IDENTITY_POOL_ID";
AWS.config.update({
region: bucketRegion,
credentials: new AWS.CognitoIdentityCredentials({
IdentityPoolId: IdentityPoolId
})
});
var s3 = new AWS.S3({
apiVersion: "2006-03-01",
params: { Bucket: albumBucketName }
});
function listAlbums() {
s3.listObjects({ Delimiter: "/" }, function(err, data) {
if (err) {
return alert("There was an error listing your albums: " + err.message);
} else {
var albums = data.CommonPrefixes.map(function(commonPrefix) {
var prefix = commonPrefix.Prefix;
var albumName = decodeURIComponent(prefix.replace("/", ""));
return getHtml([
"<li>",
"<span onclick=\"deleteAlbum('" + albumName + "')\">X</span>", | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/s3-example-photo-album-full.md |
8e5b8e54195f-2 | "<span onclick=\"deleteAlbum('" + albumName + "')\">X</span>",
"<span onclick=\"viewAlbum('" + albumName + "')\">",
albumName,
"</span>",
"</li>"
]);
});
var message = albums.length
? getHtml([
"<p>Click on an album name to view it.</p>",
"<p>Click on the X to delete the album.</p>"
])
: "<p>You do not have any albums. Please Create album.";
var htmlTemplate = [
"<h2>Albums</h2>",
message,
"<ul>",
getHtml(albums),
"</ul>",
"<button onclick=\"createAlbum(prompt('Enter Album Name:'))\">",
"Create New Album",
"</button>"
];
document.getElementById("app").innerHTML = getHtml(htmlTemplate);
}
});
}
function createAlbum(albumName) { | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/s3-example-photo-album-full.md |
8e5b8e54195f-3 | }
});
}
function createAlbum(albumName) {
albumName = albumName.trim();
if (!albumName) {
return alert("Album names must contain at least one non-space character.");
}
if (albumName.indexOf("/") !== -1) {
return alert("Album names cannot contain slashes.");
}
var albumKey = encodeURIComponent(albumName) + "/";
s3.headObject({ Key: albumKey }, function(err, data) {
if (!err) {
return alert("Album already exists.");
}
if (err.code !== "NotFound") {
return alert("There was an error creating your album: " + err.message);
}
s3.putObject({ Key: albumKey }, function(err, data) {
if (err) {
return alert("There was an error creating your album: " + err.message);
}
alert("Successfully created album.");
viewAlbum(albumName);
});
});
}
function viewAlbum(albumName) { | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/s3-example-photo-album-full.md |
8e5b8e54195f-4 | });
});
}
function viewAlbum(albumName) {
var albumPhotosKey = encodeURIComponent(albumName) + "//";
s3.listObjects({ Prefix: albumPhotosKey }, function(err, data) {
if (err) {
return alert("There was an error viewing your album: " + err.message);
}
// 'this' references the AWS.Response instance that represents the response
var href = this.request.httpRequest.endpoint.href;
var bucketUrl = href + albumBucketName + "/";
var photos = data.Contents.map(function(photo) {
var photoKey = photo.Key;
var photoUrl = bucketUrl + encodeURIComponent(photoKey);
return getHtml([
"<span>",
"<div>",
'<img style="width:128px;height:128px;" src="' + photoUrl + '"/>',
"</div>",
"<div>",
"<span onclick=\"deletePhoto('" +
albumName +
"','" +
photoKey +
"')\">", | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/s3-example-photo-album-full.md |
8e5b8e54195f-5 | albumName +
"','" +
photoKey +
"')\">",
"X",
"</span>",
"<span>",
photoKey.replace(albumPhotosKey, ""),
"</span>",
"</div>",
"</span>"
]);
});
var message = photos.length
? "<p>Click on the X to delete the photo</p>"
: "<p>You do not have any photos in this album. Please add photos.</p>";
var htmlTemplate = [
"<h2>",
"Album: " + albumName,
"</h2>",
message,
"<div>",
getHtml(photos),
"</div>",
'<input id="photoupload" type="file" accept="image/*">',
'<button id="addphoto" onclick="addPhoto(\'' + albumName + "')\">",
"Add Photo",
"</button>",
'<button onclick="listAlbums()">',
"Back To Albums", | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/s3-example-photo-album-full.md |
8e5b8e54195f-6 | '<button onclick="listAlbums()">',
"Back To Albums",
"</button>"
];
document.getElementById("app").innerHTML = getHtml(htmlTemplate);
});
}
function addPhoto(albumName) {
var files = document.getElementById("photoupload").files;
if (!files.length) {
return alert("Please choose a file to upload first.");
}
var file = files[0];
var fileName = file.name;
var albumPhotosKey = encodeURIComponent(albumName) + "//";
var photoKey = albumPhotosKey + fileName;
// Use S3 ManagedUpload class as it supports multipart uploads
var upload = new AWS.S3.ManagedUpload({
params: {
Bucket: albumBucketName,
Key: photoKey,
Body: file,
ACL: "public-read"
}
});
var promise = upload.promise();
promise.then(
function(data) {
alert("Successfully uploaded photo.");
viewAlbum(albumName);
}, | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/s3-example-photo-album-full.md |
8e5b8e54195f-7 | function(data) {
alert("Successfully uploaded photo.");
viewAlbum(albumName);
},
function(err) {
return alert("There was an error uploading your photo: ", err.message);
}
);
}
function deletePhoto(albumName, photoKey) {
s3.deleteObject({ Key: photoKey }, function(err, data) {
if (err) {
return alert("There was an error deleting your photo: ", err.message);
}
alert("Successfully deleted photo.");
viewAlbum(albumName);
});
}
function deleteAlbum(albumName) {
var albumKey = encodeURIComponent(albumName) + "/";
s3.listObjects({ Prefix: albumKey }, function(err, data) {
if (err) {
return alert("There was an error deleting your album: ", err.message);
}
var objects = data.Contents.map(function(object) {
return { Key: object.Key };
});
s3.deleteObjects(
{
Delete: { Objects: objects, Quiet: true }
}, | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/s3-example-photo-album-full.md |
8e5b8e54195f-8 | s3.deleteObjects(
{
Delete: { Objects: objects, Quiet: true }
},
function(err, data) {
if (err) {
return alert("There was an error deleting your album: ", err.message);
}
alert("Successfully deleted album.");
listAlbums();
}
);
});
}
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/s3/s3_photoExample.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/s3-example-photo-album-full.md |
a3cc60947e64-0 | This topic is part of a larger tutorial about using the AWS SDK for JavaScript with AWS Lambda functions\. To start at the beginning of the tutorial, see [Tutorial: Creating and Using Lambda Functions](using-lambda-functions.md)\.
In this task, you will focus on creating an Amazon Cognito identity pool used to authenticate your browser script code, and then editing the browser script accordingly\.
![\[Preparing the browser JavaScript\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/browser-script.png)![\[Preparing the browser JavaScript\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/)![\[Preparing the browser JavaScript\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/) | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-browser-script.md |
83bb3132c8b6-0 | The JavaScript code in the browser script needs authentication to access AWS services\. Within webpages, you typically use Amazon Cognito Identity to do this authentication\. First, create an Amazon Cognito identity pool\.
**To create and prepare an Amazon Cognito identity pool for the browser script**
1. Open the [Amazon Cognito console](https://console.aws.amazon.com/cognito/), choose **Manage Federated Identities**, and then choose **Create new identity pool**\.
1. Enter a name for your identity pool, choose **enable access to unauthenticated identities**, and then choose **Create Pool**\.
1. Choose **View Details** to display details on both the authenticated and unauthenticated IAM roles created for this identity pool\.
1. In the summary for the unauthenticated role, choose **View Policy Document** to display the current role policy\.
1. Choose **Edit** to change the role policy, and then choose **Ok**\.
1. In the text box, edit the policy to insert this `"lambda:InvokeFunction"` action, so the full policy becomes the following\.
```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"lambda:InvokeFunction",
"mobileanalytics:PutEvents", | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-browser-script.md |
83bb3132c8b6-1 | "Action": [
"lambda:InvokeFunction",
"mobileanalytics:PutEvents",
"cognito-sync:*"
],
"Resource": [
"*"
]
}
]
}
```
1. Choose **Allow**\.
1. Choose **Sample code** in the side menu\. Make a note of the identity pool ID, shown in red text in the console\.
![\[Preparing an Amazon Cognito identity pool for the browser script\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/identity-pool-id.png)![\[Preparing an Amazon Cognito identity pool for the browser script\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/)![\[Preparing an Amazon Cognito identity pool for the browser script\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/) | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-browser-script.md |
a7190466b2ef-0 | Next, update the browser script to include the Amazon Cognito identity pool ID created for this application\.
**To prepare the browser script in the webpage**
1. Open `index.html` in the `MyLambdaApp` folder in a text editor\.
1. Find this line of code in the browser script\.
`AWS.config.credentials = new AWS.CognitoIdentityCredentials({IdentityPoolId: 'IDENTITY_POOL_ID'});`
1. Replace `IDENTITY_POOL_ID` with the identity pool ID you obtained previously\.
1. Save `index.html`\.
Click **next** to continue the tutorial\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-browser-script.md |
f12d9b58b9e3-0 | ![\[JavaScript code example that applies to Node.js execution\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/nodeicon.png)
**This Node\.js code example shows:**
+ How to use a queue to receive and hold messages from other queues that the queues can't process\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-dead-letter-queues.md |
eec1f2b876b3-0 | A dead letter queue is one that other \(source\) queues can target for messages that can't be processed successfully\. You can set aside and isolate these messages in the dead letter queue to determine why their processing did not succeed\. You must individually configure each source queue that sends messages to a dead letter queue\. Multiple queues can target a single dead letter queue\.
In this example, a Node\.js module is used to route messages to a dead letter queue\. The Node\.js module uses the SDK for JavaScript to use dead letter queues using this method of the `AWS.SQS` client class:
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#setQueueAttributes-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#setQueueAttributes-property)
For more information about Amazon SQS dead letter queues, see [Using Amazon SQS Dead Letter Queues](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html) in the *Amazon Simple Queue Service Developer Guide*\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-dead-letter-queues.md |
b1a46f92baf8-0 | To set up and run this example, you must first complete these tasks:
+ Install Node\.js\. For more information about installing Node\.js, see the [Node\.js website](https://nodejs.org)\.
+ Create a shared configurations file with your user credentials\. For more information about providing a shared credentials file, see [Loading Credentials in Node\.js from the Shared Credentials File](loading-node-credentials-shared.md)\.
+ Create an Amazon SQS queue to serve as a dead letter queue\. For an example of creating a queue, see [Using Queues in Amazon SQS](sqs-examples-using-queues.md)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-dead-letter-queues.md |
27a4589b8f0c-0 | After you create a queue to act as a dead letter queue, you must configure the other queues that route unprocessed messages to the dead letter queue\. To do this, specify a redrive policy that identifies the queue to use as a dead letter queue and the maximum number of receives by individual messages before they are routed to the dead letter queue\.
Create a Node\.js module with the file name `sqs_deadletterqueue.js`\. Be sure to configure the SDK as previously shown\. To access Amazon SQS, create an `AWS.SQS` service object\. Create a JSON object containing the parameters needed to update queue attributes, including the `RedrivePolicy` parameter that specifies both the ARN of the dead letter queue, as well as the value of `maxReceiveCount`\. Also specify the URL source queue you want to configure\. Call the `setQueueAttributes` method\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create the SQS service object
var sqs = new AWS.SQS({apiVersion: '2012-11-05'});
var params = {
Attributes: { | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-dead-letter-queues.md |
27a4589b8f0c-1 | var params = {
Attributes: {
"RedrivePolicy": "{\"deadLetterTargetArn\":\"DEAD_LETTER_QUEUE_ARN\",\"maxReceiveCount\":\"10\"}",
},
QueueUrl: "SOURCE_QUEUE_URL"
};
sqs.setQueueAttributes(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data);
}
});
```
To run the example, type the following at the command line\.
```
node sqs_deadletterqueue.js
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/sqs/sqs_deadletterqueue.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-dead-letter-queues.md |
2b06907c6194-0 | There are several ways in Node\.js to supply your credentials to the SDK\. Some of these are more secure and others afford greater convenience while developing an application\. When obtaining credentials in Node\.js, be careful about relying on more than one source such as an environment variable and a JSON file you load\. You can change the permissions under which your code runs without realizing the change has happened\.
Here are the ways you can supply your credentials in order of recommendation:
1. Loaded from AWS Identity and Access Management \(IAM\) roles for Amazon EC2
1. Loaded from the shared credentials file \(`~/.aws/credentials`\)
1. Loaded from environment variables
1. Loaded from a JSON file on disk
1. Other credential\-provider classes provided by the JavaScript SDK
If more than one credential source is available to the SDK, the default precedence of selection is as follows:
1. Credentials that are explicitly set through the service\-client constructor
1. Environment variables
1. The shared credentials file
1. Credentials loaded from the Amazon ECS credentials provider \(if applicable\)
1. Credentials that are obtained by using a credential process specified in the shared AWS config file or the shared credentials file\. For more information, see [Loading Credentials in Node\.js using a Configured Credential Process](loading-node-credentials-configured-credential-process.md)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/setting-credentials-node.md |
2b06907c6194-1 | 1. Credentials loaded from AWS Identity and Access Management \(IAM\) using the credentials provider of the Amazon EC2 instance \(if configured in the instance metadata\)
For more information, see [Class: AWS\.Credentials](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Credentials.html) and [Class: AWS\.CredentialProviderChain](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CredentialProviderChain.html) in the API reference\.
**Warning**
While it is possible to do so, we do not recommend hard\-coding your AWS credentials in your application\. Hard\-coding credentials poses a risk of exposing your access key ID and secret access key\.
The topics in this section describe how to load credentials into Node\.js\.
**Topics**
+ [Loading Credentials in Node\.js from IAM Roles for Amazon EC2](loading-node-credentials-iam.md)
+ [Loading Credentials for a Node\.js Lambda Function](loading-node-credentials-lambda.md)
+ [Loading Credentials in Node\.js from the Shared Credentials File](loading-node-credentials-shared.md)
+ [Loading Credentials in Node\.js from Environment Variables](loading-node-credentials-environment.md) | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/setting-credentials-node.md |
2b06907c6194-2 | + [Loading Credentials in Node\.js from Environment Variables](loading-node-credentials-environment.md)
+ [Loading Credentials in Node\.js using a Configured Credential Process](loading-node-credentials-configured-credential-process.md) | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/setting-credentials-node.md |
2135c0da3a40-0 | Calls to API methods in the SDK for JavaScript are made to service endpoint URIs\. By default, these endpoints are built from the Region you have configured for your code\. However, there are situations in which you need to specify a custom endpoint for your API calls\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/specifying-endpoints.md |
d882b960bb0b-0 | Endpoint values should be a string in the following format\.
**`https://{service}.{region}.amazonaws.com`** | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/specifying-endpoints.md |
d04a0108b06c-0 | The `ap-northeast-3` Region in Japan is not returned by Region enumeration APIs, such as [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeRegions-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeRegions-property)\. To define endpoints for this Region, follow the format described previously\. So the Amazon EC2 endpoint for this Region would be the following\.
`ec2.ap-northeast-3.amazonaws.com` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/specifying-endpoints.md |
cc9077dcd9ce-0 | You need to create a custom endpoint to use with AWS Elemental MediaConvert\. Each customer account is assigned its own endpoint, which you must use\. Here is an example of how to use a custom endpoint with MediaConvert\.
```
// Create MediaConvert service object using custom endpoint
const MediaConvertClient = require("@aws-sdk/client-mediaconvert/MediaConvertClient")
const mcClient = new MediaConvertClient({endpoint: 'https://abcd1234.mediaconvert.us-west-1.amazonaws.com'})
const params = {Id: 'job_ID'}
const command = new GetJobCommand(params)
mediaConvert.send(command).then(data => {
console.log(data)
}).catch(err => {
console.log(err, err.stack)
})
```
To get your account API endpoint, see [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/MediaConvert.html#describeEndpoints-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/MediaConvert.html#describeEndpoints-property) in the API Reference\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/specifying-endpoints.md |
cc9077dcd9ce-1 | Make sure you specify the same Region in your code as the Region in the custom endpoint URI\. A mismatch between the Region setting and the custom endpoint URI can cause API calls to fail\.
For more information on MediaConvert, see the [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/MediaConvert.html](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/MediaConvert.html) class in the API Reference or the *[AWS Elemental MediaConvert User Guide](https://docs.aws.amazon.com/mediaconvert/latest/ug/)*\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/specifying-endpoints.md |
4d11f3b548a5-0 | ![\[JavaScript code example that applies to Node.js execution\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/nodeicon.png)
**This Node\.js code example shows:**
+ How to get a list of all of your message queues
+ How to obtain the URL for a particular queue
+ How to create and delete queues | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-using-queues.md |
0c88c7a1ce99-0 | In this example, a series of Node\.js modules are used to work with queues\. The Node\.js modules use the SDK for JavaScript to enable queues to call the following methods of the `AWS.SQS` client class:
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#listQueues-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#listQueues-property)
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#createQueue-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#createQueue-property)
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#getQueueUrl-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#getQueueUrl-property)
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#deleteQueue-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#deleteQueue-property) | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-using-queues.md |
0c88c7a1ce99-1 | For more information about Amazon SQS messages, see [How Queues Work](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-how-it-works.html) in the *Amazon Simple Queue Service Developer Guide*\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-using-queues.md |
37c4fe2f6876-0 | To set up and run this example, you must first complete these tasks:
+ Install Node\.js\. For more information about installing Node\.js, see the [Node\.js website](https://nodejs.org)\.
+ Create a shared configurations file with your user credentials\. For more information about providing a shared credentials file, see [Loading Credentials in Node\.js from the Shared Credentials File](loading-node-credentials-shared.md)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-using-queues.md |
d404d1cbd6cc-0 | Create a Node\.js module with the file name `sqs_listqueues.js`\. Be sure to configure the SDK as previously shown\. To access Amazon SQS, create an `AWS.SQS` service object\. Create a JSON object containing the parameters needed to list your queues, which by default is an empty object\. Call the `listQueues` method to retrieve the list of queues\. The callback returns the URLs of all queues\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create an SQS service object
var sqs = new AWS.SQS({apiVersion: '2012-11-05'});
var params = {};
sqs.listQueues(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.QueueUrls);
}
});
```
To run the example, type the following at the command line\.
```
node sqs_listqueues.js
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-using-queues.md |
d404d1cbd6cc-1 | ```
node sqs_listqueues.js
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/sqs/sqs_listqueues.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-using-queues.md |
d913a63dfa23-0 | Create a Node\.js module with the file name `sqs_createqueue.js`\. Be sure to configure the SDK as previously shown\. To access Amazon SQS, create an `AWS.SQS` service object\. Create a JSON object containing the parameters needed to list your queues, which must include the name for the queue created\. The parameters can also contain attributes for the queue, such as the number of seconds for which message delivery is delayed or the number of seconds to retain a received message\. Call the `createQueue` method\. The callback returns the URL of the created queue\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create an SQS service object
var sqs = new AWS.SQS({apiVersion: '2012-11-05'});
var params = {
QueueName: 'SQS_QUEUE_NAME',
Attributes: {
'DelaySeconds': '60',
'MessageRetentionPeriod': '86400'
}
};
sqs.createQueue(params, function(err, data) {
if (err) {
console.log("Error", err);
} else { | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-using-queues.md |
d913a63dfa23-1 | if (err) {
console.log("Error", err);
} else {
console.log("Success", data.QueueUrl);
}
});
```
To run the example, type the following at the command line\.
```
node sqs_createqueue.js
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/sqs/sqs_createqueue.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-using-queues.md |
c4e51a84c384-0 | Create a Node\.js module with the file name `sqs_getqueueurl.js`\. Be sure to configure the SDK as previously shown\. To access Amazon SQS, create an `AWS.SQS` service object\. Create a JSON object containing the parameters needed to list your queues, which must include the name of the queue whose URL you want\. Call the `getQueueUrl` method\. The callback returns the URL of the specified queue\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create an SQS service object
var sqs = new AWS.SQS({apiVersion: '2012-11-05'});
var params = {
QueueName: 'SQS_QUEUE_NAME'
};
sqs.getQueueUrl(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.QueueUrl);
}
});
```
To run the example, type the following at the command line\.
```
node sqs_getqueueurl.js | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-using-queues.md |
c4e51a84c384-1 | To run the example, type the following at the command line\.
```
node sqs_getqueueurl.js
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/sqs/sqs_getqueueurl.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-using-queues.md |
3afcd0d32566-0 | Create a Node\.js module with the file name `sqs_deletequeue.js`\. Be sure to configure the SDK as previously shown\. To access Amazon SQS, create an `AWS.SQS` service object\. Create a JSON object containing the parameters needed to delete a queue, which consists of the URL of the queue you want to delete\. Call the `deleteQueue` method\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create an SQS service object
var sqs = new AWS.SQS({apiVersion: '2012-11-05'});
var params = {
QueueUrl: 'SQS_QUEUE_URL'
};
sqs.deleteQueue(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data);
}
});
```
To run the example, type the following at the command line\.
```
node sqs_deletequeue.js
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-using-queues.md |
3afcd0d32566-1 | ```
node sqs_deletequeue.js
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/sqs/sqs_deletequeue.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-using-queues.md |
87aaf07f2362-0 | This AWS product or service follows the [shared responsibility model](https://aws.amazon.com/compliance/shared-responsibility-model/) through the specific Amazon Web Services \(AWS\) services it supports\. For AWS service security information, see the [AWS service security documentation page](https://docs.aws.amazon.com/security/?id=docs_gateway#aws-security) and [AWS services that are in scope of AWS compliance efforts by compliance program](https://aws.amazon.com/compliance/services-in-scope/)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/infrastructure-security.md |
871413c4c78c-0 | ![\[JavaScript code example that applies to Node.js execution\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/nodeicon.png)
**This Node\.js code example shows:**
+ How to manage the access keys of your users\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
f3785e205791-0 | Users need their own access keys to make programmatic calls to AWS from the SDK for JavaScript\. To fill this need, you can create, modify, view, or rotate access keys \(access key IDs and secret access keys\) for IAM users\. By default, when you create an access key, its status is `Active`, which means the user can use the access key for API calls\.
In this example, a series of Node\.js modules are used manage access keys in IAM\. The Node\.js modules use the SDK for JavaScript to manage IAM access keys using these methods of the `AWS.IAM` client class:
+ [createAccessKey](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/IAM.html#createAccessKey-property)
+ [listAccessKeys](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/IAM.html#listAccessKeys-property)
+ [getAccessKeyLastUsed](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/IAM.html#getAccessKeyLastUsed-property)
+ [updateAccessKey](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/IAM.html#updateAccessKey-property) | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
f3785e205791-1 | + [deleteAccessKey](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/IAM.html#deleteAccessKey-property)
For more information about IAM access keys, see [Access Keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) in the *IAM User Guide*\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
45995e193d0f-0 | To set up and run this example, you must first complete these tasks:
+ Install Node\.js\. For more information about installing Node\.js, see the [Node\.js website](https://nodejs.org)\.
+ Create a shared configurations file with your user credentials\. For more information about providing a shared credentials file, see [Loading Credentials in Node\.js from the Shared Credentials File](loading-node-credentials-shared.md)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
075db46a1577-0 | Create a Node\.js module with the file name `iam_createaccesskeys.js`\. Be sure to configure the SDK as previously shown\. To access IAM, create an `AWS.IAM` service object\. Create a JSON object containing the parameters needed to create new access keys, which includes IAM user's name\. Call the `createAccessKey` method of the `AWS.IAM` service object\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create the IAM service object
var iam = new AWS.IAM({apiVersion: '2010-05-08'});
iam.createAccessKey({UserName: 'IAM_USER_NAME'}, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.AccessKey);
}
});
```
To run the example, type the following at the command line\. Be sure to pipe the returned data to a text file in order not to lose the secret key, which can only be provided once\.
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
075db46a1577-1 | ```
node iam_createaccesskeys.js > newuserkeys.txt
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/iam/iam_createaccesskeys.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
4297bd5aba57-0 | Create a Node\.js module with the file name `iam_listaccesskeys.js`\. Be sure to configure the SDK as previously shown\. To access IAM, create an `AWS.IAM` service object\. Create a JSON object containing the parameters needed to retrieve the user's access keys, which includes IAM user's name and optionally the maximum number of access key pairs you want listed\. Call the `listAccessKeys` method of the `AWS.IAM` service object\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create the IAM service object
var iam = new AWS.IAM({apiVersion: '2010-05-08'});
var params = {
MaxItems: 5,
UserName: 'IAM_USER_NAME'
};
iam.listAccessKeys(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data);
}
});
```
To run the example, type the following at the command line\.
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
4297bd5aba57-1 | });
```
To run the example, type the following at the command line\.
```
node iam_listaccesskeys.js
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/iam/iam_listaccesskeys.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
447732b34abe-0 | Create a Node\.js module with the file name `iam_accesskeylastused.js`\. Be sure to configure the SDK as previously shown\. To access IAM, create an `AWS.IAM` service object\. Create a JSON object containing the parameters needed to create new access keys, which is the access key ID for which you want the last use information\. Call the `getAccessKeyLastUsed` method of the `AWS.IAM` service object\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create the IAM service object
var iam = new AWS.IAM({apiVersion: '2010-05-08'});
iam.getAccessKeyLastUsed({AccessKeyId: 'ACCESS_KEY_ID'}, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.AccessKeyLastUsed);
}
});
```
To run the example, type the following at the command line\.
```
node iam_accesskeylastused.js
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
447732b34abe-1 | ```
node iam_accesskeylastused.js
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/iam/iam_accesskeylastused.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
bb15e016ac32-0 | Create a Node\.js module with the file name `iam_updateaccesskey.js`\. Be sure to configure the SDK as previously shown\. To access IAM, create an `AWS.IAM` service object\. Create a JSON object containing the parameters needed to update the status of an access keys, which includes the access key ID and the updated status\. The status can be `Active` or `Inactive`\. Call the `updateAccessKey` method of the `AWS.IAM` service object\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create the IAM service object
var iam = new AWS.IAM({apiVersion: '2010-05-08'});
var params = {
AccessKeyId: 'ACCESS_KEY_ID',
Status: 'Active',
UserName: 'USER_NAME'
};
iam.updateAccessKey(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data);
}
});
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
bb15e016ac32-1 | } else {
console.log("Success", data);
}
});
```
To run the example, type the following at the command line\.
```
node iam_updateaccesskey.js
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/iam/iam_updateaccesskey.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
d245dbf83224-0 | Create a Node\.js module with the file name `iam_deleteaccesskey.js`\. Be sure to configure the SDK as previously shown\. To access IAM, create an `AWS.IAM` service object\. Create a JSON object containing the parameters needed to delete access keys, which includes the access key ID and the name of the user\. Call the `deleteAccessKey` method of the `AWS.IAM` service object\.
```
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create the IAM service object
var iam = new AWS.IAM({apiVersion: '2010-05-08'});
var params = {
AccessKeyId: 'ACCESS_KEY_ID',
UserName: 'USER_NAME'
};
iam.deleteAccessKey(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data);
}
});
```
To run the example, type the following at the command line\.
``` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
d245dbf83224-1 | });
```
To run the example, type the following at the command line\.
```
node iam_deleteaccesskey.js
```
This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/iam/iam_deleteaccesskey.js)\. | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-managing-access-keys.md |
6ca5f83401f1-0 | + **SDK version:** See [AWS SDK for JavaScript API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/)\.
+ **Latest major documentation update:** December 20, 2019 | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/doc-history.md |
fe8930836443-0 | The following table describes important changes in the V3 release of the AWS SDK for JavaScript\. For notification about updates to this documentation, you can subscribe to an [RSS feed](https://docs.aws.amazon.com/sdk-for-javascript/latest/developer-guide/amazon-sdk-javascript-guide-doc-history.rss)\.
| Change | Description | Date |
| --- |--- |--- |
| [Viewing Photos in an Amazon S3 Bucket from a Browser](s3-example-photos-view.md) | Added an example for simply viewing photos in existing photo albums\. | May 13, 2019 |
| [Setting Credentials in Node\.js, new credential\-loading choices](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html) | Added information about credentials that are loaded from the ECS credentials provider or a configured credential process\. | April 25, 2019 |
| [Credentials using a Configured Credential Process](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-configured-credential-process.html) | Added information about credentials that are loaded from a configured credential process\. | April 25, 2019 | | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/doc-history.md |
fe8930836443-1 | | [New Lambda Tutorial](using-lambda-functions.md) | Added a tutorial that builds a browser\-based game\. The tutorial includes a downloadable zip archive containing the graphic assets used by the game, several Node\.js scripts used to create and configure the services and resources used by the game, and the Node\.js code for the AWS Lambda function that runs the game\. | July 20, 2018 |
| [New Getting Started in a Browser Script](https://docs.aws.amazon.com/sdk-for-javascript/latest/developer-guide/getting-started-browser.html) | Getting Started in a Browser Script has been rewritten to simplify the example and to access the Amazon Polly service to send text and return synthesized speech you can play in the browser\. See [Getting Started in Browser Script](https://docs.aws.amazon.com/sdk-for-javascript/latest/developer-guide/getting-started-browser.html) for the new content\. | July 14, 2018 |
| [New Amazon SNS Code Samples](https://docs.aws.amazon.com/sdk-for-javascript/latest/developer-guide/sns-examples.html) | Four new Node\.js code samples for working with Amazon SNS have been added\. See [Amazon SNS Examples](https://docs.aws.amazon.com/sdk-for-javascript/latest/developer-guide/sns-examples.html) for the sample code\. | June 29, 2018 | | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/doc-history.md |
fe8930836443-2 | | [New Getting Started in Node\.js](https://docs.aws.amazon.com/sdk-for-javascript/latest/developer-guide/getting-started-nodejs.html) | Getting Started in Node\.js has been rewritten to use updated sample code and to provide greater detail in how to create the `package.json` file as well as the Node\.js code itself\. See [Getting Started in Node\.js](https://docs.aws.amazon.com/sdk-for-javascript/latest/developer-guide/getting-started-nodejs.html) for the new content\. | June 4, 2018 | | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/doc-history.md |
6fa8b2146347-0 | The following table describes important changes in the V3 release of the AWS SDK for JavaScript\.
****
| Change | Description | Date |
| --- | --- | --- |
| | | | | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/doc-history.md |
c4d28168a5a6-0 | In this task, you create and prepare the Amazon S3 bucket used by the application\.
![\[JavaScript running in a browser that creates an Amazon S3 bucket\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/create-s3-bucket.png)![\[JavaScript running in a browser that creates an Amazon S3 bucket\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/)![\[JavaScript running in a browser that creates an Amazon S3 bucket\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/)
For this application, the first thing you need to create is an Amazon S3 bucket to store all the browser assets\. These include the HTML file, all graphics files, and the CSS file\. The bucket is configured as a static website so that it also serves the application from the bucket's URL\.
The `slotassets` directory contains the Node\.js script `s3-bucket-setup.js` that creates the Amazon S3 bucket and sets the website configuration\.
**To create and configure the Amazon S3 bucket that the tutorial application uses**
+ At the command line, type the following command, where *BUCKET\_NAME* is the name for the bucket:
`node s3-bucket-setup.js BUCKET_NAME` | https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-s3-setup.md |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.