@@ -20,21 +20,28 @@ mappings in upload := Seq()
20
20
21
21
upload := {
22
22
import com .amazonaws .{ClientConfiguration , Protocol }
23
- import com .amazonaws .auth .DefaultAWSCredentialsProviderChain
23
+ import com .amazonaws .auth .{ BasicAWSCredentials , AWSStaticCredentialsProvider , DefaultAWSCredentialsProviderChain }
24
24
import com .amazonaws .services .s3 .AmazonS3ClientBuilder
25
- import com .amazonaws .services .s3 .model .{ CannedAccessControlList , PutObjectRequest }
25
+ import com .amazonaws .services .s3 .model .PutObjectRequest
26
26
import com .amazonaws .regions .Regions
27
27
28
- // the publishing job runs on an EC2 instance that has access to the S3 bucket via its IAM instance profile
29
- val client = AmazonS3ClientBuilder .standard.withRegion(Regions .US_EAST_1 ).build
28
+ def env (v : String ) = {
29
+ val r = System .getenv(v)
30
+ assert(r != null , s " Credentials env not specified: $v" )
31
+ r
32
+ }
33
+
34
+ val awsCreds = new BasicAWSCredentials (env(" AWS_ACCESS_KEY_ID" ), env(" AWS_SECRET_ACCESS_KEY" ))
35
+ val client = AmazonS3ClientBuilder .standard
36
+ .withCredentials(new AWSStaticCredentialsProvider (awsCreds))
37
+ .withRegion(Regions .US_EAST_1 )
38
+ .build
30
39
31
40
val log = streams.value.log
32
41
33
42
(mappings in upload).value map { case (file, key) =>
34
43
log.info(" Uploading " + file.getAbsolutePath() + " as " + key)
35
-
36
- // since the s3 bucket is in a separate account from where the EC2 CI instances are, must explicitly set acl as public-read
37
- client.putObject(new PutObjectRequest (" downloads.typesafe.com" , key, file).withCannedAcl(CannedAccessControlList .PublicRead ))
44
+ client.putObject(new PutObjectRequest (" downloads.typesafe.com" , key, file))
38
45
}
39
46
}
40
47
0 commit comments