npm install aws-sdk –save

npm install の–saveオプションって何?
-> パッケージをインストールして、package.jsonに書き込む

[vagrant@localhost ses]$ npm -v
6.1.0
[vagrant@localhost ses]$ npm install aws-sdk –save
npm WARN saveError ENOENT: no such file or directory, open ‘/home/vagrant/local/app/test/package.json’
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open ‘/home/vagrant/local/app/test/package.json’
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README data
npm WARN test No license field.

+ aws-sdk@2.487.0
added 39 packages from 85 contributors, removed 30 packages, updated 1 package and audited 52 packages in 30.333s
found 0 vulnerabilities
あれ、package.jsonがないです。

AWS credentialsを設定し、メール送信する

var AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});

var ses = new AWS.SES();

var params = {
	Destination: {
		ToAddresses: [ 'hoge@example.com' ]
	},
	Message: {
			Body: {
				Text: {
						Data: 'hello SES',
						Charset: 'utf-8'
				}
			},
			Subject: {
				Data: 'Hello',
				Charset: 'utf-8'
			}
	},
	Source: 'jiro@example.com'
};

ses.sendEmail(params, function(err, data){
	if(err) console.log(err, err.stack);
	else console.log(data);
});

jsonか。。