Skip to content

Commit

Permalink
Customisable AWS Region
Browse files Browse the repository at this point in the history
Allows you to set a custom AWS region using the AWS_REGION environment variable. If this variable is not set it will default to us-east-1 (backwards compatible)
  • Loading branch information
Jono20201 committed Sep 27, 2016
1 parent c8adc3b commit 13fe144
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ In order for Leader Selection to run a few environmental variables must be prese
* **USE_CRON** = true -- Must be set in order for Leader Selection to occur. (This can be used to prevent Selection from occurring on undesired environments IE Workers, etc.)
* **AWS_ACCESS_KEY_ID** -- Needed for read-only access to ec2 client
* **AWS_SECRET_ACCESS_KEY** -- Needed for read-only access to ec2 client
* **AWS_REGION** -- Sets which AWS region when looking using the ec2 client, defaults to `us-east-1` if not set.

These can be included in your **.env** or, for EB, in the environment's configuration section.

Expand Down
5 changes: 4 additions & 1 deletion src/Console/AWS/ConfigureLeaderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ class ConfigureLeaderCommand extends Command
public function __construct()
{
parent::__construct();

$region = getenv('AWS_REGION') ?: 'us-east-1';

$client = new Ec2Client([
'region' => 'us-east-1',
'region' => $region,
'version' => 'latest'
]);
$this->ecClient = $client;
Expand Down

0 comments on commit 13fe144

Please sign in to comment.