python - Google Cloud Functions - 如何对 AWS S3 存储桶进行身份验证?

标签 python amazon-s3 google-cloud-platform google-cloud-functions

我正在尝试使用 Python 3.7 获取 Google Cloud Function,以从 Google Cloud Storage 获取文件并将其上传到 AWS S3。在命令行中,我将使用 awscli 进行身份验证,然后使用 gsutil cp 命令复制文件。我已经将这个过程翻译成Python:

import subprocess
def GCS_to_s3(arg1, arg2):
    subprocess.call(["aws configure set aws_access_key_id AKIA********"], shell=True)
    subprocess.call(["aws configure set aws_secret_access_key EgkjntEFFDVej"], shell=True)
    subprocess.call(["gsutil cp gs://test_bucket/gcs_test.csv s3://mybucket)"], shell=True)`

requirements.txt 是:

awscli 谷歌云存储

此函数已成功部署并成功运行,但输出未显示在 S3 存储桶中。

编写这样的函数的最佳方法是什么?

最佳答案

您可能想要使用 boto3而是使用 Python 包,因为 Cloud Functions 无法使用或安装命令行 AWS 工具。 There's a number of ways to configure credentials as well .

关于python - Google Cloud Functions - 如何对 AWS S3 存储桶进行身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52693824/

相关文章:

node.js - 超出配额指标 'speech.googleapis.com/default_requests' 的配额不太能理解

python - 在skimage中裁剪图像?

python - scipy.optimize curve_fit 返回错误值(取决于机器)

Python tcp 发送接收函数

python - 语法错误: unexpected EOF while parsing input commands

python - 在 S3 上使用 boto 库

python - Boto3 S3 实例的 AWS 凭证放置在哪里

api - 存储桶策略中的Amazon S3无效主体

google-cloud-platform - 使用sendgrid和Google云平台发送电子邮件

google-cloud-platform - gcloud - 即使我是所有者并且通过 Web UI 工作正常,也没有任何 API 的权限