我正在尝试使用 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/