Reputation: 68715
I am playing with AWS SAM Java serverless application. I am using the eclipse AWS serverless plugin to create simple Dynamo DB based CRUD application. Application takes an http request and depending on the HTTP method tries the corresponding CRUD operation on DynamoDB.
So all is working good except that I am not able to figure out how to pass an environment variable or a property file to my Lambda java code to determine whether lambda is running locally or in AWS environment. Depending on that I want to use local Dynamo DB client or AWS DB client. Here is the code snippet for that:
String environment = System.getenv("profile");
AmazonDynamoDB dynamoDBclient = null;
if("local".equalsIgnoreCase(environment)) {
dynamoDBclient = AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration("http://172.16.123.1:8000", "local"))
.build();
} else {
dynamoDBclient = AmazonDynamoDBClientBuilder.standard().build();
}
dynamoDBMapper = new DynamoDBMapper(dynamoDBclient);
Trying to figure out how to pas this environment variable "profile". In SAM local run/debug config, I don't see any option to do that.
Upvotes: 4
Views: 1547