/** * Get the value of a tag for a specified DB instance. * * @param string $instanceIdentifier Identifier of the DB instance to get * the tag of. * @param string $tagKey Key of tag to get. * @return string|null Value of tag or null if the db instance or tag does * not exist. */ public function getRdsDbInstanceTag($instanceIdentifier, $tagKey) { // Compose the ARN of the DB instance. $accountId = explode(':', $this->iam->GetUser()['User']['Arn'])[4]; $arn = sprintf('arn:aws:rds:%s:%s:db:%s', $this->region, $accountId, $instanceIdentifier); try { $tags = $this->rds->ListTagsForResource(['ResourceName' => $arn])['TagList']; } catch (Rds\Exception\DBInstanceNotFoundException $e) { return null; } foreach ($tags as $tag) { if ($tag['Key'] === $tagKey) { return $tag['Value']; } } return null; }