我正在使用 terraform 在 GCP 中构建基础设施。我正在尝试将角色分配给service account使用 terraform 的人,但无法这样做。下面是我的代码:
sa.tf:
resource "google_service_account" "mojo-terra" {
account_id = "mojo-terra"
description = "Service account used for terraform script"
}
resource "google_project_iam_member" "mojo-roles" {
count = length(var.rolesList)
role = var.rolesList[count.index]
member = "serviceAccount:${google_service_account.mojo-terra.email}"
}
Run Code Online (Sandbox Code Playgroud)
dev.tfvars:
rolesList = [
"roles/iam.serviceAccountUser"
]
Run Code Online (Sandbox Code Playgroud)
云构建日志:
Step #2: Error: Error when reading or editing Resource "project \"poc-dev\"" with IAM Policy: Error retrieving IAM policy for project "poc-dev": googleapi: Error 403: The caller does not have permission, forbidden
Step …Run Code Online (Sandbox Code Playgroud) google-cloud-platform terraform google-cloud-iam terraform-provider-gcp
我是 Openshift 的新手。我已经在 openshift 中部署了一个应用程序。当我检查日志时,某些文件存在权限被拒绝错误。现在,我想更改已部署在 Openshift 中的容器的权限,但收到“不允许操作”警告。我该如何解决 ?
这适用于运行最新版本 MongoDB 的 linux。我已经尝试在我的 docker 文件中执行 RUN chmod 777 /path/to/directory,创建图像并在我的 yaml 文件中提取相同的图像,我正在我的 openshift 中部署它。但是,当我检查我的 docker 容器时,它显示该目录的权限已更改,但是当我部署时,我在日志中收到警告为“权限被拒绝”。
FROM node:10.16.3
RUN apt update && apt install -y openjdk-8-jdk
RUN useradd -ms /bin/bash admin
# Set the workdir /var/www/myapp
WORKDIR /var/www/myapp
# Copy the package.json to workdir
COPY package.json .
# Run npm install - install the npm dependencies
RUN npm install
RUN npm install sqlite3
# Copy application source
COPY . .
RUN chown …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 GCP 中使用 terraform 创建 Firestore 索引。下面是我的 Terraform 脚本:
resource "google_firestore_index" "job_config1_index" {
project = var.projectId
collection = var.job_config_firestore
depends_on = [
"google_firestore_index.job_config4_index"
]
fields {
field_path = "customer_id"
order = "ASCENDING"
}
fields {
field_path = "job_type"
order = "ASCENDING"
}
fields {
field_path = "start_date_time"
order = "ASCENDING"
}
fields {
field_path = "__name__"
order = "ASCENDING"
}
}
Run Code Online (Sandbox Code Playgroud)
以下是日志:
Step #2: Error: Error waiting to create Index: Error waiting for Creating Index: timeout while waiting for state …Run Code Online (Sandbox Code Playgroud) 我使用 cloudbuild yaml 文件在 GCP 中部署云函数。但是,我想从部署中排除特定文件和目录。我该怎么做 ?
下面是我的 yaml 文件:
steps:
- name: 'node:10.10.0'
id: installing_npm
args: ['npm', 'install']
dir: 'API/groups'
- name: 'gcr.io/cloud-builders/gcloud'
id: deploy
args: [
'functions', 'deploy', 'groups',
'--region=us-central1',
'--source=.',
'--trigger-http',
'--runtime=nodejs8',
'--entry-point=App',
'--allow-unauthenticated',
'--service-account=xaxaxax@appspot.gserviceaccount.com'
]
dir: 'API/groups'
Run Code Online (Sandbox Code Playgroud)
下面附上截图。在此屏幕截图中,在groups目录中,我只想部署目录src和文件package.json,package-lock.json并从目录中排除其余部分。截至目前,组目录的全部内容正在部署,这是我不想要的。
基本上,我尝试使用 cloudbuild.yaml 文件部署云功能:
Cloudbuild.yaml
steps:
- name: 'node:10.10.0'
id: installing_npm
args: ['npm', 'install']
dir: 'API/groups'
- name: 'gcr.io/cloud-builders/gcloud'
id: deploy
args: [
'functions', 'deploy', 'groups',
'--region=us-central1',
'--source=https://source.cloud.google.com/$PROJECT_ID/bitbucket_zebraema_/+/LCM-97_groups_API_test:API/groups',
'--trigger-http',
'--runtime=nodejs8',
'--entry-point=App',
'--allow-unauthenticated',
'--service-account=xaxaxax@appspot.gserviceaccount.com'
]
dir: 'API/groups'
Run Code Online (Sandbox Code Playgroud)
下面是错误:
Step #0 - "installing_npm": npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
Step #0 - "installing_npm":
Step #0 - "installing_npm": added 448 packages from 284 contributors and audited 449 packages in 9.697s
Step #0 - "installing_npm": found 5 …Run Code Online (Sandbox Code Playgroud) google-cloud-platform google-cloud-functions google-cloud-build
我正在尝试获取我的 GCP 项目的项目名称。首先,我尝试使用命令:
gcloud projects describe $PROJECT_ID
Run Code Online (Sandbox Code Playgroud)
在这里您可以获取项目 ID、编号名称、组织和其他详细信息。
然后接下来使用grep命令获取项目名称。