(properties: PropertyGetter)
| 93 | let awsProps: PropertyGetter | null = null; |
| 94 | |
| 95 | async function loadAwsConfig(properties: PropertyGetter) { |
| 96 | const region = properties<string>('region'); |
| 97 | if (!region) return {}; |
| 98 | await initialiseAwsCredentials(region); |
| 99 | const ssm = new SSM({region: region, credentials: awsCredentials()}); |
| 100 | const path = '/compiler-explorer/'; |
| 101 | try { |
| 102 | const response = await ssm.getParameters({Names: [path + 'sentryDsn']}); |
| 103 | const map: Record<string, string | undefined> = {}; |
| 104 | for (const param of unwrap(response.Parameters)) { |
| 105 | map[unwrap(param.Name).substring(path.length)] = param.Value; |
| 106 | } |
| 107 | logger.info('AWS info:', map); |
| 108 | return map; |
| 109 | } catch (err) { |
| 110 | logger.error(`Failed to get AWS info: ${err}`); |
| 111 | return {}; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | export async function initConfig(properties: PropertyGetter) { |
| 116 | awsConfigInit = true; |
no test coverage detected