Skip to content

Commit

Permalink
#39: Added configuration option for RDS engine version
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbiarda committed Sep 20, 2022
1 parent c34a0dd commit b619efe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .driver/connections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ connections:
rds:
instance-type: db.t3.medium
engine: MySQL
engine-version: 8.0.28
storage-type: gp2

# TODO: fix merging so that the other keys overwrite this.
# TODO: fix merging so that the other keys overwrite this.
1 change: 1 addition & 0 deletions .driver/connections.yaml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ connections:
## BEGIN NEW RDS INSTANCE:
instance-type: # defaults to db.t3.medium, other options can be found at https://aws.amazon.com/rds/instance-types/
engine: # defaults to MySQL
engine-version: # defaults to 8.0.28
storage-type: # defaults to gp2
## END NEW RDS INSTANCE
## BEGIN EXISTING RDS INSTANCE:
Expand Down
2 changes: 2 additions & 0 deletions .driver/connections.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ connections:
key: SDF83K0N3IDSL29ZMEIH
secret: "kF9kwnf,mo3fFoaow+3mda/439a,Dlwommw9021m"
region: us-east-2
engine: MySQL
engine-version: 5.7.38
ec2:
key: SDF83K0N3IDSL29ZMEIH
secret: "kF9kwnf,mo3fFoaow+3mda/439a,Dlwommw9021m"
Expand Down
20 changes: 11 additions & 9 deletions src/Engines/MySql/Sandbox/Sandbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@

class Sandbox
{
const DEFAULT_ENGINE = 'MySQL';
const DEFAULT_ENGINE_VERSION = '8.0.28';

private $configuration;
private $instance;
private $initialized;
private $remoteIpFetcher;
private $logger;
private $random;
private $awsClientFactory;

private $securityGroupId;
private $securityGroupName;

private $dbName;
private $identifier;
private $username;
private $password;
private $statuses;
private $output;

/** @var \Symfony\Component\EventDispatcher\EventDispatcher */
private EventDispatcher $eventDispatcher;

Expand Down Expand Up @@ -95,6 +97,7 @@ public function init()
'AllocatedStorage' => 100,
'DBInstanceClass' => $this->configuration->getNode('connections/rds/instance-type'),
'Engine' => $this->getEngine(),
'EngineVersion' => $this->getEngineVersion(),
'MasterUsername' => $this->getUsername(),
'MasterUserPassword' => $this->getPassword(),
'VpcSecurityGroupIds' => [$this->getSecurityGroup()],
Expand Down Expand Up @@ -286,15 +289,14 @@ private function getStorageType()
return $storageType;
}

private function getEngine()
private function getEngine(): string
{
$engine = $this->configuration->getNode('connections/rds/engine');

if (!$engine) {
$engine = 'MySQL';
}
return $this->configuration->getNode('connections/rds/engine') ?? self::DEFAULT_ENGINE;
}

return $engine;
private function getEngineVersion(): string
{
return $this->configuration->getNode('connections/rds/engine-version') ?? self::DEFAULT_ENGINE_VERSION;
}

public function getSecurityGroupName()
Expand Down

0 comments on commit b619efe

Please sign in to comment.