id
stringlengths
14
16
text
stringlengths
1
2.43k
source
stringlengths
99
229
4ac7ec435d1f-0
You can use `webpack` to generate bundles that run in Node\.js by specifying it as a target in the configuration\. ``` target: "node" ``` This is useful when running a Node\.js application in an environment where disk space is limited\. Here is an example `webpack.config.js` configuration with Node\.js specified as the output target\. ``` // Import path for resolving file paths var path = require('path'); module.exports = { // Specify the entry point for our app entry: [ path.join(__dirname, 'node.js') ], // Specify the output file containing our bundled code output: { path: __dirname, filename: 'bundle.js' }, // Let webpack know to generate a Node.js bundle target: "node", module: { /** * Tell webpack how to load JSON files. * When webpack encounters a 'require()' statement * where a JSON file is being imported, it will use * the json-loader */ loaders: [ { test: /\.json$/, loaders: ['json']
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/webpack.md
4ac7ec435d1f-1
loaders: [ { test: /\.json$/, loaders: ['json'] } ] } } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/webpack.md
cbc29235243d-0
The SDK automatically detects AWS credentials set as variables in your environment and uses them for SDK requests, eliminating the need to manage credentials in your application\. The environment variables that you set to provide your credentials are: + `AWS_ACCESS_KEY_ID` + `AWS_SECRET_ACCESS_KEY` + `AWS_SESSION_TOKEN` \(optional\) **Note** When setting environment variables, be sure to take appropriate actions afterward \(according to the needs of your operating system\) to make the variables available in the shell or command environment\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/loading-node-credentials-environment.md
832a4be71988-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 manage tables used to store and retrieve data from DynamoDB\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-examples-using-tables.md
f1863391186a-0
Similar to other database systems, DynamoDB stores data in tables\. A DynamoDB table is a collection of data that's organized into items that are analogous to rows\. To store or access data in DynamoDB, you create and work with tables\. In this example, you use a series of Node\.js modules to perform basic operations with a DynamoDB table\. The code uses the SDK for JavaScript to create and work with tables by using these methods of the `AWS.DynamoDB` client class: + [createTable](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#createTable-property) + [listTables](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#listTables-property) + [describeTable](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#describeTable-property) + [deleteTable](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#deleteTable-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-examples-using-tables.md
dd9d8708809e-0
To set up and run this example, first complete these tasks: + Install Node\.js\. For more information, 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/dynamodb-examples-using-tables.md
38983269ecc5-0
Create a Node\.js module with the file name `ddb_createtable.js`\. Be sure to configure the SDK as previously shown\. To access DynamoDB, create an `AWS.DynamoDB` service object\. Create a JSON object containing the parameters needed to create a table, which in this example includes the name and data type for each attribute, the key schema, the name of the table, and the units of throughput to provision\. Call the `createTable` method of the DynamoDB service object\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create the DynamoDB service object var ddb = new AWS.DynamoDB({apiVersion: '2012-08-10'}); var params = { AttributeDefinitions: [ { AttributeName: 'CUSTOMER_ID', AttributeType: 'N' }, { AttributeName: 'CUSTOMER_NAME', AttributeType: 'S' } ], KeySchema: [ { AttributeName: 'CUSTOMER_ID', KeyType: 'HASH' }, { AttributeName: 'CUSTOMER_NAME',
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-examples-using-tables.md
38983269ecc5-1
KeyType: 'HASH' }, { AttributeName: 'CUSTOMER_NAME', KeyType: 'RANGE' } ], ProvisionedThroughput: { ReadCapacityUnits: 1, WriteCapacityUnits: 1 }, TableName: 'CUSTOMER_LIST', StreamSpecification: { StreamEnabled: false } }; // Call DynamoDB to create the table ddb.createTable(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Table Created", data); } }); ``` To run the example, type the following at the command line\. ``` node ddb_createtable.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/dynamodb/ddb_createtable.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-examples-using-tables.md
a9f94d366762-0
Create a Node\.js module with the file name `ddb_listtables.js`\. Be sure to configure the SDK as previously shown\. To access DynamoDB, create an `AWS.DynamoDB` service object\. Create a JSON object containing the parameters needed to list your tables, which in this example limits the number of tables listed to 10\. Call the `listTables` method of the DynamoDB service object\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create the DynamoDB service object var ddb = new AWS.DynamoDB({apiVersion: '2012-08-10'}); // Call DynamoDB to retrieve the list of tables ddb.listTables({Limit: 10}, function(err, data) { if (err) { console.log("Error", err.code); } else { console.log("Table names are ", data.TableNames); } }); ``` To run the example, type the following at the command line\. ``` node ddb_listtables.js ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-examples-using-tables.md
a9f94d366762-1
``` node ddb_listtables.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/dynamodb/ddb_listtables.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-examples-using-tables.md
7712368ecf48-0
Create a Node\.js module with the file name `ddb_describetable.js`\. Be sure to configure the SDK as previously shown\. To access DynamoDB, create an `AWS.DynamoDB` service object\. Create a JSON object containing the parameters needed to describe a table, which in this example includes the name of the table provided as a command\-line parameter\. Call the `describeTable` method of the DynamoDB service object\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create the DynamoDB service object var ddb = new AWS.DynamoDB({apiVersion: '2012-08-10'}); var params = { TableName: process.argv[2] }; // Call DynamoDB to retrieve the selected table descriptions ddb.describeTable(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data.Table.KeySchema); } }); ``` 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/dynamodb-examples-using-tables.md
7712368ecf48-1
}); ``` To run the example, type the following at the command line\. ``` node ddb_describetable.js TABLE_NAME ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/dynamodb/ddb_describetable.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-examples-using-tables.md
6bfb916e5522-0
Create a Node\.js module with the file name `ddb_deletetable.js`\. Be sure to configure the SDK as previously shown\. To access DynamoDB, create an `AWS.DynamoDB` service object\. Create a JSON object containing the parameters needed to delete a table, which in this example includes the name of the table provided as a command\-line parameter\. Call the `deleteTable` method of the DynamoDB service object\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create the DynamoDB service object var ddb = new AWS.DynamoDB({apiVersion: '2012-08-10'}); var params = { TableName: process.argv[2] }; // Call DynamoDB to delete the specified table ddb.deleteTable(params, function(err, data) { if (err && err.code === 'ResourceNotFoundException') { console.log("Error: Table not found"); } else if (err && err.code === 'ResourceInUseException') { console.log("Error: Table in use"); } else {
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-examples-using-tables.md
6bfb916e5522-1
console.log("Error: Table in use"); } else { console.log("Success", data); } }); ``` To run the example, type the following at the command line\. ``` node ddb_deletetable.js TABLE_NAME ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/dynamodb/ddb_deletetable.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-examples-using-tables.md
437e930b26f8-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 specify the time interval during which messages received by a queue are not visible\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-managing-visibility-timeout.md
69366b61ca7d-0
In this example, a Node\.js module is used to manage visibility timeout\. The Node\.js module uses the SDK for JavaScript to manage visibility timeout by using this method of the `AWS.SQS` client class: + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#changeMessageVisibility-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#changeMessageVisibility-property) For more information about Amazon SQS visibility timeout, see [Visibility Timeout](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.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-managing-visibility-timeout.md
50673e3587ba-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\. For an example of creating a queue, see [Using Queues in Amazon SQS](sqs-examples-using-queues.md)\. + Send a message to the queue\. For an example of sending a message to a queue, see [Sending and Receiving Messages in Amazon SQS](sqs-examples-send-receive-messages.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-managing-visibility-timeout.md
d2db026a0ac7-0
Create a Node\.js module with the file name `sqs_changingvisibility.js`\. Be sure to configure the SDK as previously shown\. To access Amazon Simple Queue Service, create an `AWS.SQS` service object\. Receive the message from the queue\. Upon receipt of the message from the queue, create a JSON object containing the parameters needed for setting the timeout, including the URL of the queue containing the message, the `ReceiptHandle` returned when the message was received, and the new timeout in seconds\. Call the `changeMessageVisibility` method\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk') // Set the region to us-west-2 AWS.config.update({ region: 'us-west-2' }) // Create the SQS service object var sqs = new AWS.SQS({ apiVersion: '2012-11-05' }) var queueURL = 'https://sqs.REGION.amazonaws.com/ACCOUNT-ID/QUEUE-NAME' var params = { AttributeNames: ['SentTimestamp'], MaxNumberOfMessages: 1, MessageAttributeNames: ['All'], QueueUrl: queueURL } sqs.receiveMessage(params, function (err, data) {
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-managing-visibility-timeout.md
d2db026a0ac7-1
QueueUrl: queueURL } sqs.receiveMessage(params, function (err, data) { if (err) { console.log('Receive Error', err) } else { // Make sure we have a message if (data.Messages != null) { var visibilityParams = { QueueUrl: queueURL, ReceiptHandle: data.Messages[0].ReceiptHandle, VisibilityTimeout: 20 // 20 second timeout } sqs.changeMessageVisibility(visibilityParams, function (err, data) { if (err) { console.log('Delete Error', err) } else { console.log('Timeout Changed', data) } }) } else { console.log('No messages to change') } } }) ``` To run the example, type the following at the command line\. ``` node sqs_changingvisibility.js ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-managing-visibility-timeout.md
d2db026a0ac7-2
``` node sqs_changingvisibility.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_changingvisibility.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-managing-visibility-timeout.md
87e1c97b9034-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:** + Create IP address filters to accept or reject mail that originates from an IP address or range of IP addresses\. + List your current IP address filters\. + Delete an IP address filter\. In Amazon SES, a *filter* is a data structure that consists of a name, an IP address range, and whether to allow or block mail from it\. IP addresses you want to block or allow are specified as a single IP address or a range of IP addresses in Classless Inter\-Domain Routing \(CIDR\) notation\. For details on how Amazon SES receives email, see [Amazon SES Email\-Receiving Concepts](Amazon Simple Email Service Developer Guidereceiving-email-concepts.html) in the Amazon Simple Email Service Developer Guide\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-ip-filters.md
dfb0b3cc6f81-0
In this example, a series of Node\.js modules are used to send email in a variety of ways\. The Node\.js modules use the SDK for JavaScript to create and use email templates using these methods of the `AWS.SES` client class: + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#createReceiptFilter-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#createReceiptFilter-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#listReceiptFilters-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#listReceiptFilters-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#deleteReceiptFilter-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#deleteReceiptFilter-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-ip-filters.md
f0a82312a430-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/ses-examples-ip-filters.md
e0f8238ce05e-0
Configure the SDK for JavaScript by creating a global configuration object then setting the Region for your code\. In this example, the Region is set to `us-west-2`\. ``` // Load the SDK for JavaScript var AWS = require('aws-sdk'); // Set the Region AWS.config.update({region: 'us-west-2'}); ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-ip-filters.md
3d01aeede404-0
In this example, use a Node\.js module to send email with Amazon SES\. Create a Node\.js module with the file name `ses_createreceiptfilter.js`\. Configure the SDK as previously shown\. Create an object to pass the parameter values that define the IP filter, including the filter name, an IP address or range of addresses to filter, and whether to allow or block email traffic from the filtered addresses\. To call the `createReceiptFilter` method, create a promise for invoking an Amazon SES service object, passing the parameters\. Then handle the `response` in the promise callback\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create createReceiptFilter params var params = { Filter: { IpFilter: { Cidr: "IP_ADDRESS_OR_RANGE", Policy: "Allow" | "Block" }, Name: "NAME" } }; // Create the promise and SES service object var sendPromise = new AWS.SES({apiVersion: '2010-12-01'}).createReceiptFilter(params).promise();
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-ip-filters.md
3d01aeede404-1
// Handle promise's fulfilled/rejected states sendPromise.then( function(data) { console.log(data); }).catch( function(err) { console.error(err, err.stack); }); ``` To run the example, type the following at the command line\. The filter is created in Amazon SES\. ``` node ses_createreceiptfilter.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/ses/ses_createreceiptfilter.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-ip-filters.md
846827984fcb-0
In this example, use a Node\.js module to send email with Amazon SES\. Create a Node\.js module with the file name `ses_listreceiptfilters.js`\. Configure the SDK as previously shown\. Create an empty parameters object\. To call the `listReceiptFilters` method, create a promise for invoking an Amazon SES service object, passing the parameters\. Then handle the `response` in the promise callback\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create the promise and SES service object var sendPromise = new AWS.SES({apiVersion: '2010-12-01'}).listReceiptFilters({}).promise(); // Handle promise's fulfilled/rejected states sendPromise.then( function(data) { console.log(data.Filters); }).catch( function(err) { console.error(err, err.stack); }); ``` To run the example, type the following at the command line\. Amazon SES returns the filter list\. ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-ip-filters.md
846827984fcb-1
``` To run the example, type the following at the command line\. Amazon SES returns the filter list\. ``` node ses_listreceiptfilters.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/ses/ses_listreceiptfilters.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-ip-filters.md
fe5693956cf3-0
In this example, use a Node\.js module to send email with Amazon SES\. Create a Node\.js module with the file name `ses_deletereceiptfilter.js`\. Configure the SDK as previously shown\. Create an object to pass the name of the IP filter to delete\. To call the `deleteReceiptFilter` method, create a promise for invoking an Amazon SES service object, passing the parameters\. Then handle the `response` in the promise callback\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create the promise and SES service object var sendPromise = new AWS.SES({apiVersion: '2010-12-01'}).deleteReceiptFilter({FilterName: "NAME"}).promise(); // Handle promise's fulfilled/rejected states sendPromise.then( function(data) { console.log("IP Filter deleted"); }).catch( function(err) { console.error(err, err.stack); }); ``` To run the example, type the following at the command line\. The filter is deleted from Amazon SES\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-ip-filters.md
fe5693956cf3-1
}); ``` To run the example, type the following at the command line\. The filter is deleted from Amazon SES\. ``` node ses_deletereceiptfilter.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/ses/ses_deletereceiptfilter.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-ip-filters.md
929648de71fe-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 retrieve information about your key pairs\. + How to create a key pair to access an Amazon EC2 instance\. + How to delete an existing key pair\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-key-pairs.md
bea56a05cc5e-0
Amazon EC2 uses public–key cryptography to encrypt and decrypt login information\. Public–key cryptography uses a public key to encrypt data, then the recipient uses the private key to decrypt the data\. The public and private keys are known as a *key pair*\. In this example, you use a series of Node\.js modules to perform several Amazon EC2 key pair management operations\. The Node\.js modules use the SDK for JavaScript to manage instances by using these methods of the Amazon EC2 client class: + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#createKeyPair-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#createKeyPair-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#deleteKeyPair-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#deleteKeyPair-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeKeyPairs-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeKeyPairs-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-key-pairs.md
bea56a05cc5e-1
For more information about the Amazon EC2 key pairs, see [Amazon EC2 Key Pairs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html) in the *Amazon EC2 User Guide for Linux Instances* or [Amazon EC2 Key Pairs and Windows Instances](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-key-pairs.html) in the *Amazon EC2 User Guide for Windows Instances*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-key-pairs.md
a07f588dd6b0-0
To set up and run this example, 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/ec2-example-key-pairs.md
10bce15ac408-0
Create a Node\.js module with the file name `ec2_describekeypairs.js`\. Be sure to configure the SDK as previously shown\. To access Amazon EC2, create an `AWS.EC2` service object\. Create an empty JSON object to hold the parameters needed by the `describeKeyPairs` method to return descriptions for all your key pairs\. You can also provide an array of names of key pairs in the `KeyName` portion of the parameters in the JSON file to the `describeKeyPairs` method\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create EC2 service object var ec2 = new AWS.EC2({apiVersion: '2016-11-15'}); // Retrieve key pair descriptions; no params needed ec2.describeKeyPairs(function(err, data) { if (err) { console.log("Error", err); } else { console.log("Success", JSON.stringify(data.KeyPairs)); } }); ``` To run the example, type the following at the command line\. ``` node ec2_describekeypairs.js
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-key-pairs.md
10bce15ac408-1
To run the example, type the following at the command line\. ``` node ec2_describekeypairs.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/ec2/ec2_describekeypairs.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-key-pairs.md
e7cf3ca84570-0
Each key pair requires a name\. Amazon EC2 associates the public key with the name that you specify as the key name\. Create a Node\.js module with the file name `ec2_createkeypair.js`\. Be sure to configure the SDK as previously shown\. To access Amazon EC2, create an `AWS.EC2` service object\. Create the JSON parameters to specify the name of the key pair, then pass them to call the `createKeyPair` method\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create EC2 service object var ec2 = new AWS.EC2({apiVersion: '2016-11-15'}); var params = { KeyName: 'KEY_PAIR_NAME' }; // Create the key pair ec2.createKeyPair(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log(JSON.stringify(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/ec2-example-key-pairs.md
e7cf3ca84570-1
}); ``` To run the example, type the following at the command line\. ``` node ec2_createkeypair.js ``` This sample code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/ec2/ec2_createkeypair.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-key-pairs.md
c5d17ef36d22-0
Create a Node\.js module with the file name `ec2_deletekeypair.js`\. Be sure to configure the SDK as previously shown\. To access Amazon EC2, create an `AWS.EC2` service object\. Create the JSON parameters to specify the name of the key pair you want to delete\. Then call the `deleteKeyPair` method\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create EC2 service object var ec2 = new AWS.EC2({apiVersion: '2016-11-15'}); var params = { KeyName: 'KEY_PAIR_NAME' }; // Delete the key pair ec2.deleteKeyPair(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Key Pair Deleted"); } }); ``` To run the example, type the following at the command line\. ``` node ec2_deletekeypair.js ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-key-pairs.md
c5d17ef36d22-1
``` node ec2_deletekeypair.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/ec2/ec2_deletekeypair.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-key-pairs.md
153ab83020f3-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 send messages in a queue\. + How to receive messages in a queue\. + How to delete messages in a queue\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-send-receive-messages.md
dfd741e11a9c-0
In this example, a series of Node\.js modules are used to send and receive messages\. The Node\.js modules use the SDK for JavaScript to send and receive messages by using these methods of the `AWS.SQS` client class: + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#sendMessage-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#sendMessage-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#receiveMessage-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#receiveMessage-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#deleteMessage-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#deleteMessage-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-send-receive-messages.md
dfd741e11a9c-1
For more information about Amazon SQS messages, see [Sending a Message to an Amazon SQS Queue](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-send-message.html) and [Receiving and Deleting a Message from an Amazon SQS Queue](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-receive-delete-message.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-send-receive-messages.md
e75e42a3fe2a-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\. 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-send-receive-messages.md
f9ae01db1acf-0
Create a Node\.js module with the file name `sqs_sendmessage.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 for your message, including the URL of the queue to which you want to send this message\. In this example, the message provides details about a book on a list of fiction best sellers including the title, author, and number of weeks on the list\. Call the `sendMessage` method\. The callback returns the unique ID of the message\. ``` // 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 = { DelaySeconds: 10, MessageAttributes: { "Title": { DataType: "String", StringValue: "The Whistler" }, "Author": { DataType: "String", StringValue: "John Grisham" }, "WeeksOn": { DataType: "Number",
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-send-receive-messages.md
f9ae01db1acf-1
StringValue: "John Grisham" }, "WeeksOn": { DataType: "Number", StringValue: "6" } }, MessageBody: "Information about current NY Times fiction bestseller for week of 12/11/2016.", // MessageDeduplicationId: "TheWhistler", // Required for FIFO queues // MessageId: "Group1", // Required for FIFO queues QueueUrl: "SQS_QUEUE_URL" }; sqs.sendMessage(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data.MessageId); } }); ``` To run the example, type the following at the command line\. ``` node sqs_sendmessage.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_sendmessage.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-send-receive-messages.md
34c20e3649a3-0
Create a Node\.js module with the file name `sqs_receivemessage.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 for your message, including the URL of the queue from which you want to receive messages\. In this example, the parameters specify receipt of all message attributes, as well as receipt of no more than 10 messages\. Call the `receiveMessage` method\. The callback returns an array of `Message` objects from which you can retrieve `ReceiptHandle` for each message that you use to later delete that message\. Create another JSON object containing the parameters needed to delete the message, which are the URL of the queue and the `ReceiptHandle` value\. Call the `deleteMessage` method to delete the message you received\. ``` // 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 queueURL = "SQS_QUEUE_URL"; var params = { AttributeNames: [ "SentTimestamp" ], MaxNumberOfMessages: 10,
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-send-receive-messages.md
34c20e3649a3-1
AttributeNames: [ "SentTimestamp" ], MaxNumberOfMessages: 10, MessageAttributeNames: [ "All" ], QueueUrl: queueURL, VisibilityTimeout: 20, WaitTimeSeconds: 0 }; sqs.receiveMessage(params, function(err, data) { if (err) { console.log("Receive Error", err); } else if (data.Messages) { var deleteParams = { QueueUrl: queueURL, ReceiptHandle: data.Messages[0].ReceiptHandle }; sqs.deleteMessage(deleteParams, function(err, data) { if (err) { console.log("Delete Error", err); } else { console.log("Message Deleted", data); } }); } }); ``` To run the example, type the following at the command line\. ``` node sqs_receivemessage.js ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-send-receive-messages.md
34c20e3649a3-2
``` node sqs_receivemessage.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_receivemessage.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-send-receive-messages.md
5deca77d414f-0
After you install the SDK, you can load a client package in your node application using `require`\. For example, to load the Amazon S3 client, use the following\. ``` const s3 = require('aws-sdk/client-s3'); ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/loading-the-jssdk.md
f1ee2406a038-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 retrieve your account\-specific endpoint from MediaConvert\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/emc-examples-getendpoint.md
4c0a78357077-0
In this example, you use a Node\.js module to call MediaConvert and retrieve your account\-specific endpoint\. You can retrieve your endpoint URL from the service default endpoint and so do not yet need your account\-specific endpoint\. The code uses the SDK for JavaScript to retrieve this endpoint by using this method of the MediaConvert client class: + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/MediaConvert.html#describeEndpoints-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/MediaConvert.html#describeEndpoints-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/emc-examples-getendpoint.md
56d0e7a13521-0
To set up and run this example, first complete these tasks: + Install Node\.js\. For more information, 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 IAM role that gives MediaConvert access to your input files and the Amazon S3 buckets where your output files are stored\. For details, see [Set Up IAM Permissions](https://docs.aws.amazon.com/mediaconvert/latest/ug/iam-role.html) in the *AWS Elemental MediaConvert User Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/emc-examples-getendpoint.md
e3a688ae9767-0
Create a Node\.js module with the file name `emc_getendpoint.js`\. Be sure to configure the SDK as previously shown\. Create an object to pass the empty request parameters for the `describeEndpoints` method of the AWS\.MediaConvert client class\. To call the `describeEndpoints` method, create a promise for invoking an MediaConvert service object, passing the parameters\. Handle the response in the promise callback\. ``` // Load the SDK for JavaScript var AWS = require('aws-sdk'); // Set the Region AWS.config.update({region: 'us-west-2'}); // Create empty request parameters var params = { MaxResults: 0, }; // Create a promise on a MediaConvert object var endpointPromise = new AWS.MediaConvert({apiVersion: '2017-08-29'}).describeEndpoints(params).promise(); endpointPromise.then( function(data) { console.log("Your MediaConvert endpoint is ", data.Endpoints); }, function(err) { console.log("Error", err); } ); ``` 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/emc-examples-getendpoint.md
e3a688ae9767-1
} ); ``` To run the example, type the following at the command line\. ``` node emc_getendpoint.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/mediaconvert/emc_getendpoint.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/emc-examples-getendpoint.md
177d452f8bfd-0
The following example creates a multipart upload out of 1 megabyte chunks of a `Buffer` object using the `initiateMultipartUpload` method of the Amazon S3 Glacier service object\. The example assumes you have already created a vault named `YOUR_VAULT_NAME`\. A complete SHA\-256 tree hash is manually computed using the `computeChecksums` method\. ``` // Create a new service object and some supporting variables var glacier = new AWS.Glacier({apiVersion: '2012-06-01'}), vaultName = 'YOUR_VAULT_NAME', buffer = new Buffer(2.5 * 1024 * 1024), // 2.5MB buffer partSize = 1024 * 1024, // 1MB chunks, numPartsLeft = Math.ceil(buffer.length / partSize), startTime = new Date(), params = {vaultName: vaultName, partSize: partSize.toString()}; // Compute the complete SHA-256 tree hash so we can pass it // to completeMultipartUpload request at the end var treeHash = glacier.computeChecksums(buffer).treeHash; // Initiate the multipart upload console.log('Initiating upload to', vaultName); // Call Glacier to initiate the upload. glacier.initiateMultipartUpload(params, function (mpErr, multipart) {
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/glacier-example-multipart-upload.md
177d452f8bfd-1
// Call Glacier to initiate the upload. glacier.initiateMultipartUpload(params, function (mpErr, multipart) { if (mpErr) { console.log('Error!', mpErr.stack); return; } console.log("Got upload ID", multipart.uploadId); // Grab each partSize chunk and upload it as a part for (var i = 0; i < buffer.length; i += partSize) { var end = Math.min(i + partSize, buffer.length), partParams = { vaultName: vaultName, uploadId: multipart.uploadId, range: 'bytes ' + i + '-' + (end-1) + '/*', body: buffer.slice(i, end) }; // Send a single part console.log('Uploading part', i, '=', partParams.range); glacier.uploadMultipartPart(partParams, function(multiErr, mData) { if (multiErr) return; console.log("Completed part", this.request.params.range); if (--numPartsLeft > 0) return; // complete only when all parts uploaded var doneParams = { vaultName: vaultName,
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/glacier-example-multipart-upload.md
177d452f8bfd-2
var doneParams = { vaultName: vaultName, uploadId: multipart.uploadId, archiveSize: buffer.length.toString(), checksum: treeHash // the computed tree hash }; console.log("Completing upload..."); glacier.completeMultipartUpload(doneParams, function(err, data) { if (err) { console.log("An error occurred while uploading the archive"); console.log(err); } else { var delta = (new Date() - startTime) / 1000; console.log('Completed upload in', delta, 'seconds'); console.log('Archive ID:', data.archiveId); console.log('Checksum: ', data.checksum); } }); }); } }); ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/glacier-example-multipart-upload.md
85b0fa7cc8ec-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:** + Create and delete receipt rules\. + Organize receipt rules into receipt rule sets\. Receipt rules in Amazon SES specify what to do with email received for email addresses or domains you own\. A *receipt rule* contains a condition and an ordered list of actions\. If the recipient of an incoming email matches a recipient specified in the conditions for the receipt rule, Amazon SES performs the actions that the receipt rule specifies\. To use Amazon SES as your email receiver, you must have at least one active *receipt rule set*\. A receipt rule set is an ordered collection of receipt rules that specify what Amazon SES should do with mail it receives across your verified domains\. For more information, see [Creating Receipt Rules for Amazon SES Email Receiving](Amazon Simple Email Service Developer Guidereceiving-email-receipt-rules.html) and [Creating a Receipt Rule Set for Amazon SES Email Receiving](Amazon Simple Email Service Developer Guidereceiving-email-receipt-rule-set.html) in the Amazon Simple Email Service Developer Guide\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-receipt-rules.md
1a032bebece5-0
In this example, a series of Node\.js modules are used to send email in a variety of ways\. The Node\.js modules use the SDK for JavaScript to create and use email templates using these methods of the `AWS.SES` client class: + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#createReceiptRule-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#createReceiptRule-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#deleteReceiptRule-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#deleteReceiptRule-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#createReceiptRuleSet-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#createReceiptRuleSet-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-receipt-rules.md
1a032bebece5-1
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#deleteReceiptRuleSet-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#deleteReceiptRuleSet-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-receipt-rules.md
6491c85057d5-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 credentials JSON 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/ses-examples-receipt-rules.md
793d246a38a7-0
Each receipt rule for Amazon SES contains an ordered list of actions\. This example creates a receipt rule with an Amazon S3 action, which delivers the mail message to an Amazon S3 bucket\. For details on receipt rule actions, see [Action Options ](Amazon Simple Email Service Developer Guidereceiving-email-action.html) in the Amazon Simple Email Service Developer Guide\. For Amazon SES to write email to an Amazon S3 bucket, create a bucket policy that gives `PutObject` permission to Amazon SES\. For information about creating this bucket policy, see [Give Amazon SES Permission to Write to Your Amazon S3 Bucket ](Amazon Simple Email Service Developer Guidereceiving-email-permissions.html#receiving-email-permissions-s3.html) in the Amazon Simple Email Service Developer Guide\. In this example, use a Node\.js module to create a receipt rule in Amazon SES to save received messages in an Amazon S3 bucket\. Create a Node\.js module with the file name `ses_createreceiptrule.js`\. Configure the SDK as previously shown\. Create a parameters object to pass the values needed to create for the receipt rule set\. To call the `createReceiptRuleSet` method, create a promise for invoking an Amazon SES service object, passing the parameters\. Then handle the `response` in the promise callback\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'});
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-receipt-rules.md
793d246a38a7-1
// Set the region AWS.config.update({region: 'REGION'}); // Create createReceiptRule params var params = { Rule: { Actions: [ { S3Action: { BucketName: "S3_BUCKET_NAME", ObjectKeyPrefix: "email" } } ], Recipients: [ 'DOMAIN | EMAIL_ADDRESS', /* more items */ ], Enabled: true | false, Name: "RULE_NAME", ScanEnabled: true | false, TlsPolicy: "Optional" }, RuleSetName: "RULE_SET_NAME" }; // Create the promise and SES service object var newRulePromise = new AWS.SES({apiVersion: '2010-12-01'}).createReceiptRule(params).promise(); // Handle promise's fulfilled/rejected states newRulePromise.then( function(data) { console.log("Rule created"); }).catch( function(err) { console.error(err, err.stack); }); ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-receipt-rules.md
793d246a38a7-2
function(err) { console.error(err, err.stack); }); ``` To run the example, type the following at the command line\. Amazon SES creates the receipt rule\. ``` node ses_createreceiptrule.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/ses/ses_createreceiptrule.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-receipt-rules.md
7f9d693d17e5-0
In this example, use a Node\.js module to send email with Amazon SES\. Create a Node\.js module with the file name `ses_deletereceiptrule.js`\. Configure the SDK as previously shown\. Create a parameters object to pass the name for the receipt rule to delete\. To call the `deleteReceiptRule` method, create a promise for invoking an Amazon SES service object, passing the parameters\. Then handle the `response` in the promise callback\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create deleteReceiptRule params var params = { RuleName: 'RULE_NAME', /* required */ RuleSetName: 'RULE_SET_NAME' /* required */ }; // Create the promise and SES service object var newRulePromise = new AWS.SES({apiVersion: '2010-12-01'}).deleteReceiptRule(params).promise(); // Handle promise's fulfilled/rejected states newRulePromise.then( function(data) { console.log("Receipt Rule Deleted"); }).catch( function(err) {
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-receipt-rules.md
7f9d693d17e5-1
console.log("Receipt Rule Deleted"); }).catch( function(err) { console.error(err, err.stack); }); ``` To run the example, type the following at the command line\. Amazon SES creates the receipt rule set list\. ``` node ses_deletereceiptrule.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/ses/ses_deletereceiptrule.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-receipt-rules.md
4b0711dc738c-0
In this example, use a Node\.js module to send email with Amazon SES\. Create a Node\.js module with the file name `ses_createreceiptruleset.js`\. Configure the SDK as previously shown\. Create a parameters object to pass the name for the new receipt rule set\. To call the `createReceiptRuleSet` method, create a promise for invoking an Amazon SES service object, passing the parameters\. Then handle the `response` in the promise callback\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create the promise and SES service object var newRulePromise = new AWS.SES({apiVersion: '2010-12-01'}).createReceiptRuleSet({RuleSetName: "NAME"}).promise(); // Handle promise's fulfilled/rejected states newRulePromise.then( function(data) { console.log(data); }).catch( function(err) { console.error(err, err.stack); }); ``` To run the example, type the following at the command line\. Amazon SES creates the receipt rule set list\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-receipt-rules.md
4b0711dc738c-1
``` To run the example, type the following at the command line\. Amazon SES creates the receipt rule set list\. ``` node ses_createreceiptruleset.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/ses/ses_createreceiptruleset.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-receipt-rules.md
1fa40124777b-0
In this example, use a Node\.js module to send email with Amazon SES\. Create a Node\.js module with the file name `ses_deletereceiptruleset.js`\. Configure the SDK as previously shown\. Create an object to pass the name for the receipt rule set to delete\. To call the `deleeReceiptRuleSet` method, create a promise for invoking an Amazon SES service object, passing the parameters\. Then handle the `response` in the promise callback\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create the promise and SES service object var newRulePromise = new AWS.SES({apiVersion: '2010-12-01'}).deleteReceiptRuleSet({RuleSetName: "NAME"}).promise(); // Handle promise's fulfilled/rejected states newRulePromise.then( function(data) { console.log(data); }).catch( function(err) { console.error(err, err.stack); }); ``` To run the example, type the following at the command line\. Amazon SES creates the receipt rule set list\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-receipt-rules.md
1fa40124777b-1
``` To run the example, type the following at the command line\. Amazon SES creates the receipt rule set list\. ``` node ses_deletereceiptruleset.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/ses/ses_deletereceiptruleset.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-receipt-rules.md
4b69ba499adf-0
The default trust stores for Node\.js include the certificates needed to access AWS services\. In some cases, it might be preferable to include only a specific set of certificates\. In this example, a specific certificate on disk is used to create an `https.Agent` that rejects connections unless the designated certificate is provided\. The newly created `https.Agent` is then used by the DynamoDB client\. ``` var fs = require('fs'); var https = require('https'); const dynamodb = require('aws-sdk/clients/dynamodb') var certs = [ fs.readFileSync('/path/to/cert.pem') ]; var dynamodbClient = new DynamoDB({ httpOptions: { agent: new https.Agent({ rejectUnauthorized: true, ca: certs }) } }); ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/node-registering-certs.md
e237796428b5-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 you:** + How to access AWS services from a browser script using Amazon Cognito Identity\. + How to turn text into synthesized speech using Amazon Polly\. + How to use a presigner object to create a presigned URL\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
0bdd656d08ab-0
Amazon Polly is a cloud service that converts text into lifelike speech\. You can use Amazon Polly to develop applications that increase engagement and accessibility\. Amazon Polly supports multiple languages and includes a variety of lifelike voices\. For more information about Amazon Polly, see the [Amazon Polly Developer Guide](https://docs.aws.amazon.com/polly/latest/dg/)\. This example shows you how to set up and run a browser script that takes text, sends that text to Amazon Polly, and returns the URL of the synthesized audio of the text for you to play\. The browser script uses an Amazon Cognito Identity pool to provide credentials needed to access AWS services\. The example demonstrates the basic patterns for loading and using the SDK for JavaScript in browser scripts\. **Note** You must run this example in a browser that supports HTML 5 audio to playback the synthesized speech\. ![\[Illustration of how a browser script interacts with Amazon Cognito Identity and Amazon Polly services\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/browserscenario.png) The browser script uses the SDK for JavaScript to synthesize text by using the following APIs: + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityCredentials.html](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityCredentials.html) constructor
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
0bdd656d08ab-1
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Polly/Presigner.html](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Polly/Presigner.html) constructor + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Polly/Presigner.html#getSynthesizeSpeechUrl-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Polly/Presigner.html#getSynthesizeSpeechUrl-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
fb2ff85739d5-0
In this exercise, you create and use an Amazon Cognito Identity pool to provide unauthenticated access to your browser script for the Amazon Polly service\. Creating an identity pool also creates two AWS Identity and Access Management \(IAM\) roles, one to support users authenticated by an identity provider and the other to support unauthenticated guest users\. In this exercise, we will only work with the unauthenticated user role to keep the task focused\. You can integrate support for an identity provider and authenticated users later\. **To create an Amazon Cognito Identity pool** 1. Sign in to the AWS Management Console and open the Amazon Cognito console at [https://console\.aws\.amazon\.com/cognito/\.](https://console.aws.amazon.com/cognito/) 1. Choose **Manage Identity Pools** on the console opening page\. 1. On the next page, choose **Create new identity pool**\. **Note** If there are no other identity pools, the Amazon Cognito console will skip this page and open the next page instead\. 1. In the **Getting started wizard**, type a name for your identity pool in **Identity pool name**\. 1. Choose **Enable access to unauthenticated identities**\. 1. Choose **Create Pool**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
fb2ff85739d5-1
1. Choose **Enable access to unauthenticated identities**\. 1. Choose **Create Pool**\. 1. On the next page, choose **View Details** to see the names of the two IAM roles created for your identity pool\. Make a note of the name of the role for unauthenticated identities\. You need this name to add the required policy for Amazon Polly\. 1. Choose **Allow**\. 1. On the **Sample code** page, select the Platform of *JavaScript*\. Then, copy or write down the identity pool ID and the Region\. You need these values to replace REGION and IDENTITY\_POOL\_ID in your browser script\. After you create your Amazon Cognito identity pool, you're ready to add permissions for Amazon Polly that are needed by your browser script\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
dcb678ab3139-0
To enable browser script access to Amazon Polly for speech synthesis, use the unauthenticated IAM role created for your Amazon Cognito identity pool\. This requires you to add an IAM policy to the role\. For more information about IAM roles, 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*\. **To add an Amazon Polly policy to the IAM role associated with unauthenticated users** 1. Sign in to the AWS Management Console and open the IAM console at [https://console\.aws\.amazon\.com/iam/](https://console.aws.amazon.com/iam/)\. 1. In the navigation panel on the left of the page, choose **Roles**\. 1. In the list of IAM roles, click the link for the unauthenticated identities role previously created by Amazon Cognito\. 1. In the **Summary** page for this role, choose **Attach policies**\. 1. In the **Attach Permissions** page for this role, find and then select the check box for **AmazonPollyFullAccess**\. **Note** You can use this process to enable access to any Amazon or AWS service\. 1. Choose **Attach policy**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
dcb678ab3139-1
You can use this process to enable access to any Amazon or AWS service\. 1. Choose **Attach policy**\. After you create your Amazon Cognito identity pool and add permissions for Amazon Polly to your IAM role for unauthenticated users, you are ready to build the webpage and browser script\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
0ee29fc0ff2a-0
The sample app consists of a single HTML page that contains the user interface and browser script\. To begin, create an HTML document and copy the following contents into it\. The page includes an input field and button, an `<audio>` element to play the synthesized speech, and a `<p>` element to display messages\. \(Note that the full example is shown at the bottom of this page\.\) For more information on the `<audio>` element, see [audio](https://www.w3schools.com/tags/tag_audio.asp)\. ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>AWS SDK for JavaScript - Browser Getting Started Application</title> </head> <body> <div id="textToSynth"> <input autofocus size="23" type="text" id="textEntry" value="It's very good to meet you."/> <button class="btn default" onClick="speakText()">Synthesize</button> <p id="result">Enter text above then click Synthesize</p> </div> <audio id="audioPlayback" controls> <source id="audioSource" type="audio/mp3" src=""> </audio>
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
0ee29fc0ff2a-1
<source id="audioSource" type="audio/mp3" src=""> </audio> <!-- (script elements go here) --> </body> </html> ``` Save the HTML file, naming it `polly.html`\. After you have created the user interface for the application, you're ready to add the browser script code that runs the application\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
1069d8bc5595-0
The first thing to do when creating the browser script is to include the SDK for JavaScript by adding a `<script>` element after the `<audio>` element in the page\. ``` <script src="https://sdk.amazonaws.com/js/aws-sdk-SDK_VERSION_NUMBER.min.js"></script> ``` \(To find the current SDK\_VERSION\_NUMBER, see the API Reference for the SDK for JavaScript at [https://docs\.aws\.amazon\.com/AWSJavaScriptSDK/latest/index\.html](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/)\.\) Then add a new `<script type="text/javascript">` element after the SDK entry\. You'll add the browser script to this element\. Set the AWS Region and credentials for the SDK\. Next, create a function named `speakText()` that will be invoked as an event handler by the button\. To synthesize speech with Amazon Polly, you must provide a variety of parameters including the sound format of the output, the sampling rate, the ID of the voice to use, and the text to play back\. When you initially create the parameters, set the `Text:` parameter to an empty string; the `Text:` parameter will be set to the value you retrieve from the `<input>` element in the webpage\. ``` <script type="text/javascript">
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
1069d8bc5595-1
``` <script type="text/javascript"> // Initialize the Amazon Cognito credentials provider AWS.config.region = 'REGION'; AWS.config.credentials = new AWS.CognitoIdentityCredentials({IdentityPoolId: 'IDENTITY_POOL_ID'}); // Function invoked by button click function speakText() { // Create the JSON parameters for getSynthesizeSpeechUrl var speechParams = { OutputFormat: "mp3", SampleRate: "16000", Text: "", TextType: "text", VoiceId: "Matthew" }; speechParams.Text = document.getElementById("textEntry").value; ``` Amazon Polly returns synthesized speech as an audio stream\. The easiest way to play that audio in a browser is to have Amazon Polly make the audio available at a presigned URL you can then set as the `src` attribute of the `<audio>` element in the webpage\. Create a new `AWS.Polly` service object\. Then create the `AWS.Polly.Presigner` object you'll use to create the presigned URL from which the synthesized speech audio can be retrieved\. You must pass the speech parameters that you defined as well as the `AWS.Polly` service object that you created to the `AWS.Polly.Presigner` constructor\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
1069d8bc5595-2
After you create the presigner object, call the `getSynthesizeSpeechUrl` method of that object, passing the speech parameters\. If successful, this method returns the URL of the synthesized speech, which you then assign to the `<audio>` element for playback\. ``` // Create the Polly service object and presigner object var polly = new AWS.Polly({apiVersion: '2016-06-10'}); var signer = new AWS.Polly.Presigner(speechParams, polly) // Create presigned URL of synthesized speech file signer.getSynthesizeSpeechUrl(speechParams, function(error, url) { if (error) { document.getElementById('result').innerHTML = error; } else { document.getElementById('audioSource').src = url; document.getElementById('audioPlayback').load(); document.getElementById('result').innerHTML = "Speech ready to play."; } }); } </script> ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
2b1c0b5ae8c4-0
To run the example app, load `polly.html` into a web browser\. The app should look similar to the following\. ![\[Web application browser interface\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/browsergetstarted.png) Enter a phrase you want turned to speech in the input box, then choose **Synthesize**\. When the audio is ready to play, a message appears\. Use the audio player controls to hear the synthesized speech\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
483af3f3d763-0
Here is the full HTML page with the browser script\. It's also available [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/browserstart/polly.html)\. ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>AWS SDK for JavaScript - Browser Getting Started Application</title> </head> <body> <div id="textToSynth"> <input autofocus size="23" type="text" id="textEntry" value="It's very good to meet you."/> <button class="btn default" onClick="speakText()">Synthesize</button> <p id="result">Enter text above then click Synthesize</p> </div> <audio id="audioPlayback" controls> <source id="audioSource" type="audio/mp3" src=""> </audio> <script src="https://sdk.amazonaws.com/js/aws-sdk-2.410.0.min.js"></script> <script type="text/javascript">
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
483af3f3d763-1
<script type="text/javascript"> // Initialize the Amazon Cognito credentials provider AWS.config.region = 'REGION'; AWS.config.credentials = new AWS.CognitoIdentityCredentials({IdentityPoolId: 'IDENTITY_POOL_ID'}); // Function invoked by button click function speakText() { // Create the JSON parameters for getSynthesizeSpeechUrl var speechParams = { OutputFormat: "mp3", SampleRate: "16000", Text: "", TextType: "text", VoiceId: "Matthew" }; speechParams.Text = document.getElementById("textEntry").value; // Create the Polly service object and presigner object var polly = new AWS.Polly({apiVersion: '2016-06-10'}); var signer = new AWS.Polly.Presigner(speechParams, polly) // Create presigned URL of synthesized speech file signer.getSynthesizeSpeechUrl(speechParams, function(error, url) { if (error) { document.getElementById('result').innerHTML = error; } else {
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
483af3f3d763-2
if (error) { document.getElementById('result').innerHTML = error; } else { document.getElementById('audioSource').src = url; document.getElementById('audioPlayback').load(); document.getElementById('result').innerHTML = "Speech ready to play."; } }); } </script> </body> </html> ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
ebc98b163481-0
Here are variations on this application you can use to further explore using the SDK for JavaScript in a browser script\. + Experiment with other sound output formats\. + Add the option to select any of the various voices provided by Amazon Polly\. + Integrate an identity provider like Facebook or Amazon to use with the authenticated IAM role\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/getting-started-browser.md
b060c88982ee-0
AWS Identity and Access Management \(IAM\) is an Amazon Web Services \(AWS\) service that helps an administrator securely control access to AWS resources\. IAM administrators control who can be *authenticated* \(signed in\) and *authorized* \(have permissions\) to use resources in AWS services\. IAM is an AWS service that you can use with no additional charge\. To use this AWS product or service to access AWS, you need an AWS account and AWS credentials\. To increase the security of your AWS account, we recommend that you use an *IAM user* to provide access credentials instead of using your AWS account credentials\. For details about working with IAM, see [AWS Identity and Access Management](https://aws.amazon.com/iam/)\. For an overview of IAM users and why they are important for the security of your account, see [AWS Security Credentials](https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html) in the [Amazon Web Services General Reference](https://docs.aws.amazon.com/general/latest/gr/)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/security-iam.md
b060c88982ee-1
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/security-iam.md
58e8218cf924-0
Amazon Simple Queue Service \(SQS\) is a fast, reliable, scalable, fully managed message queuing service\. Amazon SQS lets you decouple the components of a cloud application\. Amazon SQS includes standard queues with high throughput and at\-least\-once processing, and FIFO queues that provide FIFO \(first\-in, first\-out\) delivery and exactly\-once processing\. ![\[Relationship between JavaScript environments, the SDK, and Amazon SQS\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/code-samples-sqs.png) The JavaScript API for Amazon SQS is exposed through the `AWS.SQS` client class\. For more information about using the CloudWatch client class, see [Class: AWS\.SQS](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html) in the API reference\. **Topics** + [Using Queues in Amazon SQS](sqs-examples-using-queues.md) + [Sending and Receiving Messages in Amazon SQS](sqs-examples-send-receive-messages.md) + [Managing Visibility Timeout in Amazon SQS](sqs-examples-managing-visibility-timeout.md) + [Enabling Long Polling in Amazon SQS](sqs-examples-enable-long-polling.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples.md
58e8218cf924-1
+ [Enabling Long Polling in Amazon SQS](sqs-examples-enable-long-polling.md) + [Using Dead Letter Queues in Amazon SQS](sqs-examples-dead-letter-queues.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples.md
8073917898c9-0
Here is the browser script code for the Kinesis capturing webpage scroll progress 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' }); // 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) {
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/kinesis-examples-capturing-page-scrolling-full.md
8073917898c9-1
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); 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); }); // upload data to Amazon Kinesis every second if data exists setInterval(function() { if (!recordData.length) { return;
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/kinesis-examples-capturing-page-scrolling-full.md
8073917898c9-2
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-full.md
1732fc4893fd-0
A common scenario for using Node\.js with the SDK for JavaScript is to set up and run a Node\.js web application on an Amazon Elastic Compute Cloud \(Amazon EC2\) instance\. In this tutorial, you will create a Linux instance, connect to it using SSH, and then install Node\.js to run on that instance\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/setting-up-node-on-ec2-instance.md
d3a56d708f39-0
This tutorial assumes that you have already launched a Linux instance with a public DNS name that is reachable from the Internet and to which you are able to connect using SSH\. For more information, see [Step 1: Launch an Instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html#ec2-launch-instance_linux) in the *Amazon EC2 User Guide for Linux Instances*\. You must also have configured your security group to allow `SSH` \(port 22\), `HTTP` \(port 80\), and `HTTPS` \(port 443\) connections\. For more information about these prerequisites, see [ Setting Up with Amazon EC2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/get-set-up-for-amazon-ec2.html) in the *Amazon EC2 User Guide for Linux Instances*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/setting-up-node-on-ec2-instance.md
fb7e81670422-0
The following procedure helps you install Node\.js on an Amazon Linux instance\. You can use this server to host a Node\.js web application\. **To set up Node\.js on your Linux instance** 1. Connect to your Linux instance as `ec2-user` using SSH\. 1. Install node version manager \(nvm\) by typing the following at the command line\. **Warning** AWS does not control the following code\. Before you run it, be sure to verify its authenticity and integrity\. More information about this code can be found in the [nvm](https://github.com/nvm-sh/nvm/blob/master/README.md) GitHub repository\. ``` curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash ``` We will use nvm to install Node\.js because nvm can install multiple versions of Node\.js and allow you to switch between them\. 1. Activate nvm by typing the following at the command line\. ``` . ~/.nvm/nvm.sh ``` 1. Use nvm to install the latest version of Node\.js by typing the following at the command line\. ``` nvm install node
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/setting-up-node-on-ec2-instance.md
fb7e81670422-1
``` nvm install node ``` Installing Node\.js also installs the Node Package Manager \(`npm`\) so you can install additional modules as needed\. 1. Test that Node\.js is installed and running correctly by typing the following at the command line\. ``` node -e "console.log('Running Node.js ' + process.version)" ``` This displays the following message that shows the version of Node\.js that is running\. `Running Node.js VERSION` **Note** The node installation only applies to the current EC2 session\. Once the EC2 instance goes away, you'll have to re\-install node again\. The alternative is to make an AMI of the EC2 instance once you have the configuration that you want to keep, as described in the following section\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/setting-up-node-on-ec2-instance.md