【问题标题】:Google Cloud Functions - how do I authenticate to AWS S3 bucket?Google Cloud Functions - 如何对 AWS S3 存储桶进行身份验证?
【发布时间】:2018-10-07 23:39:27
【问题描述】:

我正在尝试在 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 google-cloud-storage

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

编写这样一个函数的最佳方式是什么?

【问题讨论】:

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


    【解决方案1】:

    您可能希望改用 boto3 Python 包,因为命令行 AWS 工具不适用于 Cloud Functions 或无法安装。 There's a number of ways to configure credentials as well.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-20
      • 2016-05-15
      • 1970-01-01
      • 2019-09-16
      • 2018-07-09
      • 2018-07-23
      • 1970-01-01
      相关资源
      最近更新 更多