简体   繁体   English

如何从分段在 AWS 开发工具包中进行身份验证?

[英]How to authenticate in AWS SDK from segment?

I'm trying to call some AWS services from my segment function.我正在尝试从我的分段函数调用一些 AWS 服务。 To do that, I need to set the credentials for AWS, but I cannot find the way.为此,我需要为 AWS 设置凭证,但我找不到方法。

As you can see in the segment documentation , AWS is available.正如您在细分文档中所见, AWS可用。 The problems are:问题是:

  • I cannot use credential file (I only have one file in the segment funcion and cannot add more)我无法使用凭证文件(我在段功能中只有一个文件,无法添加更多文件)
  • I cannot use environment variables我不能使用环境变量

I have also tried the following:我还尝试了以下方法:

AWS.config.credentials.accessKeyId = "-";
AWS.config.credentials.secretAccessKey = "-";

That works locally with version 2.949.0 but not with v2.488.0 (the one provided by segment).这适用于版本2.949.0但不适用于v2.488.0 (由段提供的版本)。

Any idea how can I authenticate?知道如何进行身份验证吗? I have not found a way to authenticate using javascript code.我还没有找到使用 javascript 代码进行身份验证的方法。

Actually, I'm configuring my AWS credentials using实际上,我正在使用配置我的 AWS 凭证

AWS.config.update({
  region: 'us-east-1',
  accessKeyId: 'ACCESS_KEY',
  secretAccessKey: 'SECRET_KEY',
});

For example, to use S3 bucket例如,使用 S3 存储桶

import * as AWS from 'aws-sdk';

    AWS.config.update({
      region: 'us-east-1',
      accessKeyId: 'ACCESS_KEY',
      secretAccessKey: 'SECRET_KEY',
    });


const s3 = new AWS.S3();

// and do some manipulations with s3

I'm not used the segment, but I guess it should work.我没有使用该段,但我想它应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用AWS Cognito SDK使用NodeJS从REST服务验证用户? - How to use AWS Cognito SDK to authenticate user from REST Service using NodeJS? 无法通过节点SDK验证AWS IOT订阅 - Unable to authenticate aws iot subscribe through node sdk lambda 中的 AWS X-Ray NodeJs sdk,引发错误未指定子/段。 必须为手动模式提供子/段 - AWS X-Ray NodeJs sdk in lambda, throws error No sub/segment specified. A sub/segment must be provided for manual mode 如何在 Lambda 中只包含来自 aws-sdk 的一个类 - How to include only one class from aws-sdk in Lambda 如何使用NodeJs aws-sdk更改电子邮件的发件人名称 - How to change the Email FROM Name with NodeJs aws-sdk 如何使用 AWS SDK 解析 getThingShadow 的 json 结果 - How to parse the json result from getThingShadow, using AWS SDK 如何存根aws-sdk - How to stub aws-sdk 如何根据 aws cognito 中的特殊条件对用户进行身份验证 - How to authenticate user based on special condition in aws cognito 如何在 AWS Lambda 无服务器部署中对第三方 Webhook 请求进行身份验证 - How to authenticate third party webhook request in AWS Lambda serverless deployment 表达如何从 uri 段访问参数 - express how to access params from uri segment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM