Skip to content

Commit

Permalink
Update readme, sample.env, destination null check
Browse files Browse the repository at this point in the history
  • Loading branch information
mwodahl committed May 22, 2024
1 parent 3a66222 commit 1b9a660
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# AWS Deposit Service
# Message Deposit Service

This project is intended to serve as a consumer application to subscribe to a Kafka topic of streaming JSON, package the results as a JSON file, and deposits the resulting file into a predetermined Firehose/Kinesis, S3 Bucket, or Google Cloud Storage Bucket. This runs alongside the ODE and when deployed using Docker Compose, runs in a Docker container.
This project is intended to serve as a consumer application to subscribe to a Kafka topic of streaming JSON, package the results as a JSON file, and deposit the resulting file into a predetermined Firehose/Kinesis, S3 Bucket, or Google Cloud Storage Bucket (GCS). This runs alongside the ODE and when deployed using Docker Compose, runs in a Docker container.

## Quick Run
The use of AWS credentials is being read from the machine's environmental variables. You may also set them in your bash profile. Note that when using Docker Compose from the main `jpo-ode` repository, these variables are set in the `.env` present in that repo.

If depositing to GCS, credentials are read from a JSON service account key file. A sample service account file can be found at ./resources/google/sample_gcp_service_account.json.
Please note that if depositing to GCS the service account will need the storage.buckets.get and storage.objects.create permissions.

```
export K_AWS_ACCESS_KEY_ID = AccessKeyId
export K_AWS_SECRET_ACCESS_SECRET = SecretAccessKey
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-confluent-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ services:
CONFLUENT_SECRET: ${CONFLUENT_SECRET}
GOOGLE_APPLICATION_CREDENTIALS: '/google/gcp_service_account.json'
volumes:
- ${GOOGLE_APPLICATION_CREDENTIALS}:/google/gcp_service_account.json d
- ${GOOGLE_APPLICATION_CREDENTIALS}:/google/gcp_service_account.json

5 changes: 2 additions & 3 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ DESTINATION=

# Google Cloud Storage Variables
## path to service account key file (json format)
### If using gcs as a destination please note that the service account used must have
### storage.buckets.get and storage.objects.create permissions to deposit messages correctly.
GOOGLE_APPLICATION_CREDENTIALS=''
### If GOOGLE_APPLICATION_CREDENTIALS is blank, regardless of destination, it may cause issues when running the S3 depositor with Docker.
GOOGLE_APPLICATION_CREDENTIALS='./resources/google/sample_gcp_service_account.json'
24 changes: 13 additions & 11 deletions src/main/java/us/dot/its/jpo/ode/aws/depositor/AwsDepositor.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,19 @@ public void run(String[] args) throws Exception {
AmazonKinesisFirehoseAsync firehose = null;
Storage gcsStorage = null;

if (destination != null && destination.equals("s3")) {
depositToS3 = true;
s3 = createS3Client(awsRegion);

} else if (destination != null && destination.equals("firehose")) {
firehose = buildFirehoseClient(awsRegion);
} else if (destination != null && destination.equals("gcs")) {
gcsStorage = StorageOptions.getDefaultInstance().getService();
} else {
logger.error("Invalid destination: " + destination);
System.exit(1);
if (destination != null) {
if (destination.equals("s3")) {
depositToS3 = true;
s3 = createS3Client(awsRegion);

} else if (destination.equals("firehose")) {
firehose = buildFirehoseClient(awsRegion);
} else if (destination.equals("gcs")) {
gcsStorage = StorageOptions.getDefaultInstance().getService();
} else {
logger.error("Invalid destination: " + destination);
System.exit(1);
}
}


Expand Down

0 comments on commit 1b9a660

Please sign in to comment.