Example usage for com.amazonaws SDKGlobalConfiguration SECRET_KEY_ENV_VAR

List of usage examples for com.amazonaws SDKGlobalConfiguration SECRET_KEY_ENV_VAR

Introduction

In this page you can find the example usage for com.amazonaws SDKGlobalConfiguration SECRET_KEY_ENV_VAR.

Prototype

String SECRET_KEY_ENV_VAR

To view the source code for com.amazonaws SDKGlobalConfiguration SECRET_KEY_ENV_VAR.

Click Source Link

Document

Environment variable name for the AWS secret key

Usage

From source file:org.apache.usergrid.rest.management.ImportResourceIT.java

License:Apache License

/**
 * Call importService to import files from the configured S3 bucket.
 *//*from  ww  w.j a  va  2 s . co m*/
private Entity importCollection() throws Exception {

    String org = clientSetup.getOrganizationName();
    String app = clientSetup.getAppName();

    logger.debug("\n\nImport into new app {}\n", app);

    Entity importPayload = new Entity(new HashMap<String, Object>() {
        {
            put("properties", new HashMap<String, Object>() {
                {
                    put("storage_provider", "s3");
                    put("storage_info", new HashMap<String, Object>() {
                        {
                            put("s3_key", System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR));
                            put("s3_access_id", System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR));
                            put("bucket_location", bucketName);
                        }
                    });
                }
            });
        }
    });

    Entity importEntity = this.management().orgs().org(org).app().addToPath(app).addToPath("imports")
            .post(Entity.class, importPayload);

    int maxRetries = 120;
    int retries = 0;

    while (retries++ < maxRetries) {

        Entity importGet = this.management().orgs().org(org).app().addToPath(app).addToPath("imports")
                .addToPath(importEntity.getUuid().toString()).get();

        if (importGet.get("state").equals("FINISHED") || importGet.get("state").equals("FAILED")) {
            break;
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Waiting for import...");
        }
        Thread.sleep(1000);
    }

    refreshIndex();

    return importEntity;
}

From source file:org.apache.usergrid.rest.management.ImportResourceIT.java

License:Apache License

/**
 * Delete the configured s3 bucket./*  w  w  w  .  j  a va  2 s.  com*/
 */
public void deleteBucket() {

    logger.debug("\n\nDelete bucket\n");

    String accessId = System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR);
    String secretKey = System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR);

    Properties overrides = new Properties();
    overrides.setProperty("s3" + ".identity", accessId);
    overrides.setProperty("s3" + ".credential", secretKey);

    final Iterable<? extends Module> MODULES = ImmutableSet.of(new JavaUrlHttpCommandExecutorServiceModule(),
            new Log4JLoggingModule(), new NettyPayloadModule());

    BlobStoreContext context = ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES)
            .overrides(overrides).buildView(BlobStoreContext.class);

    BlobStore blobStore = context.getBlobStore();
    blobStore.deleteContainer(bucketName);
}

From source file:org.apache.usergrid.rest.management.ImportResourceIT.java

License:Apache License

private static void deleteBucketsWithPrefix() {

    logger.debug("\n\nDelete buckets with prefix {}\n", bucketPrefix);

    String accessId = System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR);
    String secretKey = System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR);

    Properties overrides = new Properties();
    overrides.setProperty("s3" + ".identity", accessId);
    overrides.setProperty("s3" + ".credential", secretKey);

    final Iterable<? extends Module> MODULES = ImmutableSet.of(new JavaUrlHttpCommandExecutorServiceModule(),
            new Log4JLoggingModule(), new NettyPayloadModule());

    BlobStoreContext context = ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES)
            .overrides(overrides).buildView(BlobStoreContext.class);

    BlobStore blobStore = context.getBlobStore();
    final PageSet<? extends StorageMetadata> blobStoreList = blobStore.list();

    for (Object o : blobStoreList.toArray()) {
        StorageMetadata s = (StorageMetadata) o;

        if (s.getName().startsWith(bucketPrefix)) {
            try {
                blobStore.deleteContainer(s.getName());
            } catch (ContainerNotFoundException cnfe) {
                logger.warn("Attempted to delete bucket {} but it is already deleted", cnfe);
            }//www .  j a  v  a  2  s . co  m
            logger.debug("Deleted bucket {}", s.getName());
        }
    }
}

From source file:org.apache.usergrid.rest.management.ImportResourceIT.java

License:Apache License

public Entity payloadBuilder() {

    String accessId = System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR);
    String secretKey = System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR);

    Entity storage_info = new Entity();
    storage_info.put("s3_key", secretKey);
    storage_info.put("s3_access_id", accessId);
    storage_info.put("bucket_location", bucketName);

    Entity properties = new Entity();
    properties.put("storage_provider", "s3");
    properties.put("storage_info", storage_info);

    Entity payload = new Entity();
    payload.put("properties", properties);

    return payload;
}