我尝试通过 python API 创建一个 dataproc 集群,我使用包含凭据的 json 文件进行身份验证。
app = Flask(__name__)
# Explicitly use service account credentials by specifying the private key
# file.
credentials_gcp =
service_account.Credentials.from_service_account_file('credentials.json')
client = dataproc_v1.ClusterControllerClient(credentials = credentials_gcp)
clustertest = {
"project_id": "xxxx",
"cluster_name": "testcluster",
"config": {}
}
# launch cluster on Dataproc
@app.route('/cluster/<project_id>/<region>/<clustername>', methods=['POST'])
def cluster(project_id, region, clustername):
response = client.create_cluster(project_id, 'regions/europe-west1-b',
clustertest)
response.add_done_callback(callback)
result = response.metadata()
return jsonify(result)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
google.api_core.exceptions.PermissionDenied:403“locations/regions/europe-west1”的权限被拒绝(或者可能不存在)
我不知道是我没有正确的权限还是我的语法有错误