-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.php
40 lines (28 loc) · 1.04 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
// Locations for AWS secrets when configured using the aws cli
$awsCredentials = $_SERVER['HOME'] . "/.aws/credentials";
// Check for existence and parse
if (file_exists($awsCredentials)) {
$parsed = parse_ini_file($awsCredentials);
$aws_key = $parsed['aws_access_key_id'];
$aws_secret = $parsed['aws_secret_access_key'];
// Validate
if (!preg_match("/(?<![A-Z0-9])[A-Z0-9]{20}(?![A-Z0-9])/", $aws_key)) {
die("AWS Key does not match known pattern.\nCheck credentials file.\n");
}
if (!preg_match("/(?<![A-Za-z0-9\/+=])[A-Za-z0-9\/+=]{40}(?![A-Za-z0-9\/+=])/", $aws_secret)) {
die("AWS Secret does not match known pattern.\nCheck credentials file.\n");
}
}
else
{
die("Unable to locate AWS credentials file: $awsCredentials\nPlease configure credentials using `aws configure`.\n");
}
define('DRY_RUN', false);
date_default_timezone_set('UTC');
require 'vendor/autoload.php';
// Helpers
function getConfigFile($suffix, $region) {
$file = strtolower(sprintf(".config-Percona-Training-%s-%s.cnf", $suffix, $region));
return $file;
}