Skip to content

Commit

Permalink
Add Secret Manager support on GCP (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
fcrespel committed Mar 16, 2024
1 parent d9bc0cc commit 8975670
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 54 deletions.
49 changes: 15 additions & 34 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<!-- Dependency properties -->
<commons-csv.version>1.10.0</commons-csv.version>
<guava.version>32.1.3-jre</guava.version>
<mysql-socket-factory.version>1.13.1</mysql-socket-factory.version>
<node.version>v18.19.0</node.version>
<npm.version>10.2.3</npm.version>
<socketio-client.version>1.0.1</socketio-client.version>
Expand Down Expand Up @@ -117,7 +116,19 @@
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-logging</artifactId>
<artifactId>spring-cloud-gcp-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-sql-mysql</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-sql-postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
Expand Down Expand Up @@ -172,17 +183,13 @@
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory-connector-j-8</artifactId>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>

<!-- Tests -->
Expand Down Expand Up @@ -210,11 +217,6 @@
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory-connector-j-8</artifactId>
<version>${mysql-socket-factory.version}</version>
</dependency>
<dependency>
<groupId>io.socket</groupId>
<artifactId>socket.io-client</artifactId>
Expand Down Expand Up @@ -512,27 +514,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>appengine-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${appengine.build.directory}</outputDirectory>
<resources>
<resource>
<directory>${appengine.src.directory}/files</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/appengine/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ handlers:
script: auto
env_variables:
JAVA_TOOL_OPTIONS: "-XX:MaxRAM=1024m -Xms512m -Xmx512m -Xverify:none -XX:+TieredCompilation -XX:TieredStopAtLevel=1"
SPRING_PROFILES_ACTIVE: "gcp,appengine"
SPRING_PROFILES_ACTIVE: "gcp"
automatic_scaling:
min_instances: 0
max_instances: 3
Expand Down
1 change: 0 additions & 1 deletion src/main/appengine/files/.gitignore

This file was deleted.

18 changes: 0 additions & 18 deletions src/main/appengine/files/application.example.yml

This file was deleted.

25 changes: 25 additions & 0 deletions src/main/resources/application-gcp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
spring:
cloud:
gcp:
sql:
enabled: true
instance-connection-name: "${sm://${SECRET_PREFIX:karaplan}-db-instance}"
database-name: "${sm://${SECRET_PREFIX:karaplan}-db-name}"
config:
import: sm://
datasource:
username: "${sm://${SECRET_PREFIX:karaplan}-db-username}"
password: "${sm://${SECRET_PREFIX:karaplan}-db-password}"
security:
oauth2:
client:
registration:
google:
client-id: "${sm://${SECRET_PREFIX:karaplan}-google-client-id}"
client-secret: "${sm://${SECRET_PREFIX:karaplan}-google-client-secret}"
github:
client-id: "${sm://${SECRET_PREFIX:karaplan}-github-client-id}"
client-secret: "${sm://${SECRET_PREFIX:karaplan}-github-client-secret}"
facebook:
client-id: "${sm://${SECRET_PREFIX:karaplan}-facebook-client-id}"
client-secret: "${sm://${SECRET_PREFIX:karaplan}-facebook-client-secret}"
4 changes: 4 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ spring:
cache:
jcache:
config: classpath:ehcache.xml
cloud:
gcp:
sql:
enabled: false
h2:
console:
enabled: false
Expand Down

0 comments on commit 8975670

Please sign in to comment.