package org.rakam.aws;

import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.internal.StaticCredentialsProvider;
import io.airlift.configuration.Config;

public class AWSConfig {
    private String accessKey;
    private String secretAccessKey;
    private String eventStoreStreamName;


    public String getEventStoreStreamName() {
        return eventStoreStreamName;
    }

    @Config("event.store.kinesis.stream")
    public void setEventStoreStreamName(String eventStoreStreamName) {
        this.eventStoreStreamName = eventStoreStreamName;
    }

    @Config("aws.access_key")
    public AWSConfig setAccessKey(String accessKey) {
        this.accessKey = accessKey;
        return this;
    }

    public String getAccessKey() {
        return accessKey;
    }

    @Config("aws.secret_access_key")
    public AWSConfig setSecretAccessKey(String secretAccessKey) {
        this.secretAccessKey = secretAccessKey;
        return this;
    }

    public String getSecretAccessKey() {
        return secretAccessKey;
    }

    public StaticCredentialsProvider getCredentials() {
        return new StaticCredentialsProvider(new BasicAWSCredentials(getAccessKey(), getSecretAccessKey()));
    }
}

@@ -43,21 +43,16 @@
 ws.auth.
-Basic
 AWSCrede
@@ -57,16 +57,133 @@
 dentials
+Provider;%0Aimport com.amazonaws.auth.BasicAWSCredentials;%0Aimport com.amazonaws.auth.DefaultAWSCredentialsProviderChain
 ;%0Aimport
@@ -1162,22 +1162,19 @@
  public 
-Static
+AWS
 Credenti
@@ -1200,24 +1200,155 @@
 entials() %7B%0A
+        if(accessKey == null %7C%7C secretAccessKey == null) %7B%0A            return new DefaultAWSCredentialsProviderChain();%0A        %7D%0A%0A
         retu

return default value if aws access key is not set