简体   繁体   English

向 AWS 上的 S3 存储桶发送请求时出现问题

[英]Issue with sending requests to S3 bucket on AWS

I am using Amazon's sample code to connect to my S3 bucket.我正在使用 Amazon 的示例代码连接到我的 S3 存储桶。 I have changed the key and bucket name for that of my bucket in S3.我已经更改了 S3 中我的存储桶的密钥和存储桶名称。 I have tried using the standard bucket name and using access points however I am still getting the following error.我已尝试使用标准存储桶名称并使用访问点,但我仍然收到以下错误。

Error CredentialsProviderError: Could not load credentials from any providers

I am unsure what exactly this error is saying I have missed, and also what credentials I need and how to recieve them.我不确定这个错误到底在说我错过了什么,也不确定我需要什么凭证以及如何接收它们。

I am relatively new to AWS so any help would be much appreciated.我对 AWS 比较陌生,因此非常感谢任何帮助。

I am running my code to access the bucket on an EC2 instance within the same VPC as the bucket so I was assuming I would not need additional permissions or credentials.我正在运行我的代码以访问与存储桶位于同一 VPC 内的 EC2 实例上的存储桶,因此我假设我不需要额外的权限或凭据。

I am relatively new to AWS so any help would be much appreciated.我对 AWS 比较陌生,因此非常感谢任何帮助。

EC2 instances use instance profiles (which are actually IAM Roles ) to determine their access permissions. EC2 实例使用instance profiles (实际上是IAM Roles )来确定它们的访问权限。

What you need to do:你需要做什么:

  1. Go to IAM Go 至IAM
  2. Create a Role for EC2为 EC2 创建角色
  3. Attach permissions to the Role (either create a new policy, or attach some AWS Managed policy, like AmazonS3FullAccess or AmazonS3ReadOnlyAccess depending on if you want just read permissions or write as well)将权限附加到角色(创建新策略或附加某些 AWS 托管策略,如AmazonS3FullAccessAmazonS3ReadOnlyAccess ,具体取决于您是只想要读取权限还是写入权限)
  4. Go to EC2 Go 到 EC2
  5. Select EC2 instance Select EC2实例
  6. Actions -> Security - Modify IAM Role

You can read more in AWS official documentation regarding Instance profiles您可以在 AWS 官方文档中阅读有关实例配置文件的更多信息

This error message means your application cannot find the credentials (An access key ID, A secret access key) required to use the AWS SDK for JavaScript. As you are using the JavaScript SDK, you need to read the JavaScript Developer Guide here:此错误消息表示您的应用程序找不到将 AWS SDK 用于 JavaScript 所需的凭据(An access key ID,A secret access key)。由于您正在使用 JavaScript SDK,因此您需要阅读此处的JavaScript 开发人员指南

https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/getting-your-credentials.html https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/getting-your-credentials.html

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM