Aflext
Aflext

Reputation: 309

How to create s3 connection with empty region using aws-js-sdk

I use ceph service in my company with empty region, so i can only create s3 connection without region. Bug the aws-js-sdk will specify the region to us-east-1, how can i ignore this? It will shows error like getaddrinfo ENOTFOUND...;

const AWS = require('aws-sdk');
const getS3Instance = () => new AWS.S3({
    accessKeyId: 'xxx',
    secretAccessKey: 'xxx',
    endpoint: `...local`,
    sslEnabled: false,
    region: ''
});

try {
    const s3 = getS3Instance();
    const creatBucketRes = await s3.createBucket({ Bucket: `bucket-test` }).promise();
} catch(err) {
    console.log(err);
}

Upvotes: 1

Views: 473

Answers (1)

Kannaiyan
Kannaiyan

Reputation: 13035

You need to set which region the bucket is located in,

AWS.config.update({region: 'ap-northeast-2  '});

Reference:

http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-region.html

Upvotes: 2

Related Questions