Skip to content

Commit

Permalink
Cleanup project files
Browse files Browse the repository at this point in the history
  • Loading branch information
farski committed Apr 5, 2024
1 parent 44ebc1a commit 56ba30c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 57 deletions.
Binary file removed .DS_Store
Binary file not shown.
7 changes: 7 additions & 0 deletions .github/workflows/check-project-std.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Check project standards

on: push

jobs:
check-javascript:
uses: prx/.github/.github/workflows/check-project-std-javascript.yml@main
16 changes: 16 additions & 0 deletions samconfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# sam build && sam deploy --resolve-s3

version = 0.1

[default.deploy.parameters]
profile = "prx-it-services"
stack_name = "classy-toolkit"
s3_prefix = "classy-toolkit"
confirm_changeset = false
capabilities = "CAPABILITY_IAM"
region = "us-east-2"
# Parameter overrides only need to be included when a parameter is changing
# parameter_overrides = [
# "ClassyApiClientId=",
# "ClassyApiClientSecret="
# ]
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,6 @@ function httpGet(token, path) {
});
}

// function getCount() {
// return new Promise((resolve, reject) => {
// s3.getObject(
// {
// Bucket: process.env.COUNTER_BUCKET,
// Key: process.env.COUNTER_OBJECT,
// },
// (err, data) => {
// if (err) {
// reject(err);
// } else {
// resolve(+data.Body.toString('utf8'));
// }
// },
// );
// });
// }

function shortMemberName(member, tx) {
if (tx.is_anonymous) {
return `_Anonymous_`;
Expand Down
76 changes: 37 additions & 39 deletions template.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,31 @@
# etc/adzerk-poller/template.yml
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31

Description: >-
Creates a Lambda function that polls the Classy API for recent activity, and
sends messages to Slack for certain activities
Description: A collection of utilities that integrate with Classy

Parameters:
ClassyApiClientId:
Type: String
ClassyApiClientSecret:
Type: String
SlackMessageRelayTopicArn:
Type: String
Frequency:
Type: String
Description: In minutes, greater than 1
Default: 2
CounterBucket:
Type: String
CounterObject:
Type: String

Resources:
PollerFunction:
ActivitySlackNotificationsFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: index.js
CodeUri: src/activity-slack-notifications
Description: >-
Polls Classy for new activity
Polls the Classy API for recent activity, and sends messages to Slack
for certain activities
Environment:
Variables:
CLASSY_API_CLIENT_ID: !Ref ClassyApiClientId
CLASSY_API_CLIENT_SECRET: !Ref ClassyApiClientSecret
SLACK_MESSAGE_RELAY_SNS_TOPIC_ARN: !Ref SlackMessageRelayTopicArn
POLLING_FREQUENCY: !Ref Frequency
COUNTER_BUCKET: !Ref CounterBucket
COUNTER_OBJECT: !Ref CounterObject
Events:
Poller:
Properties:
Expand All @@ -48,45 +37,54 @@ Resources:
MemorySize: 128
Policies:
- Statement:
- Action: sns:Publish
Effect: Allow
Resource: !Ref SlackMessageRelayTopicArn
Version: "2012-10-17"
- Statement:
- Action: sns:Publish
Effect: Allow
Resource: !Ref SlackMessageRelayTopicArn
- Action:
- s3:getObject
- s3:putObject
- Action: events:PutEvents
Effect: Allow
Resource: !Sub arn:aws:s3:::${CounterBucket}/${CounterObject}
Resource: !Sub arn:${AWS::Partition}:events:${AWS::Region}:${AWS::AccountId}:event-bus/default
Sid: AllowDefaultEventBusPut
Version: "2012-10-17"
Runtime: nodejs18.x
# Tags:
# Project: Misc
# prx:cloudformation:stack-name: !Ref AWS::StackName
# prx:cloudformation:stack-id: !Ref AWS::StackId
Runtime: nodejs20.x
Tags:
prx:meta:tagging-version: 2021-04-07
prx:cloudformation:stack-name: !Ref AWS::StackName
prx:cloudformation:stack-id: !Ref AWS::StackId
prx:ops:environment: Production
prx:dev:application: Classy Toolkit
Timeout: 180
PollerFunctionLogGroup:
ActivitySlackNotificationsLogGroup:
Type: AWS::Logs::LogGroup
DeletionPolicy: Delete
UpdateReplacePolicy: Delete
Properties:
LogGroupName: !Sub /aws/lambda/${PollerFunction}
LogGroupName: !Sub /aws/lambda/${ActivitySlackNotificationsFunction}
RetentionInDays: 30
PollerFunctionErrorAlarm:
Tags:
- { Key: prx:meta:tagging-version, Value: "2021-04-07" }
- { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
- { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
- { Key: prx:ops:environment, Value: Production }
- { Key: prx:dev:application, Value: Classy Toolkit }
ActivitySlackNotificationsErrorAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: "MINOR [Classy] Activity Poller <prod> EXPERIENCING ERRORS"
AlarmName: "MINOR [Classy] Activity Notifications <prod> EXPERIENCING ERRORS"
AlarmDescription: >-
The error rate on the Classy app has exceeded 0.
The error rate on the Classy toolkit activity Slack notifications
Lambda function has exceeded 0. Some donation activity may not be
reaching Slack channels.
ComparisonOperator: GreaterThanThreshold
Dimensions:
- Name: FunctionName
Value: !Ref PollerFunction
Value: !Ref ActivitySlackNotificationsFunction
EvaluationPeriods: 2
MetricName: Errors
Namespace: AWS/Lambda
Period: 60
Statistic: Sum
Tags:
- { Key: prx:meta:tagging-version, Value: "2021-04-07" }
- { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
- { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
- { Key: prx:ops:environment, Value: Production }
- { Key: prx:dev:application, Value: Classy Toolkit }
Threshold: 0
TreatMissingData: notBreaching

0 comments on commit 56ba30c

Please sign in to comment.