LoginSignup
7
5

More than 5 years have passed since last update.

AWS SDK for Node.jsをProxy環境で使う

Posted at

環境

$node ---version
v0.10.33

$npm --version
1.4.28

以下でpackage.jsonを作成

$npm init

AWS-SDKとProxy用のモジュールをインストール。-saveオプションによってpackage.jsonに依存関係として追記する。

$npm install aws-sdk --save
$npm install proxy-agent --save

コードは以下のようにすればOK

Configuring the SDK in Node.js

var AWS = require('aws-sdk');
var proxy = require('proxy-agent');

AWS.config.update({
    httpOptions: { agent: proxy('http://host:port') }
});

var s3 = new AWS.S3();
s3.listBuckets(function(err, data) {
  if (err) console.log(err, err.stack);
  else console.log(data);
});

7
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5