Skip to content

Commit

Permalink
fix: update application.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
laigasus committed Apr 27, 2024
1 parent 8eadab3 commit 51c3687
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ spring:
baseline-on-migrate: true
init-sqls: "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'blisgo';"

docker:
compose:
enabled: true

server:
servlet:
session:
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
spring:
config:
activate:
on-profile: prod

data:
redis:
host: ${REDISHOST}
Expand Down Expand Up @@ -29,6 +33,10 @@ spring:
password: ${MYSQLPASSWORD}
driver-class-name: com.mysql.cj.jdbc.Driver

docker:
compose:
enabled: false

server:
servlet:
session:
Expand Down
27 changes: 27 additions & 0 deletions vault.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Vault 접속을 위한 토큰 생성
HCP_API_TOKEN=$(curl --location "https://auth.idp.hashicorp.com/oauth2/token" \
--header "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "client_id=$HCP_CLIENT_ID" \
--data-urlencode "client_secret=$HCP_CLIENT_SECRET" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "audience=https://api.hashicorp.cloud" | jq -r .access_token)

# Vault에서 JSON 값을 받아옴
VAULT_JSON=$(curl --location "https://api.cloud.hashicorp.com/secrets/2023-06-13/organizations/1f81c43a-c020-4e89-9fff-a97504adda1c/projects/705e4885-3d57-4917-a218-1151c919b909/apps/blisgo/open" \
--request GET \
--header "Authorization: Bearer $HCP_API_TOKEN")

# JSON에서 필요한 값을 추출하고 이를 환경변수로 설정
for row in $(echo "${VAULT_JSON}" | jq -r '.secrets[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}

key=$(_jq '.name')
value=$(_jq '.version.value')

export $key=$value

# 설정된 환경변수의 키-값 쌍 출력
echo "$key=$value"
done

0 comments on commit 51c3687

Please sign in to comment.