Skip to content

Commit

Permalink
support SQS init from env, and use of temp session credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
ssadedin committed Aug 25, 2024
1 parent 37396e6 commit 1d4d040
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.amazon.sqs.javamessaging.SQSConnectionFactory
import com.amazonaws.auth.AWSCredentials
import com.amazonaws.auth.AWSStaticCredentialsProvider
import com.amazonaws.auth.BasicAWSCredentials
import com.amazonaws.auth.BasicSessionCredentials
import com.amazonaws.services.sqs.AmazonSQSClientBuilder

@Log
Expand Down Expand Up @@ -63,6 +64,22 @@ class AWSSQSNotificationChannel extends JMSNotificationChannel {
else
throw new IllegalStateException("Profile $config.profile for SQS connection could not be found in your AWS credentials file")
}
else
if(System.getenv('AWS_SECRET_ACCESS_KEY')) {

if(System.getenv('AWS_SESSION_TOKEN')) {
credentials = new BasicSessionCredentials(
System.getenv('AWS_ACCESS_KEY_ID'),
System.getenv('AWS_SECRET_ACCESS_KEY'),
System.getenv('AWS_SESSION_TOKEN'))

log.info("Using AWS SQS session credentials from environment")
}
else {
credentials = new BasicAWSCredentials(System.getenv('AWS_ACCESS_KEY_ID'),System.getenv('AWS_SECRET_ACCESS_KEY'));
log.info("Using AWS SQS fixed credentials from environment")
}
}

if(credentials == null) {
throw new IllegalStateException(
Expand Down

0 comments on commit 1d4d040

Please sign in to comment.