8000 feat: Update READMEs with Secret Manager info (#6262) · jasonfmorton/python-docs-samples@e3fb3cf · GitHub
[go: up one dir, main page]

Skip to content

Commit e3fb3cf

Browse files
authored
feat: Update READMEs with Secret Manager info (GoogleCloudPlatform#6262)
## Description Fixes #<ISSUE-NUMBER> Note: It's a good idea to open an issue first for discussion. ## Checklist - [ ] I have followed [Sample Guidelines from AUTHORING_GUIDE.MD](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md) - [ ] README is updated to include [all relevant information](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md#readme-file) - [ ] **Tests** pass: `nox -s py-3.6` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md#test-environment-setup)) - [ ] **Lint** pass: `nox -s lint` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md#test-environment-setup)) - [ ] These samples need a new **API enabled** in testing projects to pass (let us know which ones) - [ ] These samples need a new/updated **env vars** in testing projects set to pass (let us know which ones) - [ ] Please **merge** this PR for me once it is approved. - [ ] This sample adds a new sample directory, and I updated the [CODEOWNERS file](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/.github/CODEOWNERS) with the codeowners for this sample
1 parent 79435b4 commit e3fb3cf

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

cloud-sql/mysql/sqlalchemy/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,26 @@ instance configuration.
177177

178178
This step can be done as part of deployment but is separated for clarity.
179179

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+
180200
4. Navigate your browser to the URL noted in step 2.
181201

182202
For more details about using Cloud Run see http://cloud.run.

cloud-sql/postgres/sqlalchemy/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,26 @@ instance configuration.
175175

176176
This step can be done as part of deployment but is separated for clarity.
177177

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+
178198
4. Navigate your browser to the URL noted in step 2.
179199

180200
For more details about using Cloud Run see http://cloud.run.

0 commit comments

Comments
 (0)
0