Skip to content

Commit d5290d9

Browse files
authored
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
1 parent 579fd43 commit d5290d9

22 files changed

+222
-55
lines changed

.github/workflows/deploy-apm-development.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ jobs:
3232
run: ./bin/dev lambda-asset-download
3333
working-directory: ./workflow-cli
3434

35+
- name: Generate aws template
36+
run: ./bin/dev aws-render
37+
working-directory: ./workflow-cli
38+
3539
- name: Setup AWS SAM
3640
uses: aws-actions/setup-sam@v2
3741
with:

.github/workflows/deploy-apm-production.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ jobs:
3434
run: ./bin/dev lambda-asset-download
3535
working-directory: ./workflow-cli
3636

37+
- name: Generate aws template
38+
run: ./bin/dev aws-render
39+
working-directory: ./workflow-cli
40+
3741
- name: Setup AWS SAM
3842
uses: aws-actions/setup-sam@v2
3943
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,4 @@ terraform/.terraform.lock.hcl
121121
workflow-cli/indicesusage*.csv
122122

123123
.aws-sam
124+
/template.yaml

template.yaml renamed to template.yaml.tpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,23 @@ Resources:
262262
Enabled: true
263263
LogGroupName: /aws/kinesisfirehose/apm-dlq-stream
264264
LogStreamName: DestinationDelivery
265+
<% notifications.filter((n) => n.configType == 'sns').forEach((notification) => { %>
266+
<%= notification.entity %>:
267+
Type: AWS::SNS::Topic
268+
Properties:
269+
TopicName: "<%= notification.sns.topicArn %>"
270+
DisplayName: "<%= notification.name %>"<% if (notification.sns.subscriptions) { %><% notification.sns.subscriptions.forEach((sub) => { %>
271+
<%= sub.entity %>Sub:
272+
Type: AWS::SNS::Subscription
273+
Properties:
274+
Endpoint: <% if (sub.protocol == 'sqs') { %>!GetAtt <%= sub.entity %>.Arn<% } else if (sub.protocol == 'email' || sub.protocol == 'sns') { %>"<%= sub.endpoint %>"<% } %>
275+
Protocol: "<%= sub.protocol %>"
276+
TopicArn: !GetAtt <%= notification.entity %>.TopicArn <% if (sub.protocol == 'sqs') { %>
277+
<%= sub.entity %>:
278+
Type: AWS::SQS::Queue
279+
Properties:
280+
QueueName: "<%= sub.endpoint %>"<% }}) } -%>
281+
<% }); -%>
265282

266283
Outputs:
267284
FunctionName:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"_meta": {
3+
"documentation": "https://apps.nrs.gov.bc.ca/int/confluence/x/PqJvBQ",
4+
"version": "1.0"
5+
},
6+
"template": {
7+
"mappings": {
8+
"properties": {
9+
"etc": {
10+
"type": "flat_object"
11+
}
12+
}
13+
}
14+
}
15+
}

workflow-cli/configuration-opensearch/index_template/access_internal.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"ecs_url_8.11",
3131
"ecs_user_agent_8.11",
3232
"ecs_nrm_base_1.0",
33+
"ecs_nrm_etc_1.0",
3334
"ecs_nrm_kinesis_1.0",
3435
"ecs_nrm_user_agent_1.0",
3536
"ecs_nrm_url_context_1.0"

workflow-cli/configuration-opensearch/notification/appdlvr-normal.sns.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"id": "appdlvr-normal-sns",
3+
"entity": "SnsAppDlvrNormal",
34
"name": "Appdlvr SNS",
45
"description": "SNS destination (APM Deployment Managed)",
56
"configType": "sns",
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
{
22
"id": "appdlvr-priority-sns",
3+
"entity": "SnsAppDlvrPriority",
34
"name": "Appdlvr Priority SNS",
45
"description": "SNS destination (APM Deployment Managed)",
56
"configType": "sns",
67
"isEnabled": true,
78
"sns": {
89
"topicArn": "nress-prod-appdlvr-priority",
9-
"roleArn": "opensearch_sns_nress-prod"
10+
"roleArn": "opensearch_sns_nress-prod",
11+
"subscriptions": [{
12+
"entity": "SnsAppDlvrPriorityEmailApp",
13+
"endpoint": "nrids.applicationdelivery@gov.bc.ca",
14+
"protocol": "email"
15+
}]
1016
}
1117
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
{
22
"id": "automation-sqs-sns",
3+
"entity": "SnsAutomationSqs",
34
"name": "Automation SQS SNS",
45
"description": "SNS destination (APM Deployment Managed)",
56
"configType": "sns",
67
"isEnabled": true,
78
"sns": {
89
"topicArn": "nress-prod-message-queue",
9-
"roleArn": "opensearch_sns_nress-prod"
10+
"roleArn": "opensearch_sns_nress-prod",
11+
"subscriptions": [{
12+
"entity": "SqsAutomation",
13+
"endpoint": "nress-prod-message-queue",
14+
"protocol": "sqs"
15+
}]
1016
}
1117
}

workflow-cli/configuration-opensearch/notification/midtier-normal.sns.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"id": "midtier-normal-sns",
3+
"entity": "SnsMidtierNormal",
34
"name": "Midtier SNS",
45
"description": "SNS destination (APM Deployment Managed)",
56
"configType": "sns",

0 commit comments

Comments
 (0)