![](/img/trans.png)
[英]c# How to identify accountId and Region in a AWS Lambda call?
[英]How to call service in different region using lambda and AWS SDK
嘗試使用 AWS SDK 從位於使用 NodeJS 環境的不同區域的 Lambda 函數調用 AWS Firehose 服務的 PutRecord。 這在 Lambda Function 和 Firehose 位於同一區域時有效,而在 Function 位於其他區域時不起作用。 是否有附加的 Firehose 或 IAM 角色設置可以允許這些區域間調用?
您只需在 sdk 中指定區域名稱。 例如,以下內容在 Python 中就足夠了:
import boto3
client = boto3.client('firehose', region_name='us-west-2')
client.put_record(...)
不需要其他特殊設置。
在nodejs 中,它將是:
var fh = new AWS.Firehose({region: 'us-west-2'});
問題是我錯誤地設置了區域。 不是只為 Firehose 指定區域,而是需要為 SDK 指定區域:
安裝於:
const AWS = require('aws-sdk');
const firehose = new AWS.Firehose({ region: 'us-east-1' });
使用:
const AWS = require('aws-sdk');
AWS.config.update({ region: 'us-east-1' });
const firehose = new AWS.Firehose();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.