Skip to content

Instantly share code, notes, and snippets.

@chathurangat
Last active August 2, 2018 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chathurangat/2129ef87c733506b5c3e463928fb4caf to your computer and use it in GitHub Desktop.
Save chathurangat/2129ef87c733506b5c3e463928fb4caf to your computer and use it in GitHub Desktop.
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
@Configuration
public class AmazonS3Config
{
@Value("${aws.access.key.id}")
private String awsKeyId;
@Value("${aws.access.key.secret}")
private String awsKeySecret;
@Value("${aws.region}")
private String awsRegion;
@Value("${aws.s3.audio.bucket}")
private String awsS3AudioBucket;
@Bean(name = "awsKeyId")
public String getAWSKeyId() {
return awsKeyId;
}
@Bean(name = "awsKeySecret")
public String getAWSKeySecret() {
return awsKeySecret;
}
@Bean(name = "awsRegion")
public Region getAWSPollyRegion() {
return Region.getRegion(Regions.fromName(awsRegion));
}
@Bean(name = "awsCredentialsProvider")
public AWSCredentialsProvider getAWSCredentials() {
BasicAWSCredentials awsCredentials = new BasicAWSCredentials(this.awsKeyId, this.awsKeySecret);
return new AWSStaticCredentialsProvider(awsCredentials);
}
@Bean(name = "awsS3AudioBucket")
public String getAWSS3AudioBucket() {
return awsS3AudioBucket;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment