Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add region poperty for working bucket #262

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ Using basic setup, you don't need any extra code change and you will use the pro

ice.processor.localDir=/mnt/ice_processor

1.3 In ice.properties, set up the working s3 bucket and working s3 bucket file prefix to upload the processed output files which will be read by reader. Ice must have read and write access to the s3 bucket. For example:
1.3 In ice.properties, set up the working s3 bucket, working s3 region, and working s3 bucket file prefix to upload the processed output files which will be read by reader. Ice must have read and write access to the s3 bucket. For example:

ice.work_s3bucketname=work_s3bucketname
ice.work_s3bucketregion=eu-west-1
ice.work_s3bucketprefix=work_s3bucketprefix/

1.4 If running locally, set the following system properties at runtime. ice.s3AccessToken is optional.
Expand Down
1 change: 1 addition & 0 deletions grails-app/conf/BootStrap.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class BootStrap {
else
properties.setProperty(IceOptions.START_MILLIS, "" + new DateTime(DateTimeZone.UTC).withMillisOfDay(0).withDayOfMonth(1).getMillis());
properties.setProperty(IceOptions.WORK_S3_BUCKET_NAME, prop.getProperty(IceOptions.WORK_S3_BUCKET_NAME));
properties.setProperty(IceOptions.WORK_S3_BUCKET_REGION, prop.getProperty(IceOptions.WORK_S3_BUCKET_REGION));
properties.setProperty(IceOptions.WORK_S3_BUCKET_PREFIX, prop.getProperty(IceOptions.WORK_S3_BUCKET_PREFIX));
properties.setProperty(IceOptions.CUSTOM_TAGS, prop.getProperty(IceOptions.CUSTOM_TAGS, ""));

Expand Down
21 changes: 12 additions & 9 deletions src/java/com/netflix/ice/common/AwsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static Credentials getAssumedCredentials(String accountId, String assumeR
* This method must be called before all methods can be used.
* @param credentialsProvider
*/
public static void init(AWSCredentialsProvider credentialsProvider) {
public static void init(AWSCredentialsProvider credentialsProvider, String workS3BucketRegion) {
awsCredentialsProvider = credentialsProvider;
clientConfig = new ClientConfiguration();
String proxyHost = System.getProperty("https.proxyHost");
Expand All @@ -95,13 +95,11 @@ public static void init(AWSCredentialsProvider credentialsProvider) {
}
s3Client = new AmazonS3Client(awsCredentialsProvider, clientConfig);
securityClient = new AWSSecurityTokenServiceClient(awsCredentialsProvider, clientConfig);
if (System.getProperty("EC2_REGION") != null && !"us-east-1".equals(System.getProperty("EC2_REGION"))) {
if ("global".equals(System.getProperty("EC2_REGION"))) {
s3Client.setEndpoint("s3.amazonaws.com");
}
else {
s3Client.setEndpoint("s3-" + System.getProperty("EC2_REGION") + ".amazonaws.com");
}
if("us-east-1".equals(workS3BucketRegion)) {
s3Client.setEndpoint("s3.amazonaws.com");
}
else {
s3Client.setEndpoint("s3-" + workS3BucketRegion + ".amazonaws.com");
}
}

Expand Down Expand Up @@ -273,7 +271,12 @@ public static boolean downloadFileIfChangedSince(String bucketName, String bucke
}

if(bucketFileRegion != null && !bucketFileRegion.isEmpty()) {
s3Client.setEndpoint("s3-" + bucketFileRegion + ".amazonaws.com");
if("us-east-1".equals(bucketFileRegion)) {
s3Client.setEndpoint("s3.amazonaws.com");
}
else {
s3Client.setEndpoint("s3-" + bucketFileRegion + ".amazonaws.com");
}
}

ObjectMetadata metadata = s3Client.getObjectMetadata(bucketName, bucketFilePrefix + file.getName());
Expand Down
5 changes: 4 additions & 1 deletion src/java/com/netflix/ice/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
public abstract class Config {

public final String workS3BucketName;
public final String workS3BucketRegion;
public final String workS3BucketPrefix;
public final String localDir;
public final AccountService accountService;
Expand Down Expand Up @@ -56,17 +57,19 @@ public Config(

DateTime startDate = new DateTime(Long.parseLong(properties.getProperty(IceOptions.START_MILLIS)), DateTimeZone.UTC);
workS3BucketName = properties.getProperty(IceOptions.WORK_S3_BUCKET_NAME);
workS3BucketRegion = properties.getProperty(IceOptions.WORK_S3_BUCKET_REGION);
workS3BucketPrefix = properties.getProperty(IceOptions.WORK_S3_BUCKET_PREFIX, "ice/");
localDir = properties.getProperty(IceOptions.LOCAL_DIR, "/mnt/ice");

if (workS3BucketName == null) throw new IllegalArgumentException("IceOptions.WORK_S3_BUCKET_NAME must be specified");
if (workS3BucketRegion == null) throw new IllegalArgumentException("IceOptions.WORK_S3_BUCKET_REGION must be specified");

this.credentialsProvider = credentialsProvider;
this.startDate = startDate;
this.accountService = accountService;
this.productService = productService;
this.resourceService = resourceService;

AwsUtils.init(credentialsProvider);
AwsUtils.init(credentialsProvider, workS3BucketRegion);
}
}
6 changes: 6 additions & 0 deletions src/java/com/netflix/ice/common/IceOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ public class IceOptions {
*/
public static final String WORK_S3_BUCKET_NAME = "ice.work_s3bucketname";

/**
* Region for output files s3 bucket. It should be specified for buckets using v4 validation.
* It must be specified in Config.
*/
public static final String WORK_S3_BUCKET_REGION = "ice.work_s3bucketregion";

/**
* Prefix of output files in output s3 bucket. It must be specified in Config.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/java/sample.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ ice.companyName=Your Company Name

# s3 bucket name where Ice can store output files. Ice must have read and write access to billing s3 bucket.
ice.work_s3bucketname=work_s3bucketname
# location for the output files bucket. It should be specified for buckets using v4 validation
ice.work_s3bucketregion=eu-west-1
# prefix of Ice output files
ice.work_s3bucketprefix=ice/

Expand Down