File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,26 @@ instance configuration.
177
177
178
178
This step can be done as part of deployment but is separated for clarity.
179
179
180
+ It is recommended to use the [ Secret Manager integration] ( https://cloud.google.com/run/docs/configuring/secrets ) for Cloud Run instead
181
+ of using environment variables for the SQL configuration. The service injects the SQL credentials from
182
+ Secret Manager at runtime via an environment variable.
183
+
184
+ Create secrets via the command line:
185
+ ``` sh
186
+ echo -n $CLOUD_SQL_CONNECTION_NAME | \
187
+ gcloud secrets create [CLOUD_SQL_CONNECTION_NAME_SECRET] --data-file=-
188
+ ```
189
+
190
+ Deploy the service to Cloud Run specifying the env var name and secret name:
191
+ ``` sh
192
+ gcloud beta run deploy SERVICE --image gcr.io/[YOUR_PROJECT_ID]/run-sql \
193
+ --add-cloudsql-instances $CLOUD_SQL_CONNECTION_NAME \
194
+ --update-secrets CLOUD_SQL_CONNECTION_NAME=[CLOUD_SQL_CONNECTION_NAME_SECRET]:latest,\
195
+ DB_USER=[DB_USER_SECRET]:latest, \
196
+ DB_PASS=[DB_PASS_SECRET]:latest, \
197
+ DB_NAME=[DB_NAME_SECRET]:latest
198
+ ```
199
+
180
200
4 . Navigate your browser to the URL noted in step 2.
181
201
182
202
For more details about using Cloud Run see http://cloud.run .
Original file line number Diff line number Diff line change @@ -175,6 +175,26 @@ instance configuration.
175
175
176
176
This step can be done as part of deployment but is separated for clarity.
177
177
178
+ It is recommended to use the [Secret Manager integration](https://cloud.google.com/run/docs/configuring/secrets) for Cloud Run instead
179
+ of using environment variables for the SQL configuration. The service injects the SQL credentials from
180
+ Secret Manager at runtime via an environment variable.
181
+
182
+ Create secrets via the command line:
183
+ ` ` ` sh
184
+ echo -n $CLOUD_SQL_CONNECTION_NAME | \
185
+ gcloud secrets create [CLOUD_SQL_CONNECTION_NAME_SECRET] --data-file=-
186
+ ` ` `
187
+
188
+ Deploy the service to Cloud Run specifying the env var name and secret name:
189
+ ` ` ` sh
190
+ gcloud beta run deploy SERVICE --image gcr.io/[YOUR_PROJECT_ID]/run-sql \
191
+ --add-cloudsql-instances $CLOUD_SQL_CONNECTION_NAME \
192
+ --update-secrets CLOUD_SQL_CONNECTION_NAME=[CLOUD_SQL_CONNECTION_NAME_SECRET]:latest,\
193
+ DB_USER=[DB_USER_SECRET]:latest, \
194
+ DB_PASS=[DB_PASS_SECRET]:latest, \
195
+ DB_NAME=[DB_NAME_SECRET]:latest
196
+ ` ` `
197
+
178
198
4. Navigate your browser to the URL noted in step 2.
179
199
180
200
For more details about using Cloud Run see http://cloud.run.
You can’t perform that action at this time.
0 commit comments