From b619efe20979198e698d1ef19ad6cf9917ed3ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Biarda?= <1135380+michalbiarda@users.noreply.github.com> Date: Tue, 20 Sep 2022 16:39:54 +0200 Subject: [PATCH] #39: Added configuration option for RDS engine version --- .driver/connections.yaml | 3 ++- .driver/connections.yaml.dist | 1 + .driver/connections.yaml.example | 2 ++ src/Engines/MySql/Sandbox/Sandbox.php | 20 +++++++++++--------- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.driver/connections.yaml b/.driver/connections.yaml index 0297c66..cf05b4b 100644 --- a/.driver/connections.yaml +++ b/.driver/connections.yaml @@ -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. \ No newline at end of file +# TODO: fix merging so that the other keys overwrite this. diff --git a/.driver/connections.yaml.dist b/.driver/connections.yaml.dist index f4c30db..0b0f09c 100644 --- a/.driver/connections.yaml.dist +++ b/.driver/connections.yaml.dist @@ -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: diff --git a/.driver/connections.yaml.example b/.driver/connections.yaml.example index 6b80437..6e094d5 100644 --- a/.driver/connections.yaml.example +++ b/.driver/connections.yaml.example @@ -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" diff --git a/src/Engines/MySql/Sandbox/Sandbox.php b/src/Engines/MySql/Sandbox/Sandbox.php index 06f2220..da3811f 100755 --- a/src/Engines/MySql/Sandbox/Sandbox.php +++ b/src/Engines/MySql/Sandbox/Sandbox.php @@ -29,6 +29,9 @@ class Sandbox { + const DEFAULT_ENGINE = 'MySQL'; + const DEFAULT_ENGINE_VERSION = '8.0.28'; + private $configuration; private $instance; private $initialized; @@ -36,16 +39,15 @@ class Sandbox 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; @@ -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()], @@ -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()