Repository: wso2/testgrid
Issue: [AWS] Test grid infrastructure creation failed when AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not in environment variables.

**Description:**
Test grid infrastructure creation failed with following exception when AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not in environment variables. Ideally this values should take from config.properties file.

```
[10:25:59,137] Error on infrastructure creation for deployment pattern 'DeploymentPattern{id='1478f023-d8de-4af2-bab9-b9aff640106c', name='default', createdTimestamp='2018-04-24 09:25:52.0', modifiedTimestamp='2018-04-24 09:25:52.0', product='Product{id='5a5236f4-ab8b-4dad-9838-a1e02e2e876e', name='WSOIS-5.4.0', createdTimestamp='2018-04-24 09:25:52.0', modifiedTimestamp='2018-04-24 09:25:52.0'}'}', in TestPlan org.wso2.testgrid.common.exception.TestGridInfrastructureException: AWS Credentials must be set as environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
	at org.wso2.testgrid.infrastructure.providers.AWSProvider.init(AWSProvider.java:110)
	at org.wso2.testgrid.core.TestPlanExecutor.provisionInfrastructure(TestPlanExecutor.java:213)
	at org.wso2.testgrid.core.TestPlanExecutor.execute(TestPlanExecutor.java:82)
	at org.wso2.testgrid.core.command.RunTestPlanCommand.executeTestPlan(RunTestPlanCommand.java:222)
	at org.wso2.testgrid.core.command.RunTestPlanCommand.execute(RunTestPlanCommand.java:118)
	at org.wso2.testgrid.core.command.CommandHandler.execute(CommandHandler.java:124)
	at org.wso2.testgrid.core.Main.main(Main.java:47)
```

**Suggested Labels:**
Type/Bug

**Suggested Assignees:**
charithag

**Affected Product Version:**
0.9.0-m22

**OS, DB, other environment details and versions:**    
Ubuntu x64 16.04.4 LTS, JDK 1.8.0_171-b11, MySQL 5.7.21

**Steps to reproduce:**
Follow Quick Start Guide on newly created instance.
https://github.com/wso2/testgrid/blob/master/docs/QuickStartGuide.md

**Related Issues:**
https://github.com/wso2/testgrid/issues/510

Changed files:
infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java
infrastructure/src/test/java/org/wso2/testgrid/infrastructure/AWSProviderTest.java

diff --git a/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java b/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java
index 56877875..af0a5e54 100644
--- a/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java
+++ b/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java
@@ -74,8 +74,6 @@ import java.util.concurrent.TimeUnit;
  */
 public class AWSProvider implements InfrastructureProvider {
 
-    public static final String AWS_ACCESS_KEY_ID = "AWS_ACCESS_KEY_ID";
-    public static final String AWS_SECRET_ACCESS_KEY = "AWS_SECRET_ACCESS_KEY";
     private static final String AWS_PROVIDER = "AWS";
     private static final Logger logger = LoggerFactory.getLogger(AWSProvider.class);
     private static final String AWS_REGION_PARAMETER = "region";
@@ -103,13 +101,6 @@ public class AWSProvider implements InfrastructureProvider {
 
     @Override
     public void init() throws TestGridInfrastructureException {
-        String awsIdentity = System.getenv(AWS_ACCESS_KEY_ID);
-        String awsSecret = System.getenv(AWS_SECRET_ACCESS_KEY);
-        if (StringUtil.isStringNullOrEmpty(awsIdentity) || StringUtil.isStringNullOrEmpty(awsSecret)) {
-            throw new TestGridInfrastructureException(StringUtil
-                    .concatStrings("AWS Credentials must be set as environment variables: ", AWS_ACCESS_KEY_ID,
-                            ", ", AWS_SECRET_ACCESS_KEY));
-        }
         cfScriptPreprocessor = new CloudFormationScriptPreprocessor();
         amiMapper = new AMIMapper();
     }
diff --git a/infrastructure/src/test/java/org/wso2/testgrid/infrastructure/AWSProviderTest.java b/infrastructure/src/test/java/org/wso2/testgrid/infrastructure/AWSProviderTest.java
index f472f69f..b0aa2b41 100644
--- a/infrastructure/src/test/java/org/wso2/testgrid/infrastructure/AWSProviderTest.java
+++ b/infrastructure/src/test/java/org/wso2/testgrid/infrastructure/AWSProviderTest.java
@@ -72,6 +72,8 @@ import java.util.Set;
                 })
 public class AWSProviderTest extends PowerMockTestCase {
 
+    private static final String AWS_ACCESS_KEY_ID = "AWS_ACCESS_KEY_ID";
+    private static final String AWS_SECRET_ACCESS_KEY = "AWS_SECRET_ACCESS_KEY";
     private static final String AWS_ACCESS_KEY_ID_VALUE = "aws_key_value";
     private static final String AWS_SECRET_ACCESS_KEY_VALUE = "aws_secret_value";
 
@@ -83,8 +85,8 @@ public class AWSProviderTest extends PowerMockTestCase {
     public void testManagerCreation() throws Exception {
         //set environment variables for
         Map<String, String> map = new HashMap<>();
-        map.put(AWSProvider.AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID_VALUE);
-        map.put(AWSProvider.AWS_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY_VALUE);
+        map.put(AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID_VALUE);
+        map.put(AWS_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY_VALUE);
         set(map);
         AMIMapper awsAMIMapper = Mockito.mock(AMIMapper.class);
         PowerMockito.whenNew(AMIMapper.class).withAnyArguments().thenReturn(awsAMIMapper);
@@ -103,7 +105,7 @@ public class AWSProviderTest extends PowerMockTestCase {
             InterruptedException, NoSuchFieldException, IllegalAccessException {
         String secret2 = "AWS_SCERET2";
         Map<String, String> map = new HashMap<>();
-        map.put(AWSProvider.AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID_VALUE);
+        map.put(AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID_VALUE);
         set(map);
         //invoke without no secret key environment variable set.
         AWSProvider awsProvider = new AWSProvider();
@@ -120,8 +122,8 @@ public class AWSProviderTest extends PowerMockTestCase {
         String matchedAmi = "123464";
 
         Map<String, String> map = new HashMap<>();
-        map.put(AWSProvider.AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID_VALUE);
-        map.put(AWSProvider.AWS_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY_VALUE);
+        map.put(AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID_VALUE);
+        map.put(AWS_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY_VALUE);
         set(map);
         InfrastructureConfig infrastructureConfig = getDummyInfrastructureConfig(patternName);
 
@@ -208,8 +210,8 @@ public class AWSProviderTest extends PowerMockTestCase {
 
         //set environment variables for
         Map<String, String> map = new HashMap<>();
-        map.put(AWSProvider.AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID_VALUE);
-        map.put(AWSProvider.AWS_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY_VALUE);
+        map.put(AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID_VALUE);
+        map.put(AWS_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY_VALUE);
         set(map);
         InfrastructureConfig dummyInfrastructureConfig = getDummyInfrastructureConfig(patternName);
         File resourcePath = new File("src/test/resources");