8000 chore: rename CLOUD_SQL_CONNECTION_NAME to INSTANCE_CONNECTION_NAME (… · qursaan/java-docs-samples@a469e8a · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit a469e8a

Browse files
authored
chore: rename CLOUD_SQL_CONNECTION_NAME to INSTANCE_CONNECTION_NAME (GoogleCloudPlatform#6162)
1 parent 5b1565f commit a469e8a

File tree

25 files changed

+63
-63
lines changed

25 files changed

+63
-63
lines changed

cloud-sql/mysql/client-side-encryption/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ by following these [instructions](https://cloud.google.com/kms/docs/iam).
2626
## Running Locally
2727

2828
Before running, copy the `example.envrc` file to `.envrc` and replace the values for
29-
`GOOGLE_APPLICATION_CREDENTIALS`, `DB_USER`, `DB_PASS`, `DB_NAME`, `CLOUD_SQL_CONNECTION_NAME`,
29+
`GOOGLE_APPLICATION_CREDENTIALS`, `DB_USER`, `DB_PASS`, `DB_NAME`, `INSTANCE_CONNECTION_NAME`,
3030
and `CLOUD_KMS_URI` with the values from your project. Then run `source .envrc` or optionally use
3131
[direnv](https://direnv.net/).
3232

cloud-sql/mysql/client-side-encryption/example.envrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ GOOGLE_APPLICATION_CREDENTIALS='path/to/service-account-key.json'
1818
DB_USER='your-database-username'
1919
DB_PASS='your-database-password'
2020
DB_NAME='your_database_name'
21-
CLOUD_SQL_CONNECTION_NAME='project:region:instance-name'
21+
INSTANCE_CONNECTION_NAME='project:region:instance-name'
2222
CLOUD_KMS_URI='gcp-kms://your-kms-uri`

cloud-sql/mysql/client-side-encryption/src/main/java/cloudsql/tink/CloudSqlConnectionPool.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
public class CloudSqlConnectionPool {
2929

3030
public static DataSource createConnectionPool(String dbUser, String dbPass, String dbName,
31-
String cloudSqlConnectionName) {
31+
String instanceConnectionName) {
3232
HikariConfig config = new HikariConfig();
3333
config.setJdbcUrl(String.format("jdbc:mysql:///%s", dbName));
3434
config.setUsername(dbUser);
3535
config.setPassword(dbPass);
3636
config.addDataSourceProperty("socketFactory", "com.google.cloud.sql.mysql.SocketFactory");
37-
config.addDataSourceProperty("cloudSqlInstance", cloudSqlConnectionName);
37+
config.addDataSourceProperty("cloudSqlInstance", instanceConnectionName);
3838
DataSource pool = new HikariDataSource(config);
3939
return pool;
4040
}

cloud-sql/mysql/client-side-encryption/src/main/java/cloudsql/tink/EncryptAndInsertData.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public static void main(String[] args) throws GeneralSecurityException, SQLExcep
3535
String dbUser = System.getenv("DB_USER"); // e.g. "root", "mysql"
3636
String dbPass = System.getenv("DB_PASS"); // e.g. "mysupersecretpassword"
3737
String dbName = System.getenv("DB_NAME"); // e.g. "votes_db"
38-
String cloudSqlConnectionName =
39-
System.getenv("CLOUD_SQL_CONNECTION_NAME"); // e.g. "project-name:region:instance-name"
38+
String instanceConnectionName =
39+
System.getenv("INSTANCE_CONNECTION_NAME"); // e.g. "project-name:region:instance-name"
4040
String kmsUri = System.getenv("CLOUD_KMS_URI"); // e.g. "gcp-kms://projects/...path/to/key
4141
// Tink uses the "gcp-kms://" prefix for paths to keys stored in Google Cloud KMS. For more
4242
// info on creating a KMS key and getting its path, see
@@ -49,7 +49,7 @@ public static void main(String[] args) throws GeneralSecurityException, SQLExcep
4949
// Initialize database connection pool and create table if it does not exist
5050
// See CloudSqlConnectionPool.java for setup details
5151
DataSource pool =
52-
CloudSqlConnectionPool.createConnectionPool(dbUser, dbPass, dbName, cloudSqlConnectionName);
52+
CloudSqlConnectionPool.createConnectionPool(dbUser, dbPass, dbName, instanceConnectionName);
5353
CloudSqlConnectionPool.createTable(pool, tableName);
5454

5555
// Initialize envelope AEAD

cloud-sql/mysql/client-side-encryption/src/main/java/cloudsql/tink/QueryAndDecryptData.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public static void main(String[] args) throws GeneralSecurityException, SQLExcep
3535
String dbUser = System.getenv("DB_USER"); // e.g. "root", "mysql"
3636
String dbPass = System.getenv("DB_PASS"); // e.g. "mysupersecretpassword"
3737
String dbName = System.getenv("DB_NAME"); // e.g. "votes_db"
38-
String cloudSqlConnectionName =
39-
System.getenv("CLOUD_SQL_CONNECTION_NAME"); // e.g. "project-name:region:instance-name"
38+
String instanceConnectionName =
39+
System.getenv("INSTANCE_CONNECTION_NAME"); // e.g. "project-name:region:instance-name"
4040
String kmsUri = System.getenv("CLOUD_KMS_URI"); // e.g. "gcp-kms://projects/...path/to/key
4141
// Tink uses the "gcp-kms://" prefix for paths to keys stored in Google Cloud KMS. For more
4242
// info on creating a KMS key and getting its path, see
@@ -47,7 +47,7 @@ public static void main(String[] args) throws GeneralSecurityException, SQLExcep
4747
// Initialize database connection pool and create table if it does not exist
4848
// See CloudSqlConnectionPool.java for setup details
4949
DataSource pool =
50-
CloudSqlConnectionPool.createConnectionPool(dbUser, dbPass, dbName, cloudSqlConnectionName);
50+
CloudSqlConnectionPool.createConnectionPool(dbUser, dbPass, dbName, instanceConnectionName);
5151
CloudSqlConnectionPool.createTable(pool, tableName);
5252

5353
// Initialize envelope AEAD

cloud-sql/mysql/servlet/README.md

Lines changed: 5 additions & 5 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>:<INSTANCE-NAME>'
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'
@@ -85,7 +85,7 @@ mvn clean package com.google.cloud.tools:jib-maven-plugin:2.8.0:build \
8585
--platform managed \
8686
--allow-unauthenticated \
8787
--region [REGION] \
88-
--update-env-vars CLOUD_SQL_CONNECTION_NAME=[CLOUD_SQL_CONNECTION_NAME] \
88+
--update-env-vars INSTANCE_CONNECTION_NAME=[INSTANCE_CONNECTION_NAME] \
8989
--update-env-vars DB_USER=[MY_DB_USER] \
9090
--update-env-vars DB_PASS=[MY_DB_PASS] \
9191
--update-env-vars DB_NAME=[MY_DB]
@@ -103,14 +103,14 @@ mvn clean package com.google.cloud.tools:jib-maven-plugin:2.8.0:build \
103103
Create secrets via the command line:
104104
```sh
105105
echo -n "my-awesome-project:us-central1:my-cloud-sql-instance" | \
106-
gcloud secrets versions add CLOUD_SQL_CONNECTION_NAME_SECRET --data-file=-
106+
gcloud secrets versions add INSTANCE_CONNECTION_NAME_SECRET --data-file=-
107107
```
108108

109109
Deploy the service to Cloud Run specifying the env var name and secret name:
110110
```sh
111111
gcloud beta run deploy SERVICE --image gcr.io/[YOUR_PROJECT_ID]/run-sql \
112-
--add-cloudsql-instances [CLOUD_SQL_CONNECTION_NAME] \
113-
--update-secrets CLOUD_SQL_CONNECTION_NAME=[CLOUD_SQL_CONNECTION_NAME_SECRET]:latest,\
112+
--add-cloudsql-instances [INSTANCE_CONNECTION_NAME] \
113+
--update-secrets INSTANCE_CONNECTION_NAME=[INSTANCE_CONNECTION_NAME_SECRET]:latest,\
114114
DB_USER=[DB_USER_SECRET]:latest, \
115115
DB_PASS=[DB_PASS_SECRET]:latest, \
116116
DB_NAME=[DB_NAME_SECRET]:latest

cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public class ConnectionPoolContextListener implements ServletContextListener {
3636

3737
// Saving credentials in environment variables is convenient, but not secure - consider a more
3838
// secure solution such as https://cloud.google.com/kms/ to help keep secrets safe.
39-
private static final String CLOUD_SQL_CONNECTION_NAME =
40-
System.getenv("CLOUD_SQL_CONNECTION_NAME");
39+
private static final String INSTANCE_CONNECTION_NAME =
40+
System.getenv("INSTANCE_CONNECTION_NAME");
4141
private static final String DB_USER = System.getenv("DB_USER");
4242
private static final String DB_PASS = System.getenv("DB_PASS");
4343
private static final String DB_NAME = System.getenv("DB_NAME");
@@ -55,7 +55,7 @@ private DataSource createConnectionPool() {
5555
HikariConfig config = new HikariConfig();
5656

5757
// The following URL is equivalent to setting the config options below:
58-
// jdbc:mysql:///<DB_NAME>?cloudSqlInstance=<CLOUD_SQL_CONNECTION_NAME>&
58+
// jdbc:mysql:///<DB_NAME>?cloudSqlInstance=<INSTANCE_CONNECTION_NAME>&
5959
// socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=<DB_USER>&password=<DB_PASS>
6060
// See the link below for more info on building a JDBC URL for the Cloud SQL JDBC Socket Factory
6161
// https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#creating-the-jdbc-url
@@ -66,7 +66,7 @@ private DataSource createConnectionPool() {
6666
config.setPassword(DB_PASS); // e.g. "my-password"
6767

6868
config.addDataSourceProperty("socketFactory", "com.google.cloud.sql.mysql.SocketFactory");
69-
config.addDataSourceProperty("cloudSqlInstance", CLOUD_SQL_CONNECTION_NAME);
69+
config.addDataSourceProperty("cloudSqlInstance", INSTANCE_CONNECTION_NAME);
7070

7171
// The ipTypes argument can be used to specify a comma delimited list of preferred IP types
7272
// for connecting to a Cloud SQL instance. The argument ipTypes=PRIVATE will force the

cloud-sql/mysql/servlet/src/main/webapp/WEB-INF/appengine-web.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<threadsafe>true</threadsafe>
1919
<runtime>java8</runtime>
2020
<env-variables>
21-
<env-var name="CLOUD_SQL_CONNECTION_NAME" value="my-project:region:instance" />
21+
<env-var name="INSTANCE_CONNECTION_NAME" value="my-project:region:instance" />
2222
<env-var name="DB_USER" value="my-db-user" />
2323
<env-var name="DB_PASS" value="my-db-password" />
2424
<env-var name="DB_NAME" value="my_db" />

cloud-sql/postgres/client-side-encryption/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ by following these [instructions](https://cloud.google.com/kms/docs/iam).
2626
## Running Locally
2727

2828
Before running, copy the `example.envrc` file to `.envrc` and replace the values for
29-
`GOOGLE_APPLICATION_CREDENTIALS`, `DB_USER`, `DB_PASS`, `DB_NAME`, `CLOUD_SQL_CONNECTION_NAME`,
29+
`GOOGLE_APPLICATION_CREDENTIALS`, `DB_USER`, `DB_PASS`, `DB_NAME`, `INSTANCE_CONNECTION_NAME`,
3030
and `CLOUD_KMS_URI` with the values from your project. Then run `source .envrc` or optionally use
3131
[direnv](https://direnv.net/).
3232

cloud-sql/postgres/client-side-encryption/example.envrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ GOOGLE_APPLICATION_CREDENTIALS='path/to/service-account-key.json'
1818
DB_USER='your-database-username'
1919
DB_PASS='your-database-password'
2020
DB_NAME='your_database_name'
21-
CLOUD_SQL_CONNECTION_NAME='project:region:instance-name'
21+
INSTANCE_CONNECTION_NAME='project:region:instance-name'
2222
CLOUD_KMS_URI='gcp-kms://your-kms-uri`

0 commit comments

Comments
 (0)
0