我有部署在默认 VPC 中的 Lambda,该 VPC 具有开放的 Endpoint to S3 服务,Lambda 具有广泛开放所有 S3 操作的 IAM 角色
iamRoleStatements:
- Effect: "Allow"
Action:
- "rds:*"
- "ec2:CreateNetworkInterface"
Resource: "*"
- Effect: Allow
Action:
- s3:*
Resource: "*"
我通过以下方式访问 NodeJS 中的 S3 SDK:
const {
DIGITAL_OCEAN_SPACES_ENDPOINT,
DIGITAL_OCEAN_SPACES_ACCESS,
DIGITAL_OCEAN_SPACES_REGION,
DIGITAL_OCEAN_SPACES_SECRET,
DIGITAL_OCEAN_SPACES_BUCKET_NAME,
} = process.env;
const spacesEndpoint = new Endpoint(DIGITAL_OCEAN_SPACES_ENDPOINT);
const S3Client = new S3({
accessKeyId: DIGITAL_OCEAN_SPACES_ACCESS,
endpoint: spacesEndpoint,
region: DIGITAL_OCEAN_SPACES_REGION,
secretAccessKey: DIGITAL_OCEAN_SPACES_SECRET,
});
并且 Lambda 超时 - 它无法连接到 DigitalOcean S3 存储桶。我还需要添加什么才能访问 DO?