如何使用 Google Cloud Composer CLI 设置 AWS 凭证?

How do I set AWS credentials using the Google Cloud Composer CLI?

我想从我的 cloud-composer 管理的气流系统访问 AWS 服务。我不想从气流 UI 中进行设置——我想使用 Google Cloud SDK 作为 CLI。

我唯一的选择是使用 CLI 的 env-variables 选项吗?如果是这样,我只设置 AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY 环境变量就足够了吗?或者我是否需要设置很多特定于气流的连接变量,例如对于 s3 AIRFLOW_CONN_S3_DEFAULT?

您可以使用 gcloud composer environment run 通过 Cloud Composer SDK CLI 隧道传输气流命令。例如:

gcloud config set composer/location {your-env-location}
gcloud composer environments run {your-env-name} connections -- -a --conn_id your-aws-id --conn_type aws {any other connection details}

因此,如果您想更新名为 my-env 的环境的 aws_default 连接,您首先要删除预先存在的条目(此 connection_id 已预先填充通过气流)使用以下命令:

gcloud composer environments run my-env connections -- -d --conn_id aws_default

然后按如下方式添加您的凭据:

gcloud composer environments run data-lake connections -- -a --conn_id aws_default --conn_type aws --conn_extra '{"region_name": "us-east-1", "aws_access_key_id":"YOUR_ACCESS_KEY_HERE", "aws_secret_access_key": "YOUR_SECRET_KEY_HERE"}'

当然,您需要相应地更新 AWS 区域名称和凭据。