How to call service in different region using lambda and AWS SDK

Viewed 725

Trying to call AWS Firehose service's PutRecord using AWS SDK from Lambda Function that located in different region using NodeJS environment. This works when Lambda Function and Firehose are in same region and not working when Function is in other region. Is there a setting of Firehose or IAM role attached to it that could allow these inter region calls?

2 Answers

You just specify the region name in your sdk. For example, the following should be enough in Python:

import boto3

client = boto3.client('firehose', region_name='us-west-2')

client.put_record(...)

No other special settings should be required.

In nodejs, it would be:


var fh = new AWS.Firehose({region: 'us-west-2'});

Problem was that I've set region incorrectly. Instead of specifying region just for Firehose, need to specify region for SDK:

Insted of:

const AWS = require('aws-sdk');
const firehose = new AWS.Firehose({ region: 'us-east-1' });

Using:

const AWS = require('aws-sdk');
AWS.config.update({ region: 'us-east-1' });
const firehose = new AWS.Firehose();
Related