Skip to content

Commit 2f2bccf

Browse files
Luke SikinaLuke-Sikina
Luke Sikina
authored andcommitted
Add Instance Profile Auth
1 parent d6b5285 commit 2f2bccf

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

uploader/env-proto

+11-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ AWS_SESSION_TOKEN=
44
AWS_DATA_UPLOAD_ROLE=arn:aws:iam::111111111111:role/PicSureDataUploadRole
55
AWS_SHARED_SECRET=
66
AWS_S3_BUCKET_NAME=
7-
AWS_REGION
7+
AWS_REGION=us-east-1
88
AWS_KEY_ID
9+
AUTH_METHOD=user
910

1011
DATA_UPLOAD_DB_DATABASE=data-upload
1112
DATA_UPLOAD_DB_HOST=uploader-db
1213
DATA_UPLOAD_DB_PASS=mycoolpassword
13-
DATA_UPLOAD_DB_USER=datauploaduser
14+
DATA_UPLOAD_DB_USER=datauploaduser
15+
DATA_UPLOAD_DB_ROOT_PASS=mycoolpassword
16+
17+
FILE_SHARING_ROOT=/gic_query_results
18+
19+
INSTITUTIONS=bch-dev
20+
HOME_INSTITUTION_NAME=bch-dev
21+
HOME_INSTITUTION_DISPLAY=BCH
22+
HOME_INSTITUTION_LONG_DISPLAY=Boston Children's Hospital

uploader/src/main/java/edu/harvard/dbmi/avillach/dataupload/aws/AWSConfiguration.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ public StsClient stsClients(
6666
}
6767

6868
@Bean
69-
@ConditionalOnProperty(name = "production", havingValue = "true")
69+
@ConditionalOnProperty(name = "aws.authentication.method", havingValue = "user")
7070
AwsCredentials credentials() {
71+
LOG.info("Authentication method is user. Attempting to resolve user credentials.");
7172
if (Strings.isBlank(key)) {
7273
LOG.error("No AWS key. Can't create client. Exiting");
7374
context.close();
@@ -82,6 +83,12 @@ AwsCredentials credentials() {
8283
return AwsSessionCredentials.create(key, secret, token);
8384
}
8485
}
86+
@Bean
87+
@ConditionalOnProperty(name = "aws.authentication.method", havingValue = "instance-profile")
88+
AwsCredentials ipCredentials() {
89+
LOG.info("Authentication method is instance-profile. Attempting to resolve instance profile credentials.");
90+
return InstanceProfileCredentialsProvider.create().resolveCredentials();
91+
}
8592

8693
@Bean
8794
@ConditionalOnProperty(name = "production", havingValue = "true")

uploader/src/main/resources/application.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ aws.s3.session_token=${AWS_SESSION_TOKEN:}
1212
aws.s3.institution=${INSTITUTIONS}
1313
aws.region=${AWS_REGION}
1414
aws.kms.key_ids=${AWS_KEY_ID}
15+
aws.authentication.method=${AUTH_METHOD:noauth}
1516

1617
production=true
1718
enable_file_sharing=true
1819
file_sharing_root=${FILE_SHARING_ROOT}
1920
institution.name=${HOME_INSTITUTION_NAME}
2021
institution.short-display=${HOME_INSTITUTION_DISPLAY}
2122
institution.long-display=${HOME_INSTITUTION_LONG_DISPLAY}
22-
server.port=80
23+
server.port=${PORT:80}

0 commit comments

Comments
 (0)