id
stringlengths
14
16
text
stringlengths
1
2.43k
source
stringlengths
99
229
8e65ceeea112-1
``` node iam_listservercerts.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_listservercerts.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-server-certificates.md
b7a9c4a41d60-0
Create a Node\.js module with the file name `iam_getservercert.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 get a certificate, which consists of the name of the server certificate you want\. Call the `getServerCertificates` 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.getServerCertificate({ServerCertificateName: 'CERTIFICATE_NAME'}, 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 iam_getservercert.js ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-server-certificates.md
b7a9c4a41d60-1
``` node iam_getservercert.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_getservercert.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-server-certificates.md
5926507ac3f2-0
Create a Node\.js module with the file name `iam_updateservercert.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 a certificate, which consists of the name of the existing server certificate as well as the name of the new certificate\. Call the `updateServerCertificate` 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 = { ServerCertificateName: 'CERTIFICATE_NAME', NewServerCertificateName: 'NEW_CERTIFICATE_NAME' }; iam.updateServerCertificate(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-server-certificates.md
5926507ac3f2-1
} }); ``` To run the example, type the following at the command line\. ``` node iam_updateservercert.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_updateservercert.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-server-certificates.md
db85f5112f26-0
Create a Node\.js module with the file name `iam_deleteservercert.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 a server certificate, which consists of the name of the certificate you want to delete\. Call the `deleteServerCertificates` 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.deleteServerCertificate({ServerCertificateName: 'CERTIFICATE_NAME'}, 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 iam_deleteservercert.js ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-server-certificates.md
db85f5112f26-1
``` node iam_deleteservercert.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_deleteservercert.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/iam-examples-server-certificates.md
5f7e0b21bf58-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 or set the access control list for an Amazon S3 bucket\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/s3-example-access-permissions.md
67b8082c6f31-0
In this example, a Node\.js module is used to display the bucket access control list \(ACL\) for a selected bucket and apply changes to the ACL for a selected bucket\. The Node\.js module uses the SDK for JavaScript to manage Amazon S3 bucket access permissions using these methods of the Amazon S3 client class: + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getBucketAcl-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getBucketAcl-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putBucketAcl-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putBucketAcl-property) For more information about access control lists for Amazon S3 buckets, see [ Managing Access with ACLs](https://docs.aws.amazon.com/AmazonS3/latest/dev/S3_ACLs_UsingACLs.html) in the *Amazon Simple Storage Service Developer Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/s3-example-access-permissions.md
b23597356cb3-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/s3-example-access-permissions.md
80b7d1b13684-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/s3-example-access-permissions.md
d4000972f11d-0
Create a Node\.js module with the file name `s3_getbucketacl.js`\. The module will take a single command\-line argument to specify the bucket whose ACL configuration you want\. Make sure to configure the SDK as previously shown\. Create an `AWS.S3` service object\. The only parameter you need to pass is the name of the selected bucket when calling the `getBucketAcl` method\. The current access control list configuration is returned by Amazon S3 in the `data` parameter passed to the callback function\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create S3 service object s3 = new AWS.S3({apiVersion: '2006-03-01'}); var bucketParams = {Bucket: process.argv[2]}; // call S3 to retrieve policy for selected bucket s3.getBucketAcl(bucketParams, function(err, data) { if (err) { console.log("Error", err); } else if (data) { console.log("Success", data.Grants); } }); ``` 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/s3-example-access-permissions.md
d4000972f11d-1
} }); ``` To run the example, type the following at the command line\. ``` node s3_getbucketacl.js BUCKET_NAME ``` This sample code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/s3/s3_getbucketacl.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/s3-example-access-permissions.md
1a3faa07c6d6-0
Amazon Simple Email Service \(Amazon SES\) is a cloud\-based email sending service designed to help digital marketers and application developers send marketing, notification, and transactional emails\. It is a reliable, cost\-effective service for businesses of all sizes that use email to keep in contact with their customers\. ![\[Relationship between JavaScript environments, the SDK, and Amazon SES\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/code-samples-ses.png) The JavaScript API for Amazon SES is exposed through the `AWS.SES` client class\. For more information about using the Amazon SES client class, see [Class: AWS\.SES](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html) in the API reference\. **Topics** + [Managing Amazon SES Identities](ses-examples-managing-identities.md) + [Working with Email Templates in Amazon SES](ses-examples-creating-template.md) + [Sending Email Using Amazon SES](ses-examples-sending-email.md) + [Using IP Address Filters for Email Receipt in Amazon SES](ses-examples-ip-filters.md) + [Using Receipt Rules in Amazon SES](ses-examples-receipt-rules.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples.md
76b7412dd750-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 descriptions for AWS Regions and Availability Zones\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-regions-availability-zones.md
cef3aea44ecb-0
Amazon EC2 is hosted in multiple locations worldwide\. These locations are composed of Regions and Availability Zones\. Each Region is a separate geographic area\. Each Region has multiple, isolated locations known as *Availability Zones*\. Amazon EC2 provides the ability to place instances and data in multiple locations\. In this example, you use a series of Node\.js modules to retrieve details about Regions and Availability Zones\. The Node\.js modules use the SDK for JavaScript to manage instances by using the following methods of the Amazon EC2 client class: + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeAvailabilityZones-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeAvailabilityZones-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeRegions-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeRegions-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-regions-availability-zones.md
cef3aea44ecb-1
For more information about Regions and Availability Zones, see [Regions and Availability Zones](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html) in the *Amazon EC2 User Guide for Linux Instances* or [Regions and Availability Zones](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/using-regions-availability-zones.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-regions-availability-zones.md
93063ca6e895-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/ec2-example-regions-availability-zones.md
2fa5fa72e4ef-0
Create a Node\.js module with the file name `ec2_describeregionsandzones.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 pass as parameters, which returns all available descriptions\. Then call the `describeRegions` and `describeAvailabilityZones` methods\. ``` // 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 = {}; // Retrieves all regions/endpoints that work with EC2 ec2.describeRegions(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Regions: ", data.Regions); } }); // Retrieves availability zones only for region of the ec2 service object ec2.describeAvailabilityZones(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/ec2-example-regions-availability-zones.md
2fa5fa72e4ef-1
if (err) { console.log("Error", err); } else { console.log("Availability Zones: ", data.AvailabilityZones); } }); ``` To run the example, type the following at the command line\. ``` node ec2_describeregionsandzones.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_describeregionsandzones.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-regions-availability-zones.md
26fe384e81b3-0
If you run your Node\.js application on an Amazon EC2 instance, you can leverage IAM roles for Amazon EC2 to automatically provide credentials to the instance\. If you configure your instance to use IAM roles, the SDK automatically selects the IAM credentials for your application, eliminating the need to manually provide credentials\. For more information on adding IAM roles to an Amazon EC2 instance, see [IAM Roles for Amazon EC2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/loading-node-credentials-iam.md
3b097fea7470-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:** + Get a list of all of your email templates\. + Retrieve and update email templates\. + Create and delete email templates\. Amazon SES lets you send personalized email messages using email templates\. For details on how to create and use email templates in Amazon Simple Email Service, see [Sending Personalized Email Using the Amazon SES API](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-personalized-email-api.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-creating-template.md
2b1d5c30dbb7-0
In this example, you use a series of Node\.js modules to work with email templates\. 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#listTemplates-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#listTemplates-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#createTemplate-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#createTemplate-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#getTemplate-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#getTemplate-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#deleteTemplate-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#deleteTemplate-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-creating-template.md
2b1d5c30dbb7-1
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#updateTemplate-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#updateTemplate-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-creating-template.md
e339ce83bdac-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 creating a 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-creating-template.md
c714639267c9-0
In this example, use a Node\.js module to create an email template to use with Amazon SES\. Create a Node\.js module with the file name `ses_listtemplates.js`\. Configure the SDK as previously shown\. Create an object to pass the parameters for the `listTemplates` method of the `AWS.SES` client class\. To call the `listTemplates` 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 templatePromise = new AWS.SES({apiVersion: '2010-12-01'}).listTemplates({MaxItems: ITEMS_COUNT}).promise(); // Handle promise's fulfilled/rejected states templatePromise.then( function(data) { console.log(data); }).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-creating-template.md
c714639267c9-1
function(err) { console.error(err, err.stack); }); ``` To run the example, type the following at the command line\. Amazon SES returns the list of templates\. ``` node ses_listtemplates.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_listtemplates.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-creating-template.md
bf044d17b7c4-0
In this example, use a Node\.js module to get an email template to use with Amazon SES\. Create a Node\.js module with the file name `ses_gettemplate.js`\. Configure the SDK as previously shown\. Create an object to pass the `TemplateName` parameter for the `getTemplate` method of the `AWS.SES` client class\. To call the `getTemplate` 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 templatePromise = new AWS.SES({apiVersion: '2010-12-01'}).getTemplate({TemplateName: 'TEMPLATE_NAME'}).promise(); // Handle promise's fulfilled/rejected states templatePromise.then( function(data) { console.log(data.SubjectPart); }).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-creating-template.md
bf044d17b7c4-1
function(err) { console.error(err, err.stack); }); ``` To run the example, type the following at the command line\. Amazon SES returns the template details\. ``` node ses_gettemplate.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_gettemplate.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-creating-template.md
617a96fb42bd-0
In this example, use a Node\.js module to create an email template to use with Amazon SES\. Create a Node\.js module with the file name `ses_createtemplate.js`\. Configure the SDK as previously shown\. Create an object to pass the parameters for the `createTemplate` method of the `AWS.SES` client class, including `TemplateName`, `HtmlPart`, `SubjectPart`, and `TextPart`\. To call the `createTemplate` 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 createTemplate params var params = { Template: { TemplateName: 'TEMPLATE_NAME', /* required */ HtmlPart: 'HTML_CONTENT', SubjectPart: 'SUBJECT_LINE', TextPart: 'TEXT_CONTENT' } }; // Create the promise and SES service object var templatePromise = new AWS.SES({apiVersion: '2010-12-01'}).createTemplate(params).promise();
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-creating-template.md
617a96fb42bd-1
var templatePromise = new AWS.SES({apiVersion: '2010-12-01'}).createTemplate(params).promise(); // Handle promise's fulfilled/rejected states templatePromise.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 template is added to Amazon SES\. ``` node ses_createtemplate.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_createtemplate.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-creating-template.md
63af62dce34c-0
In this example, use a Node\.js module to create an email template to use with Amazon SES\. Create a Node\.js module with the file name `ses_updatetemplate.js`\. Configure the SDK as previously shown\. Create an object to pass the `Template` parameter values you want to update in the template, with the required `TemplateName` parameter passed to the `updateTemplate` method of the `AWS.SES` client class\. To call the `updateTemplate` 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 updateTemplate parameters var params = { Template: { TemplateName: 'TEMPLATE_NAME', /* required */ HtmlPart: 'HTML_CONTENT', SubjectPart: 'SUBJECT_LINE', TextPart: 'TEXT_CONTENT' } }; // Create the promise and SES service object var templatePromise = new AWS.SES({apiVersion: '2010-12-01'}).updateTemplate(params).promise(); // Handle promise's fulfilled/rejected states
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-creating-template.md
63af62dce34c-1
// Handle promise's fulfilled/rejected states templatePromise.then( function(data) { console.log("Template Updated"); }).catch( function(err) { console.error(err, err.stack); }); ``` To run the example, type the following at the command line\. Amazon SES returns the template details\. ``` node ses_updatetemplate.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_updatetemplate.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-creating-template.md
2ae73010ffbe-0
In this example, use a Node\.js module to create an email template to use with Amazon SES\. Create a Node\.js module with the file name `ses_deletetemplate.js`\. Configure the SDK as previously shown\. Create an object to pass the required`TemplateName` parameter to the `deleteTemplate` method of the `AWS.SES` client class\. To call the `deleteTemplate` 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 templatePromise = new AWS.SES({apiVersion: '2010-12-01'}).deleteTemplate({TemplateName: 'TEMPLATE_NAME'}).promise(); // Handle promise's fulfilled/rejected states templatePromise.then( function(data) { console.log("Template Deleted"); }).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-creating-template.md
2ae73010ffbe-1
function(err) { console.error(err, err.stack); }); ``` To run the example, type the following at the command line\. Amazon SES returns the template details\. ``` node ses_deletetemplate.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_deletetemplate.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ses-examples-creating-template.md
05bccb3b969d-0
Amazon DynamoDB is a fully managed NoSQL cloud database that supports both document and key\-value store models\. You create schemaless tables for data without the need to provision or maintain dedicated database servers\. ![\[Relationship between JavaScript environments, the SDK, and DynamoDB\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/code-samples-dynamodb.png) The JavaScript API for DynamoDB is exposed through the `AWS.DynamoDB`, `AWS.DynamoDBStreams`, and `AWS.DynamoDB.DocumentClient` client classes\. For more information about using the DynamoDB client classes, see [Class: AWS\.DynamoDB](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html), [Class: AWS\.DynamoDBStreams](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDBStreams.html), and [Class: AWS\.DynamoDB\.DocumentClient](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html) in the API reference\. **Topics** + [Creating and Using Tables in DynamoDB](dynamodb-examples-using-tables.md) + [Reading and Writing a Single Item in DynamoDB](dynamodb-example-table-read-write.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-examples.md
05bccb3b969d-1
+ [Reading and Writing a Single Item in DynamoDB](dynamodb-example-table-read-write.md) + [Reading and Writing Items in Batch in DynamoDB](dynamodb-example-table-read-write-batch.md) + [Querying and Scanning a DynamoDB Table](dynamodb-example-query-scan.md) + [Using the DynamoDB Document Client](dynamodb-example-document-client.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-examples.md
d1a95e2572ee-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 descriptions of your Elastic IP addresses\. + How to allocate and release an Elastic IP address\. + How to associate an Elastic IP address with an Amazon EC2 instance\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-elastic-ip-addresses.md
0e057f47003b-0
An *Elastic IP address* is a static IP address designed for dynamic cloud computing\. An Elastic IP address is associated with your AWS account\. It is a public IP address, which is reachable from the internet\. If your instance does not have a public IP address, you can associate an Elastic IP address with your instance to enable communication with the internet\. In this example, you use a series of Node\.js modules to perform several Amazon EC2 operations involving Elastic IP addresses\. The Node\.js modules use the SDK for JavaScript to manage Elastic IP addresses by using these methods of the Amazon EC2 client class: + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeAddresses-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeAddresses-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#allocateAddress-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#allocateAddress-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#associateAddress-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#associateAddress-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-elastic-ip-addresses.md
0e057f47003b-1
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#releaseAddress-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#releaseAddress-property) For more information about Elastic IP addresses in Amazon EC2, see [Elastic IP Addresses](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html) in the *Amazon EC2 User Guide for Linux Instances* or [Elastic IP Addresses](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/elastic-ip-addresses-eip.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-elastic-ip-addresses.md
2f2a1df934d6-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)\. + Create an Amazon EC2 instance\. For more information about creating Amazon EC2 instances, see [Amazon EC2 Instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Instances.html) in the *Amazon EC2 User Guide for Linux Instances* or [Amazon EC2 Instances](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Instances.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-elastic-ip-addresses.md
97c871c7d067-0
Create a Node\.js module with the file name `ec2_describeaddresses.js`\. Be sure to configure the SDK as previously shown\. To access Amazon EC2, create an `AWS.EC2` service object\. Create a JSON object to pass as parameters, filtering the addresses returned by those in your VPC\. To retrieve descriptions of all your Elastic IP addresses, omit a filter from the parameters JSON\. Then call the `describeAddresses` method of the Amazon EC2 service object\. ``` // 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 = { Filters: [ {Name: 'domain', Values: ['vpc']} ] }; // Retrieve Elastic IP address descriptions ec2.describeAddresses(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Success", JSON.stringify(data.Addresses)); } }); ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-elastic-ip-addresses.md
97c871c7d067-1
} }); ``` To run the example, type the following at the command line\. ``` node ec2_describeaddresses.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_describeaddresses.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-elastic-ip-addresses.md
5c5db3c6ad4b-0
Create a Node\.js module with the file name `ec2_allocateaddress.js`\. Be sure to configure the SDK as previously shown\. To access Amazon EC2, create an `AWS.EC2` service object\. Create a JSON object for the parameters used to allocate an Elastic IP address, which in this case specifies the `Domain` is a VPC\. Call the `allocateAddress` method of the Amazon EC2 service object\. If the call succeeds, the `data` parameter to the callback function has an `AllocationId` property that identifies the allocated Elastic IP address\. Create a JSON object for the parameters used to associate an Elastic IP address to an Amazon EC2 instance, including the `AllocationId` from the newly allocated address and the `InstanceId` of the Amazon EC2 instance\. Then call the `associateAddresses` method of the Amazon EC2 service object\. ``` // 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 paramsAllocateAddress = { Domain: 'vpc' }; // Allocate the Elastic IP address
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-elastic-ip-addresses.md
5c5db3c6ad4b-1
Domain: 'vpc' }; // Allocate the Elastic IP address ec2.allocateAddress(paramsAllocateAddress, function(err, data) { if (err) { console.log("Address Not Allocated", err); } else { console.log("Address allocated:", data.AllocationId); var paramsAssociateAddress = { AllocationId: data.AllocationId, InstanceId: 'INSTANCE_ID' }; // Associate the new Elastic IP address with an EC2 instance ec2.associateAddress(paramsAssociateAddress, function(err, data) { if (err) { console.log("Address Not Associated", err); } else { console.log("Address associated:", data.AssociationId); } }); } }); ``` To run the example, type the following at the command line\. ``` node ec2_allocateaddress.js ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-elastic-ip-addresses.md
5c5db3c6ad4b-2
``` node ec2_allocateaddress.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_allocateaddress.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-elastic-ip-addresses.md
78caaed0ce29-0
Create a Node\.js module with the file name `ec2_releaseaddress.js`\. Be sure to configure the SDK as previously shown\. To access Amazon EC2, create an `AWS.EC2` service object\. Create a JSON object for the parameters used to release an Elastic IP address, which in this case specifies the `AllocationId` for the Elastic IP address\. Releasing an Elastic IP address also disassociates it from any Amazon EC2 instance\. Call the `releaseAddress` method of the Amazon EC2 service object\. ``` // 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 paramsReleaseAddress = { AllocationId: 'ALLOCATION_ID' }; // Disassociate the Elastic IP address from EC2 instance ec2.releaseAddress(paramsReleaseAddress, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Address released"); } }); ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-elastic-ip-addresses.md
78caaed0ce29-1
} else { console.log("Address released"); } }); ``` To run the example, type the following at the command line\. ``` node ec2_releaseaddress.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_releaseaddress.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-example-elastic-ip-addresses.md
430855fdcc73-0
Amazon CloudWatch \(CloudWatch\) is a web service that monitors your Amazon Web Services \(AWS\) resources and applications you run on AWS in real time\. You can use CloudWatch to collect and track metrics, which are variables you can measure for your resources and applications\. CloudWatch alarms send notifications or automatically make changes to the resources you are monitoring based on rules that you define\. ![\[Relationship between JavaScript environments, the SDK, and CloudWatch\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/code-samples-cloudwatch.png) The JavaScript API for CloudWatch is exposed through the `AWS.CloudWatch`, `AWS.CloudWatchEvents`, and `AWS.CloudWatchLogs` client classes\. For more information about using the CloudWatch client classes, see [Class: AWS\.CloudWatch](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html), [Class: AWS\.CloudWatchEvents](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchEvents.html), and [Class: AWS\.CloudWatchLogs](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchLogs.html) in the API reference\. **Topics** + [Creating Alarms in Amazon CloudWatch](cloudwatch-examples-creating-alarms.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples.md
430855fdcc73-1
**Topics** + [Creating Alarms in Amazon CloudWatch](cloudwatch-examples-creating-alarms.md) + [Using Alarm Actions in Amazon CloudWatch](cloudwatch-examples-using-alarm-actions.md) + [Getting Metrics from Amazon CloudWatch](cloudwatch-examples-getting-metrics.md) + [Sending Events to Amazon CloudWatch Events](cloudwatch-examples-sending-events.md) + [Using Subscription Filters in Amazon CloudWatch Logs](cloudwatch-examples-subscriptions.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples.md
92c82e2a439c-0
Amazon Simple Notification Service \(Amazon SNS\) is a web service that coordinates and manages the delivery or sending of messages to subscribing endpoints or clients\. In Amazon SNS, there are two types of clients—publishers and subscribers—also referred to as producers and consumers\. ![\[Relationship between JavaScript environments, the SDK, and Amazon SNS\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/code-samples-sns.png) Publishers communicate asynchronously with subscribers by producing and sending a message to a topic, which is a logical access point and communication channel\. Subscribers \(web servers, email addresses, Amazon SQS queues, Lambda functions\) consume or receive the message or notification over one of the supported protocols \(Amazon SQS, HTTP/S, email, SMS, AWS Lambda\) when they are subscribed to the topic\. The JavaScript API for Amazon SNS is exposed through the [Class: AWS\.SNS](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html)\. **Topics** + [Managing Topics in Amazon SNS](sns-examples-managing-topics.md) + [Publishing Messages in Amazon SNS](sns-examples-publishing-messages.md) + [Managing Subscriptions in Amazon SNS](sns-examples-subscribing-unubscribing-topics.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sns-examples.md
92c82e2a439c-1
+ [Managing Subscriptions in Amazon SNS](sns-examples-subscribing-unubscribing-topics.md) + [Sending SMS Messages with Amazon SNS](sns-examples-sending-sms.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sns-examples.md
718199d569d8-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 enable long polling for a newly created queue + How to enable long polling for an existing queue + How to enable long polling upon receipt of a message
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-enable-long-polling.md
4bcce1637da5-0
Long polling reduces the number of empty responses by allowing Amazon SQS to wait a specified time for a message to become available in the queue before sending a response\. Also, long polling eliminates false empty responses by querying all of the servers instead of a sampling of servers\. To enable long polling, you must specify a non\-zero wait time for received messages\. You can do this by setting the `ReceiveMessageWaitTimeSeconds` parameter of a queue or by setting the `WaitTimeSeconds` parameter on a message when it is received\. In this example, a series of Node\.js modules are used to enable long polling\. The Node\.js modules use the SDK for JavaScript to enable long polling using these methods 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) + [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://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-enable-long-polling.md
4bcce1637da5-1
+ [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#createQueue-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#createQueue-property) For more information about Amazon SQS long polling, see [Long Polling](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-long-polling.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-enable-long-polling.md
5e71144f585f-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-enable-long-polling.md
c96543f3bca8-0
Create a Node\.js module with the file name `sqs_longpolling_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 create a queue, including a non\-zero value for the `ReceiveMessageWaitTimeSeconds` parameter\. Call the `createQueue` method\. Long polling is then enabled for the queue\. ``` // 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 = { QueueName: 'SQS_QUEUE_NAME', Attributes: { 'ReceiveMessageWaitTimeSeconds': '20', } }; sqs.createQueue(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data.QueueUrl); } }); ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-enable-long-polling.md
c96543f3bca8-1
console.log("Success", data.QueueUrl); } }); ``` To run the example, type the following at the command line\. ``` node sqs_longpolling_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_longpolling_createqueue.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-enable-long-polling.md
f12c60107c67-0
Create a Node\.js module with the file name `sqs_longpolling_existingqueue.js`\. Be sure to configure the SDK as previously shown\. To access Amazon Simple Queue Service, create an `AWS.SQS` service object\. Create a JSON object containing the parameters needed to set the attributes of queue, including a non\-zero value for the `ReceiveMessageWaitTimeSeconds` parameter and the URL of the queue\. Call the `setQueueAttributes` method\. Long polling is then enabled for the queue\. ``` // 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: { "ReceiveMessageWaitTimeSeconds": "20", }, QueueUrl: "SQS_QUEUE_URL" }; sqs.setQueueAttributes(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/sqs-examples-enable-long-polling.md
f12c60107c67-1
} else { console.log("Success", data); } }); ``` To run the example, type the following at the command line\. ``` node sqs_longpolling_existingqueue.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_longpolling_existingqueue.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-enable-long-polling.md
25a735aef68a-0
Create a Node\.js module with the file name `sqs_longpolling_receivemessage.js`\. Be sure to configure the SDK as previously shown\. To access Amazon Simple Queue Service, create an `AWS.SQS` service object\. Create a JSON object containing the parameters needed to receive messages, including a non\-zero value for the `WaitTimeSeconds` parameter and the URL of the queue\. Call the `receiveMessage` 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 queueURL = "SQS_QUEUE_URL"; var params = { AttributeNames: [ "SentTimestamp" ], MaxNumberOfMessages: 1, MessageAttributeNames: [ "All" ], QueueUrl: queueURL, WaitTimeSeconds: 20 }; sqs.receiveMessage(params, function(err, data) { if (err) {
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-enable-long-polling.md
25a735aef68a-1
}; sqs.receiveMessage(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_longpolling_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_longpolling_receivemessage.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/sqs-examples-enable-long-polling.md
93f371b0d85a-0
When you create an AWS Lambda function, you must create a special IAM role that has permission to execute the function\. This role is called the *execution role*\. When you set up a Lambda function, you must specify the IAM role you created as the corresponding execution role\. The execution role provides the Lambda function with the credentials it needs to run and to invoke other web services\. As a result, you do not need to provide credentials to the Node\.js code you write within a Lambda function\. For more information about creating a Lambda execution role, see [Manage Permissions: Using an IAM Role \(Execution Role\)](https://docs.aws.amazon.com/lambda/latest/dg/intro-permission-model.html#lambda-intro-execution-role) in the *AWS Lambda Developer Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/loading-node-credentials-lambda.md
5812affcbd1e-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 a vault using the `createVault` method of the Amazon S3 Glacier service object\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/glacier-example-creating-a-vault.md
19de46d60020-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/glacier-example-creating-a-vault.md
fcde0db8ec55-0
``` // Load the SDK for JavaScript var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create a new service object var glacier = new AWS.Glacier({apiVersion: '2012-06-01'}); // Call Glacier to create the vault glacier.createVault({vaultName: 'YOUR_VAULT_NAME'}, function(err) { if (!err) { console.log("Created vault!") } }); ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/glacier-example-creating-a-vault.md
e2fd74f88a59-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 basic information about your CloudWatch alarms\. + How to create and delete a CloudWatch alarm\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-creating-alarms.md
3c897ac5c7d1-0
An alarm watches a single metric over a time period you specify, and performs one or more actions based on the value of the metric relative to a given threshold over a number of time periods\. In this example, a series of Node\.js modules are used to create alarms in CloudWatch\. The Node\.js modules use the SDK for JavaScript to create alarms using these methods of the `AWS.CloudWatch` client class: + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#describeAlarms-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#describeAlarms-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#putMetricAlarm-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#putMetricAlarm-property) + [https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#deleteAlarms-property](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#deleteAlarms-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-creating-alarms.md
3c897ac5c7d1-1
For more information about CloudWatch alarms, see [Creating Amazon CloudWatch Alarms](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html) in the *Amazon CloudWatch User Guide*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-creating-alarms.md
907b5f031c6f-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/cloudwatch-examples-creating-alarms.md
7edb28a40ba7-0
Create a Node\.js module with the file name `cw_describealarms.js`\. Be sure to configure the SDK as previously shown\. To access CloudWatch, create an `AWS.CloudWatch` service object\. Create a JSON object to hold the parameters for retrieving alarm descriptions, limiting the alarms returned to those with a state of `INSUFFICIENT_DATA`\. Then call the `describeAlarms` method of the `AWS.CloudWatch` service object\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create CloudWatch service object var cw = new AWS.CloudWatch({apiVersion: '2010-08-01'}); cw.describeAlarms({StateValue: 'INSUFFICIENT_DATA'}, function(err, data) { if (err) { console.log("Error", err); } else { // List the names of all current alarms in the console data.MetricAlarms.forEach(function (item, index, array) { console.log(item.AlarmName); }); } }); ``` 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/cloudwatch-examples-creating-alarms.md
7edb28a40ba7-1
}); ``` To run the example, type the following at the command line\. ``` node cw_describealarms.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/cloudwatch/cw_describealarms.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-creating-alarms.md
4d23488e10d0-0
Create a Node\.js module with the file name `cw_putmetricalarm.js`\. Be sure to configure the SDK as previously shown\. To access CloudWatch, create an `AWS.CloudWatch` service object\. Create a JSON object for the parameters needed to create an alarm based on a metric, in this case the CPU utilization of an Amazon EC2 instance\. The remaining parameters are set so the alarm triggers when the metric exceeds a threshold of 70 percent\. Then call the `describeAlarms` method of the `AWS.CloudWatch` service object\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create CloudWatch service object var cw = new AWS.CloudWatch({apiVersion: '2010-08-01'}); var params = { AlarmName: 'Web_Server_CPU_Utilization', ComparisonOperator: 'GreaterThanThreshold', EvaluationPeriods: 1, MetricName: 'CPUUtilization', Namespace: 'AWS/EC2', Period: 60, Statistic: 'Average', Threshold: 70.0, ActionsEnabled: false, AlarmDescription: 'Alarm when server CPU exceeds 70%', Dimensions: [ {
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-creating-alarms.md
4d23488e10d0-1
ActionsEnabled: false, AlarmDescription: 'Alarm when server CPU exceeds 70%', Dimensions: [ { Name: 'InstanceId', Value: 'INSTANCE_ID' }, ], Unit: 'Percent' }; cw.putMetricAlarm(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 cw_putmetricalarm.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/cloudwatch/cw_putmetricalarm.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-creating-alarms.md
8f57afef82d2-0
Create a Node\.js module with the file name `cw_deletealarms.js`\. Be sure to configure the SDK as previously shown\. To access CloudWatch, create an `AWS.CloudWatch` service object\. Create a JSON object to hold the names of the alarms you want to delete\. Then call the `deleteAlarms` method of the `AWS.CloudWatch` service object\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Set the region AWS.config.update({region: 'REGION'}); // Create CloudWatch service object var cw = new AWS.CloudWatch({apiVersion: '2010-08-01'}); var params = { AlarmNames: ['Web_Server_CPU_Utilization'] }; cw.deleteAlarms(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 cw_deletealarms.js ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-creating-alarms.md
8f57afef82d2-1
``` node cw_deletealarms.js ``` This example code can be found [here on GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/cloudwatch/cw_deletealarms.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/cloudwatch-examples-creating-alarms.md
d7d6c8c977fe-0
Cloud security at Amazon Web Services \(AWS\) is the highest priority\. As an AWS customer, you benefit from a data center and network architecture that is built to meet the requirements of the most security\-sensitive organizations\. Security is a shared responsibility between AWS and you\. The [Shared Responsibility Model](https://aws.amazon.com/compliance/shared-responsibility-model/) describes this as Security of the Cloud and Security in the Cloud\. **Security of the Cloud** – AWS is responsible for protecting the infrastructure that runs all of the services offered in the AWS Cloud and providing you with services that you can use securely\. Our security responsibility is the highest priority at AWS, and the effectiveness of our security is regularly tested and verified by third\-party auditors as part of the [AWS Compliance Programs](https://aws.amazon.com/compliance/programs/)\. **Security in the Cloud** – Your responsibility is determined by the AWS service you are using, and other factors including the sensitivity of your data, your organization’s requirements, and applicable laws and regulations\. 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.md
d7d6c8c977fe-1
**Topics** + [Data Protection](data-protection.md) + [Identity and Access Management](security-iam.md) + [Compliance Validation](compliance-validation.md) + [Resilience](disaster-recovery-resiliency.md) + [Infrastructure Security](infrastructure-security.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/security.md
9424b6da8e9c-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 add an item in a DynamoDB table\. + How to retrieve, an item in a DynamoDB table\. + How to delete an item in a DynamoDB table\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-example-table-read-write.md
ce3b4ee6e814-0
In this example, you use a series of Node\.js modules to read and write one item in a DynamoDB table by using these methods of the `AWS.DynamoDB` client class: + [putItem](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#putItem-property) + [getItem](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#getItem-property) + [deleteItem](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#deleteItem-property)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-example-table-read-write.md
2b3aa0fd647d-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 a DynamoDB table whose items you can access\. For more information about creating a DynamoDB table, see [Creating and Using Tables in DynamoDB](dynamodb-examples-using-tables.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-example-table-read-write.md
c67924681f27-0
Create a Node\.js module with the file name `ddb_putitem.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 add an item, which in this example includes the name of the table and a map that defines the attributes to set and the values for each attribute\. Call the `putItem` 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: 'CUSTOMER_LIST', Item: { 'CUSTOMER_ID' : {N: '001'}, 'CUSTOMER_NAME' : {S: 'Richard Roe'} } }; // Call DynamoDB to add the item to the table ddb.putItem(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/dynamodb-example-table-read-write.md
c67924681f27-1
} else { console.log("Success", data); } }); ``` To run the example, type the following at the command line\. ``` node ddb_putitem.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_putitem.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-example-table-read-write.md
4eb8cbe1906e-0
Create a Node\.js module with the file name `ddb_getitem.js`\. Be sure to configure the SDK as previously shown\. To access DynamoDB, create an `AWS.DynamoDB` service object\. To identify the item to get, you must provide the value of the primary key for that item in the table\. By default, the `getItem` method returns all the attribute values defined for the item\. To get only a subset of all possible attribute values, specify a projection expression\. Create a JSON object containing the parameters needed to get an item, which in this example includes the name of the table, the name and value of the key for the item you're getting, and a projection expression that identifies the item attribute you want to retrieve\. Call the `getItem` 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: 'TABLE', Key: { 'KEY_NAME': {N: '001'} }, ProjectionExpression: 'ATTRIBUTE_NAME' }; // Call DynamoDB to read the item from the table
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-example-table-read-write.md
4eb8cbe1906e-1
}, ProjectionExpression: 'ATTRIBUTE_NAME' }; // Call DynamoDB to read the item from the table ddb.getItem(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data.Item); } }); ``` To run the example, type the following at the command line\. ``` node ddb_getitem.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_getitem.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-example-table-read-write.md
6a7a14c90dad-0
Create a Node\.js module with the file name `ddb_deleteitem.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 an item, which in this example includes the name of the table and both the key name and value for the item you're deleting\. Call the `deleteItem` 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: 'TABLE', Key: { 'KEY_NAME': {N: 'VALUE'} } }; // Call DynamoDB to delete the item from the table ddb.deleteItem(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/dynamodb-example-table-read-write.md
6a7a14c90dad-1
} else { console.log("Success", data); } }); ``` To run the example, type the following at the command line\. ``` node ddb_deleteitem.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_deleteitem.js)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/dynamodb-example-table-read-write.md
9934a9850913-0
In this task, you create the AWS Lambda function used by the application\. ![\[JavaScript running in a browser invoking a Lambda function\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/create-lambda-function.png)![\[JavaScript running in a browser invoking a Lambda function\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/)![\[JavaScript running in a browser invoking a Lambda function\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/) The Lambda function is invoked by the browser script every time the player of the game clicks and releases the handle on the side of the machine\. There are 16 possible results that can appear in each slot position, chosen at random\. The Lambda function generates three random results, one for each slot wheel in the game\. For each result, the Lambda function calls the Amazon DynamoDB table to retrieve the file name of the result graphic\. Once all three results are determined and their matching graphic URLs are retrieved, the result information is returned to the browser script for showing the result\. The Node\.js code needed for the Lambda function is in the `slotassets` directory\. You must edit this code to use it in your Lambda function\. Completing this portion of the application requires you to do these things: + Edit the Node\.js code used by the Lambda function\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-function-prep.md
9934a9850913-1
+ Edit the Node\.js code used by the Lambda function\. + Compress the Node\.js code into a \.zip archive file that you then upload to the Amazon S3 bucket used by the application\. + Edit the Node\.js setup script that creates the Lambda function\. + Run the setup script, which creates the Lambda function from the \.zip archive file in the Amazon S3 bucket\. **To make the necessary edits in the Node\.js code of the Lambda function** 1. Open `slotpull.js` in the `slotassets` directory in a text editor\. 1. Find this line of code in the browser script\. ``` TableName: = "TABLE_NAME"; ``` 1. Replace *TABLE\_NAME* with your DynamoDB table name\. 1. Save and close the file\. **To prepare the Node\.js code for creating the Lambda function** 1. Compress `slotpull.js` into a \.zip archive file for creating the Lambda function\. 1. Upload `slotpull.js.zip` to the Amazon S3 bucket you created for this app\. You can use the following CLI command, where *BUCKET* is the name of your Amazon S3 bucket\. ``` aws s3 cp slotpull.js.zip s3://BUCKET ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-function-prep.md
c00e72766c85-0
The code creates a JSON object to package the result for the browser script in the application\. Next, it generates three random integer values that are used to look up items in the DynamoDB table, and obtains file names of images in the Amazon S3 bucket\. The result JSON is populated and passed back to the Lambda function caller\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-function-prep.md
09609ed6bdb0-0
You can provide the Node\.js code for the Lambda function is in a file compressed into a \.zip archive file that you upload to an Amazon S3 bucket\. The `slotassets` directory contains the Node\.js script `lambda-function-setup.js` that you can modify and run to create the Lambda function\. **To edit the Node\.js setup script for creating the Lambda function** 1. Open `lambda-function-setup.js` in the `slotassets` directory in a text editor\. 1. Find this line in the script\. ``` S3Bucket: 'BUCKET_NAME', ``` Replace *BUCKET\_NAME* with the name of the Amazon S3 bucket that contains the \.zip archive file of the Lambda function code\. 1. Find this line in the script ``` S3Key: 'ZIP_FILE_NAME', ``` Replace *ZIP\_FILE\_NAME* with the name of the \.zip archive file of the Lambda function code in the Amazon S3 bucket\. 1. Find this line in the script\. ``` Role: 'ROLE_ARN', ``` Replace *ROLE\_ARN* with the ARN of the execution role you just created\. 1. Save and close the file\. **To run the setup script and create the Lambda function from the \.zip archive file in the Amazon S3 bucket**
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-function-prep.md
09609ed6bdb0-1
**To run the setup script and create the Lambda function from the \.zip archive file in the Amazon S3 bucket** + At the command line, type the following\. ``` node lambda-function-setup.js ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-function-prep.md
79ea2df7bafa-0
The following is the script that creates the Lambda function\. The code assumes you uploaded the \.zip archive file of the Lambda function to the Amazon S3 bucket you created for the application\. ``` // Load the AWS SDK for Node.js var AWS = require('aws-sdk'); // Load credentials and set Region from JSON file AWS.config.loadFromPath('./config.json'); // Create the IAM service object var lambda = new AWS.Lambda({apiVersion: '2015-03-31'}); var params = { Code: { /* required */ S3Bucket: ''BUCKET_NAME', S3Key: 'ZIP_FILE_NAME' }, FunctionName: 'slotTurn', /* required */ Handler: 'slotSpin.Slothandler', /* required */ Role: 'ROLE_ARN', /* required */ Runtime: 'nodejs8.10', /* required */ Description: 'Slot machine game results generator' }; lambda.createFunction(params, function(err, data) { if (err) console.log(err); // an error occurred else console.log("success"); // successful response }); ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-function-prep.md
79ea2df7bafa-1
else console.log("success"); // successful response }); ``` Click **next** to continue the tutorial\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-function-prep.md
1affa3ebca00-0
Amazon Elastic Compute Cloud \(Amazon EC2\) is a web service that provides virtual server hosting in the cloud\. It is designed to make web\-scale cloud computing easier for developers by providing resizeable compute capacity\. ![\[Relationship between JavaScript environments, the SDK, and Amazon EC2\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/code-samples-ec2.png) The JavaScript API for Amazon EC2 is exposed through the `AWS.EC2` client class\. For more information about using the Amazon EC2 client class, see [Class: AWS\.EC2](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html) in the API reference\. **Topics** + [Creating an Amazon EC2 Instance](ec2-example-creating-an-instance.md) + [Managing Amazon EC2 Instances](ec2-example-managing-instances.md) + [Working with Amazon EC2 Key Pairs](ec2-example-key-pairs.md) + [Using Regions and Availability Zones with Amazon EC2](ec2-example-regions-availability-zones.md) + [Working with Security Groups in Amazon EC2](ec2-example-security-groups.md) + [Using Elastic IP Addresses in Amazon EC2](ec2-example-elastic-ip-addresses.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/ec2-examples.md
c3e32168afa0-0
The default Node\.js HTTP/HTTPS agent creates a new TCP connection for every new request\. To avoid the cost of establishing a new connection, the SDK for JavaScript reuses TCP connections\. For short\-lived operations, such as Amazon DynamoDB queries, the latency overhead of setting up a TCP connection might be greater than the operation itself\. Additionally, since DynamoDB [encryption at rest](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/encryption.howitworks.html) is integrated with [AWS KMS](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/encryption.howitworks.html), you may experience latencies from the database having to re\-establish new AWS KMS cache entries for each operation\. To disable reusing TCP connections, set the `AWS_NODEJS_CONNECTION_REUSE_ENABLED` environment variable to `false` \(the default is `true`\)\. You can also disable keeping these connections alive on a per\-service client basis, as shown in the following example for a DynamoDB client\. ``` const NodeHttpHandler = require("@aws-sdk/node-http-handler") const dynamodbClient = new DynamoDBClient({ requestHandler: new NodeHttpHandler({ httpAgent: new Agent({keepAlive: false}) }) }) ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/node-reusing-connections.md
c3e32168afa0-1
httpAgent: new Agent({keepAlive: false}) }) }) ``` If `keepAlive` is enabled, you can also set the initial delay for TCP Keep\-Alive packets with `keepAliveMsecs`, which by default is 1000 ms\. See the [Node\.js documentation](https://nodejs.org/api/http.html) for details\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/node-reusing-connections.md
db6e0f730d3e-0
In this tutorial, you learn how to: + Create AWS Lambda functions in Node\.js and call them from JavaScript running in a web browser\. + Call another service within a Lambda function and process the asynchronous responses before forwarding those responses to the browser script\. + Use Node\.js scripts to create the resources needed by the Lambda function\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-functions.md
e6de731c91b4-0
In this example, a simulated browser\-based slot machine game invokes a Lambda function that generates the random results of each slot pull\. Those results are returned as the file names of the images that are used to display to the user\. The images are stored in an Amazon S3 bucket that is configured to function as a static web host for the HTML, CSS, and other assets used to present the application experience\. This diagram illustrates most of the elements in this application and how they relate to one another\. Versions of this diagram will appear throughout the tutorial to show the focus of each task ![\[JavaScript running in a browser that invokes a Lambda function\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/images/browser-calls-lambda-function.png)![\[JavaScript running in a browser that invokes a Lambda function\]](http://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/)![\[JavaScript running in a browser that invokes a Lambda function\]](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-functions.md
cb5f535a710e-0
You must complete the following tasks before you can begin the tutorial: + Install Node\.js on your computer to run various scripts that help set up the Amazon S3 bucket and the Amazon DynamoDB table, and create and configure the Lambda function\. The Lambda function itself runs in the AWS Lambda Node\.js environment\. For information about installing Node\.js, see [www\.nodejs\.org](http://www.nodejs.org)\. + Install the AWS SDK for JavaScript on your computer to run the setup scripts\. For information on installing the AWS SDK for JavaScript for Node\.js, see [Installing the SDK for JavaScript](installing-jssdk.md)\. The tutorial should take about 30 minutes to complete\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-sdk-for-javascript-v3/doc_source/using-lambda-functions.md