Skip to content

Commit 2991f86

Browse files
authored
Rename CLOUD_SQL_CONNECTION_NAME to INSTANCE_CONNECTION_NAME (GoogleCloudPlatform#2435)
1 parent fd3ee99 commit 2991f86

File tree

12 files changed

+34
-41
lines changed

12 files changed

+34
-41
lines changed

.kokoro/build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ gcloud auth activate-service-account --key-file "$GOOGLE_APPLICATION_CREDENTIALS
109109
gcloud config set project $GOOGLE_CLOUD_PROJECT
110110

111111
export DB_SOCKET_PATH=$KOKORO_GFILE_DIR
112-
export CLOUD_SQL_CONNECTION_NAME=$INSTANCE_CONNECTION_NAME
113112

114113
# Download and run the proxy if testing a Cloud SQL sample
115114
if [[ $SQL_CLIENT ]]; then

cloud-sql/mysql/mysql/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Download a JSON key to use to authenticate your connection.
2121
1. Use the information noted in the previous steps:
2222
```bash
2323
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account/key.json
24-
export CLOUD_SQL_CONNECTION_NAME='<MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>'
24+
export INSTANCE_CONNECTION_NAME='<MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>'
2525
export DB_USER='my-db-user'
2626
export DB_PASS='my-db-pass'
2727
export DB_NAME='my_db'
@@ -91,7 +91,7 @@ export DB_SOCKET_PATH=/path/to/the/new/directory
9191
Use these terminal commands to initialize other environment variables as well:
9292
```bash
9393
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account/key.json
94-
export CLOUD_SQL_CONNECTION_NAME='<MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>'
94+
export INSTANCE_CONNECTION_NAME='<MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>'
9595
export DB_USER='<DB_USER_NAME>'
9696
export DB_PASS='<DB_PASSWORD>'
9797
export DB_NAME='<DB_NAME>'
@@ -100,7 +100,7 @@ export DB_NAME='<DB_NAME>'
100100
Then use this command to launch the proxy in the background:
101101

102102
```bash
103-
./cloud_sql_proxy -dir=$DB_SOCKET_PATH --instances=$CLOUD_SQL_CONNECTION_NAME --credential_file=$GOOGLE_APPLICATION_CREDENTIALS &
103+
./cloud_sql_proxy -dir=$DB_SOCKET_PATH --instances=$INSTANCE_CONNECTION_NAME --credential_file=$GOOGLE_APPLICATION_CREDENTIALS &
104104
```
105105

106106
### Testing the application
@@ -174,8 +174,8 @@ Take note of the URL output at the end of the deployment process.
174174

175175
```sh
176176
gcloud run services update run-sql \
177-
--add-cloudsql-instances [CLOUD_SQL_CONNECTION_NAME] \
178-
--set-env-vars CLOUD_SQL_CONNECTION_NAME=[CLOUD_SQL_CONNECTION_NAME],\
177+
--add-cloudsql-instances [INSTANCE_CONNECTION_NAME] \
178+
--set-env-vars INSTANCE_CONNECTION_NAME=[INSTANCE_CONNECTION_NAME],\
179179
DB_USER=[MY_DB_USER],DB_PASS=[MY_DB_PASS],DB_NAME=[MY_DB]
180180
```
181181
Replace environment variables with the correct values for your Cloud SQL
@@ -189,15 +189,15 @@ Secret Manager at runtime via an environment variable.
189189

190190
Create secrets via the command line:
191191
```sh
192-
echo -n $CLOUD_SQL_CONNECTION_NAME | \
193-
gcloud secrets create [CLOUD_SQL_CONNECTION_NAME_SECRET] --data-file=-
192+
echo -n $INSTANCE_CONNECTION_NAME | \
193+
gcloud secrets create [INSTANCE_CONNECTION_NAME_SECRET] --data-file=-
194194
```
195195

196196
Deploy the service to Cloud Run specifying the env var name and secret name:
197197
```sh
198198
gcloud beta run deploy SERVICE --image gcr.io/[YOUR_PROJECT_ID]/run-sql \
199-
--add-cloudsql-instances $CLOUD_SQL_CONNECTION_NAME \
200-
--update-secrets CLOUD_SQL_CONNECTION_NAME=[CLOUD_SQL_CONNECTION_NAME_SECRET]:latest,\
199+
--add-cloudsql-instances $INSTANCE_CONNECTION_NAME \
200+
--update-secrets INSTANCE_CONNECTION_NAME=[INSTANCE_CONNECTION_NAME_SECRET]:latest,\
201201
DB_USER=[DB_USER_SECRET]:latest, \
202202
DB_PASS=[DB_PASS_SECRET]:latest, \
203203
DB_NAME=[DB_NAME_SECRET]:latest

cloud-sql/mysql/mysql/app.flexible.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ env_variables:
2121
DB_PASS: MY_DB_PASSWORD
2222
DB_NAME: MY_DATABASE
2323
# e.g. my-awesome-project:us-central1:my-cloud-sql-instance
24-
CLOUD_SQL_CONNECTION_NAME: <MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>
24+
INSTANCE_CONNECTION_NAME: <MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>
2525

2626
beta_settings:
2727
# The connection name of your instance, available by using
2828
# 'gcloud beta sql instances describe [INSTANCE_NAME]' or from
2929
# the Instance details page in the Google Cloud Platform Console.
30-
cloud_sql_instances: <MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>
30+
cloud_sql_instances: <MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>

cloud-sql/mysql/mysql/app.standard.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ env_variables:
2020
DB_PASS: MY_DB_PASSWORD
2121
DB_NAME: MY_DATABASE
2222
# e.g. my-awesome-project:us-central1:my-cloud-sql-instance
23-
CLOUD_SQL_CONNECTION_NAME: <MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>
23+
INSTANCE_CONNECTION_NAME: <MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>

cloud-sql/mysql/mysql/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const createUnixSocketPool = async config => {
9494
password: process.env.DB_PASS, // e.g. 'my-db-password'
9595
database: process.env.DB_NAME, // e.g. 'my-database'
9696
// If connecting via unix domain socket, specify the path
97-
socketPath: `${dbSocketPath}/${process.env.CLOUD_SQL_CONNECTION_NAME}`,
97+
socketPath: `${dbSocketPath}/${process.env.INSTANCE_CONNECTION_NAME}`,
9898
// Specify additional properties here.
9999
...config,
100100
});

cloud-sql/postgres/knex/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Download a JSON key to use to authenticate your connection.
2020
5. Use the information noted in the previous steps:
2121
```bash
2222
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account/key.json
23-
export CLOUD_SQL_CONNECTION_NAME='<MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>'
23+
export INSTANCE_CONNECTION_NAME='<MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>'
2424
export DB_USER='my-db-user'
2525
export DB_PASS='my-db-pass'
2626
export DB_NAME='my_db'
@@ -92,7 +92,7 @@ export DB_SOCKET_PATH=/path/to/the/new/directory
9292
Use these terminal commands to initialize other environment variables as well:
9393
```bash
9494
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account/key.json
95-
export CLOUD_SQL_CONNECTION_NAME='<MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>'
95+
export INSTANCE_CONNECTION_NAME='<MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>'
9696
export DB_USER='<DB_USER_NAME>'
9797
export DB_PASS='<DB_PASSWORD>'
9898
export DB_NAME='<DB_NAME>'
@@ -101,7 +101,7 @@ export DB_NAME='<DB_NAME>'
101101
Then use this command to launch the proxy in the background:
102102

103103
```bash
104-
./cloud_sql_proxy -dir=$DB_SOCKET_PATH --instances=$CLOUD_SQL_CONNECTION_NAME --credential_file=$GOOGLE_APPLICATION_CREDENTIALS &
104+
./cloud_sql_proxy -dir=$DB_SOCKET_PATH --instances=$INSTANCE_CONNECTION_NAME --credential_file=$GOOGLE_APPLICATION_CREDENTIALS &
105105
```
106106

107107
### Testing the application
@@ -130,7 +130,7 @@ Navigate towards `http://127.0.0.1:8080` to verify your application is running c
130130
DB_PASS: MY_DB_PASSWORD
131131
DB_NAME: MY_DATABASE
132132
# e.g. my-awesome-project:us-central1:my-cloud-sql-instance
133-
CLOUD_SQL_CONNECTION_NAME: <MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>
133+
INSTANCE_CONNECTION_NAME: <MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>
134134
```
135135
136136
2. To deploy to App Engine Standard, run the following command:
@@ -155,7 +155,7 @@ Navigate towards `http://127.0.0.1:8080` to verify your application is running c
155155
DB_PASS: MY_DB_PASSWORD
156156
DB_NAME: MY_DATABASE
157157
# e.g. my-awesome-project:us-central1:my-cloud-sql-instance
158-
CLOUD_SQL_CONNECTION_NAME: <MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>
158+
INSTANCE_CONNECTION_NAME: <MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>
159159
```
160160
161161
2. To deploy to App Engine Node.js Flexible Environment, run the following command:
@@ -193,8 +193,8 @@ Take note of the URL output at the end of the deployment process.
193193

194194
```sh
195195
gcloud run services update run-sql \
196-
--add-cloudsql-instances [CLOUD_SQL_CONNECTION_NAME] \
197-
--set-env-vars CLOUD_SQL_CONNECTION_NAME=[CLOUD_SQL_CONNECTION_NAME],\
196+
--add-cloudsql-instances [INSTANCE_CONNECTION_NAME] \
197+
--set-env-vars INSTANCE_CONNECTION_NAME=[INSTANCE_CONNECTION_NAME],\
198198
DB_USER=[MY_DB_USER],DB_PASS=[MY_DB_PASS],DB_NAME=[MY_DB]
199199
```
200200
Replace environment variables with the correct values for your Cloud SQL
@@ -208,15 +208,15 @@ Secret Manager at runtime via an environment variable.
208208

209209
Create secrets via the command line:
210210
```sh
211-
echo -n $CLOUD_SQL_CONNECTION_NAME | \
212-
gcloud secrets create [CLOUD_SQL_CONNECTION_NAME_SECRET] --data-file=-
211+
echo -n $INSTANCE_CONNECTION_NAME | \
212+
gcloud secrets create [INSTANCE_CONNECTION_NAME_SECRET] --data-file=-
213213
```
214214

215215
Deploy the service to Cloud Run specifying the env var name and secret name:
216216
```sh
217217
gcloud beta run deploy SERVICE --image gcr.io/[YOUR_PROJECT_ID]/run-sql \
218-
--add-cloudsql-instances $CLOUD_SQL_CONNECTION_NAME \
219-
--update-secrets CLOUD_SQL_CONNECTION_NAME=[CLOUD_SQL_CONNECTION_NAME_SECRET]:latest,\
218+
--add-cloudsql-instances $INSTANCE_CONNECTION_NAME \
219+
--update-secrets INSTANCE_CONNECTION_NAME=[INSTANCE_CONNECTION_NAME_SECRET]:latest,\
220220
DB_USER=[DB_USER_SECRET]:latest, \
221221
DB_PASS=[DB_PASS_SECRET]:latest, \
222222
DB_NAME=[DB_NAME_SECRET]:latest

cloud-sql/postgres/knex/app.flexible.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ env_variables:
2121
DB_PASS: MY_DB_PASSWORD
2222
DB_NAME: MY_DATABASE
2323
# e.g. my-awesome-project:us-central1:my-cloud-sql-instance
24-
CLOUD_SQL_CONNECTION_NAME: <MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>
24+
INSTANCE_CONNECTION_NAME: <MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>
2525

2626
beta_settings:
2727
# The connection name of your instance, available by using
2828
# 'gcloud beta sql instances describe [INSTANCE_NAME]' or from
2929
# the Instance details page in the Google Cloud Platform Console.
30-
cloud_sql_instances: <MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>
30+
cloud_sql_instances: <MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>

cloud-sql/postgres/knex/app.standard.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ env_variables:
2020
DB_PASS: MY_DB_PASSWORD
2121
DB_NAME: MY_DATABASE
2222
# e.g. my-awesome-project:us-central1:my-cloud-sql-instance
23-
CLOUD_SQL_CONNECTION_NAME: <MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>
23+
INSTANCE_CONNECTION_NAME: <MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>
2424

2525
beta_settings:
2626
# The connection name of your instance, available by using
2727
# 'gcloud beta sql instances describe [INSTANCE_NAME]' or from
2828
# the Instance details page in the Google Cloud Platform Console.
29-
cloud_sql_instances: <MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>
29+
cloud_sql_instances: <MY-PROJECT>:<INSTANCE-REGION>:<INSTANCE-NAME>

cloud-sql/postgres/knex/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"node": ">=10.0.0"
1414
},
1515
"scripts": {
16-
"start-proxy": "! pgrep cloud_sql_proxy > /dev/null && cloud_sql_proxy -dir=/cloudsql -instances=$CLOUD_SQL_CONNECTION_NAME &",
16+
"start-proxy": "! pgrep cloud_sql_proxy > /dev/null && cloud_sql_proxy -dir=/cloudsql -instances=$INSTANCE_CONNECTION_NAME &",
1717
"test": "mocha test/*.test.js --timeout=60000 --exit"
1818
},
1919
"dependencies": {

cloud-sql/postgres/knex/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const createUnixSocketPool = async config => {
122122
user: process.env.DB_USER, // e.g. 'my-user'
123123
password: process.env.DB_PASS, // e.g. 'my-user-password'
124124
database: process.env.DB_NAME, // e.g. 'my-database'
125-
host: `${dbSocketPath}/${process.env.CLOUD_SQL_CONNECTION_NAME}`,
125+
host: `${dbSocketPath}/${process.env.INSTANCE_CONNECTION_NAME}`,
126126
},
127127
// ... Specify additional properties here.
128128
...config,

0 commit comments

Comments
 (0)