-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sns and sqs to aws template (#375)
* feat: add sns and sqs to aws template * feat: add email subs * feat: individual sub entities * feat: individual sub entities * fix: tweak subs * feat: add etc to internal
- Loading branch information
Showing
22 changed files
with
222 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,3 +121,4 @@ terraform/.terraform.lock.hcl | |
workflow-cli/indicesusage*.csv | ||
|
||
.aws-sam | ||
/template.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
workflow-cli/configuration-opensearch/ecs_nrm_1.0/etc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"_meta": { | ||
"documentation": "https://apps.nrs.gov.bc.ca/int/confluence/x/PqJvBQ", | ||
"version": "1.0" | ||
}, | ||
"template": { | ||
"mappings": { | ||
"properties": { | ||
"etc": { | ||
"type": "flat_object" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
workflow-cli/configuration-opensearch/notification/appdlvr-normal.sns.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
workflow-cli/configuration-opensearch/notification/appdlvr-priority.sns.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
{ | ||
"id": "appdlvr-priority-sns", | ||
"entity": "SnsAppDlvrPriority", | ||
"name": "Appdlvr Priority SNS", | ||
"description": "SNS destination (APM Deployment Managed)", | ||
"configType": "sns", | ||
"isEnabled": true, | ||
"sns": { | ||
"topicArn": "nress-prod-appdlvr-priority", | ||
"roleArn": "opensearch_sns_nress-prod" | ||
"roleArn": "opensearch_sns_nress-prod", | ||
"subscriptions": [{ | ||
"entity": "SnsAppDlvrPriorityEmailApp", | ||
"endpoint": "[email protected]", | ||
"protocol": "email" | ||
}] | ||
} | ||
} |
8 changes: 7 additions & 1 deletion
8
workflow-cli/configuration-opensearch/notification/automation-sqs.sns.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
{ | ||
"id": "automation-sqs-sns", | ||
"entity": "SnsAutomationSqs", | ||
"name": "Automation SQS SNS", | ||
"description": "SNS destination (APM Deployment Managed)", | ||
"configType": "sns", | ||
"isEnabled": true, | ||
"sns": { | ||
"topicArn": "nress-prod-message-queue", | ||
"roleArn": "opensearch_sns_nress-prod" | ||
"roleArn": "opensearch_sns_nress-prod", | ||
"subscriptions": [{ | ||
"entity": "SqsAutomation", | ||
"endpoint": "nress-prod-message-queue", | ||
"protocol": "sqs" | ||
}] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
workflow-cli/configuration-opensearch/notification/midtier-normal.sns.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
workflow-cli/configuration-opensearch/notification/midtier-priority.sns.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
workflow-cli/configuration-opensearch/notification/oneteam-priority.sns.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
workflow-cli/configuration-opensearch/notification/wf-normal.sns.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
{ | ||
"id": "wildfire-normal-sns", | ||
"entity": "SnsWildfireNormal", | ||
"name": "Wildfire SNS", | ||
"description": "SNS destination (APM Deployment Managed)", | ||
"configType": "sns", | ||
"isEnabled": true, | ||
"sns": { | ||
"topicArn": "nress-prod-wildfire-normal", | ||
"roleArn": "opensearch_sns_nress-prod" | ||
"roleArn": "opensearch_sns_nress-prod", | ||
"subscriptions": [{ | ||
"entity": "SnsWildfireNormalEmailWf", | ||
"endpoint": "[email protected]", | ||
"protocol": "email" | ||
}] | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
workflow-cli/configuration-opensearch/notification/wso2-alert.sns.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"id": "wso2-alert-sns", | ||
"entity": "SnsWso2Alert", | ||
"name": "WSO2 Alert", | ||
"description": "SNS destination (APM Deployment Managed)", | ||
"configType": "sns", | ||
"isEnabled": true, | ||
"sns": { | ||
"topicArn": "nress-prod-wso2-alert", | ||
"roleArn": "opensearch_sns_nress-prod", | ||
"subscriptions": [{ | ||
"entity": "SnsWso2AlertEmailWf", | ||
"endpoint": "[email protected]", | ||
"protocol": "email" | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'reflect-metadata'; | ||
import { Args, Command } from '@oclif/core'; | ||
import { vsContainer } from '../inversify.config'; | ||
import { TYPES } from '../inversify.types'; | ||
import AwsRenderService from '../services/aws-render.service'; | ||
|
||
export default class AwsRender extends Command { | ||
static description = 'Renders AWS Cloudformation doc'; | ||
|
||
static examples = ['<%= config.bin %> <%= command.id %>']; | ||
|
||
static flags = {}; | ||
|
||
static args = { | ||
file: Args.string({ name: 'file' }), | ||
}; | ||
|
||
public async run(): Promise<void> { | ||
await this.parse(AwsRender); | ||
this.log(`AWS Template render - start`); | ||
vsContainer.get<AwsRenderService>(TYPES.AwsRenderService).render(); | ||
this.log(`AWS Template render - end`); | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import ejs from 'ejs'; | ||
import { inject, injectable } from 'inversify'; | ||
import NotificationService from './notification.service'; | ||
import { TYPES } from '../inversify.types'; | ||
|
||
const TEMPLATE_DIR = path.resolve(__dirname, '../../..'); | ||
|
||
@injectable() | ||
export default class AwsRenderService { | ||
constructor( | ||
@inject(TYPES.NotificationService) | ||
private notificationService: NotificationService, | ||
) {} | ||
|
||
render() { | ||
const templateStr = fs.readFileSync( | ||
path.resolve(TEMPLATE_DIR, 'template.yaml.tpl'), | ||
{ encoding: 'utf8' }, | ||
); | ||
|
||
const val = ejs.render(templateStr, { | ||
notifications: this.notificationService.renderConfigs({}), | ||
}); | ||
|
||
console.log(val); | ||
|
||
fs.writeFileSync(path.resolve(TEMPLATE_DIR, 'template.yaml'), val, { | ||
encoding: 'utf8', | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import ejs from 'ejs'; | ||
import { injectable } from 'inversify'; | ||
|
||
export interface NotificationSettings { | ||
hostname: string; | ||
region: string; | ||
accountNumber: string; | ||
} | ||
|
||
export interface NotificationConfig { | ||
id: string; | ||
name: string; | ||
description: string; | ||
configType: string; | ||
isEnabled: boolean; | ||
sns: { | ||
topicArn: string; | ||
roleArn: string; | ||
}; | ||
microsoft_teams: { | ||
url: string; | ||
}; | ||
} | ||
|
||
const NOTIFICATION_CONFIG_DIR = path.resolve( | ||
__dirname, | ||
'../../configuration-opensearch/notification', | ||
); | ||
|
||
@injectable() | ||
export default class NotificationService { | ||
public renderConfigs(secrets: any): NotificationConfig[] { | ||
const configs: NotificationConfig[] = []; | ||
for (const notificationFile of fs.readdirSync(NOTIFICATION_CONFIG_DIR)) { | ||
const configStr = fs.readFileSync( | ||
path.resolve(NOTIFICATION_CONFIG_DIR, notificationFile), | ||
{ encoding: 'utf8' }, | ||
); | ||
|
||
const config = JSON.parse( | ||
this.renderConfig(notificationFile, configStr, secrets), | ||
); | ||
configs.push(config); | ||
} | ||
return configs; | ||
} | ||
|
||
private renderConfig(file: string, configStr: string, secrets: any) { | ||
if (file.endsWith('microsoft_teams.json')) { | ||
const key = `notification_teams_${file.slice(0, -21).replaceAll(/[^a-zA-Z_0-9]/gi, '_')}`; | ||
return ejs.render(configStr, { | ||
url: secrets[key] ?? '', | ||
}); | ||
} | ||
return configStr; | ||
} | ||
} |
Oops, something went wrong.