Skip to content

Commit f1448bb

Browse files
authored
feat(Config): Adds generic region and access creds for easier stack creation (LLC-1667) (#859)
1 parent 682da29 commit f1448bb

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

.env.example

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,28 @@ EXPRESS_PORT=8081
8282
#WINSTON_CLOUDWATCH_ACCESS_KEY_ID=
8383
#WINSTON_CLOUDWATCH_SECRET_ACCESS_KEY=
8484
#WINSTON_CLOUDWATCH_REGION=
85+
#WINSTON_CLOUDWATCH_LOG_STREAM_NAME=
86+
87+
###############
88+
# Statements #
89+
###############
90+
# Set if you'd like the statement service to remove nullified fields
91+
#SERVICE_REMOVE_NULLS=false
8592

8693
###############################
8794
# Statement handling priority #
8895
###############################
89-
9096
# Uncomment next line if you want to enable statement handling priority
9197
#ENABLE_QUEUE_PRIORITY=true
98+
99+
##########
100+
# Misc #
101+
##########
102+
# If set this will override AWS region for FS_S3_REGION and WINSTON_CLOUDWATCH_REGION
103+
#GLOBAL_AWS_REGION=
104+
105+
# If set this will override AWS access key id for FS_S3_ACCESS_KEY_ID and WINSTON_CLOUDWATCH_ACCESS_KEY_ID
106+
#GLOBAL_AWS_IAM_ACCESS_KEY_ID=
107+
108+
# If set this will override AWS access secret for FS_S3_SECRET_ACCESS_KEY and WINSTON_CLOUDWATCH_SECRET_ACCESS_KEY
109+
#GLOBAL_AWS_IAM_SECRET_ACCESS_KEY=

src/config.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const newRelicLicenseKey = getStringOption(process.env.NEW_RELIC_LICENSE_KEY, ''
2525
const defaultMongoUrl = 'mongodb://localhost:27017/learninglocker_v2';
2626
const mongoUrl = getStringOption(process.env.MONGO_URL, defaultMongoUrl);
2727

28+
const globalAwsRegion = process.env.GLOBAL_AWS_REGION;
29+
const globalAwsIamAccessKeyId = process.env.GLOBAL_AWS_IAM_ACCESS_KEY_ID;
30+
const globalAwsIamAccessKeySecret = process.env.GLOBAL_AWS_IAM_SECRET_ACCESS_KEY;
31+
2832
export default {
2933
defaultTimeout: getNumberOption(process.env.DEFAULT_TIMEOUT_MS, DEFAULT_TIMEOUT_MS),
3034
isQueuePriorityEnabled: process.env.ENABLE_QUEUE_PRIORITY === 'true',
@@ -68,10 +72,13 @@ export default {
6872
},
6973
s3StorageRepo: {
7074
awsConfig: {
71-
accessKeyId: getStringOption(process.env.FS_S3_ACCESS_KEY_ID),
75+
accessKeyId: getStringOption(process.env.FS_S3_ACCESS_KEY_ID, globalAwsIamAccessKeyId),
7276
apiVersion: '2006-03-01',
73-
region: getStringOption(process.env.FS_S3_REGION),
74-
secretAccessKey: getStringOption(process.env.FS_S3_SECRET_ACCESS_KEY),
77+
region: getStringOption(process.env.FS_S3_REGION, globalAwsRegion),
78+
secretAccessKey: getStringOption(
79+
process.env.FS_S3_SECRET_ACCESS_KEY,
80+
globalAwsIamAccessKeySecret,
81+
),
7582
signatureVersion: 'v4',
7683
sslEnabled: true,
7784
} as S3.ClientConfiguration,
@@ -113,9 +120,15 @@ export default {
113120
winston: {
114121
cloudWatch: {
115122
awsConfig: {
116-
accessKeyId: getStringOption(process.env.WINSTON_CLOUDWATCH_ACCESS_KEY_ID),
117-
region: getStringOption(process.env.WINSTON_CLOUDWATCH_REGION),
118-
secretAccessKey: getStringOption(process.env.WINSTON_CLOUDWATCH_SECRET_ACCESS_KEY),
123+
accessKeyId: getStringOption(
124+
process.env.WINSTON_CLOUDWATCH_ACCESS_KEY_ID,
125+
globalAwsIamAccessKeyId,
126+
),
127+
region: getStringOption(process.env.WINSTON_CLOUDWATCH_REGION, globalAwsRegion),
128+
secretAccessKey: getStringOption(
129+
process.env.WINSTON_CLOUDWATCH_SECRET_ACCESS_KEY,
130+
globalAwsIamAccessKeySecret,
131+
),
119132
},
120133
enabled: getBooleanOption(process.env.WINSTON_CLOUDWATCH_ENABLED, false),
121134
level: getStringOption(process.env.WINSTON_CLOUDWATCH_LEVEL, 'info'),

0 commit comments

Comments
 (0)