小编sin*_*ngh的帖子

配置中缺少凭证,如果使用 AWS_CONFIG_FILE,请设置 AWS_SDK_LOAD_CONFIG=1

当我尝试在我的项目中使用 Aws 凭据时,它给出了一个错误,我很难找到解决方案,当我在同一个文件中使用凭据时,它可以工作,但是当我尝试使用时。这是我尝试过的代码

const AWS = require('aws-sdk');


const SESConfig = {
    apiVersion: "2010-12-01",
    accessKeyId: process.env.AWS_SECRET_KEY,
    accessSecretKey: process.env.AWS_SECRET_KEY,
    region: "us-east-1"
}
AWS.config.update(SESConfig);
var sns = new AWS.SNS()
var sns = new AWS.SNS();

function sendSMS(to_number, message, cb) {

    sns.publish({
        Message: message,
        Subject: 'Admin',
        PhoneNumber:to_number
    }, cb);

  }

  // Example
  const PhoneNumberArray = ['any mobile number']
  PhoneNumberArray.forEach(number => {
    sendSMS(number, "Lorem Ipsum is simply dummy text of the printing and typesetting industry.", (err, result)=>{
        console.log("RESULTS: ",err,result)
      })
  })
Run Code Online (Sandbox Code Playgroud)

amazon-web-services node.js aws-config

41
推荐指数
6
解决办法
7万
查看次数

标签 统计

amazon-web-services ×1

aws-config ×1

node.js ×1