Skip to content

Commit

Permalink
Merge pull request #270 from guardian/jw-remove-superfluous-backup-infra
Browse files Browse the repository at this point in the history
Remove scheduled backup Lambda
  • Loading branch information
jacobwinch authored Dec 19, 2023
2 parents 938bd3a + 6e68927 commit 18b96e8
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 139 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/memsub-promotions-lambdas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ jobs:
functionNames:
- MembershipSub-Promotions-to-PromoCode-View-
- MembershipSub-PromoCode-View-Dynamo-to-Salesforce-
- MembershipSub-Promotions-Scheduled-Dynamo-Backup-
dependencies:
- memsub-promotions-lambdas-cloudformation
contentDirectories: |
MembershipSub-Promotions-PromoCode-View:
- lambdas/dist/MembershipSub-Promotions-PromoCode-View.zip
Expand Down
67 changes: 0 additions & 67 deletions cloudformation/memsub-promotions-lambdas-cf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,45 +53,6 @@ Resources:
Resource:
- arn:aws:dynamodb:*:*:table/MembershipSub-PromoCode-View-PROD
- arn:aws:dynamodb:*:*:table/MembershipSub-PromoCode-View-CODE
MembershipSubPromotionsDataBackupLambdaRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: /
Policies:
- PolicyName: MembershipSub-Promotions-Data-Backup-Lambda-Policy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- arn:aws:logs:*:*:log-group:/aws/lambda/MembershipSub-Promotions-Scheduled-Dynamo-Backup-*
- Effect: Allow
Action:
- dynamodb:GetRecords
- dynamodb:Scan
Resource:
- arn:aws:dynamodb:*:*:table/MembershipSub-Promotions-*
- arn:aws:dynamodb:*:*:table/MembershipSub-Campaigns-*
- Effect: Allow
Action:
- dynamodb:CreateBackup
- dynamodb:ListBackups
- dynamodb:DescribeBackup
- dynamodb:DeleteBackup
Resource:
- '*'
MembershipSubPromoCodeViewETLRole:
Type: AWS::IAM::Role
Properties:
Expand Down Expand Up @@ -209,34 +170,6 @@ Resources:
Runtime: nodejs18.x
Timeout: 60

ScheduledBackupLambdaPROD:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket: gu-promotions-tool-dist
S3Key: membership/PROD/MembershipSub-Promotions-PromoCode-View/MembershipSub-Promotions-PromoCode-View.zip
Description: A Lambda function to trigger the backup of the Campaigns and Promotions table and delete any old backups (retention days is defined in the code)
FunctionName: MembershipSub-Promotions-Scheduled-Dynamo-Backup-PROD
Handler: MembershipSub-Promotions-Scheduled-Dynamo-Backup.handler
MemorySize: 128
Role: !GetAtt [MembershipSubPromotionsDataBackupLambdaRole, Arn]
Runtime: nodejs18.x
Timeout: 60
BackupSchedule:
Type: AWS::Events::Rule
Properties:
ScheduleExpression: cron(20 12 * * ? *)
State: ENABLED
Targets:
- Id: ScheduledBackupLambdaPRODScheduler
Arn: !GetAtt [ScheduledBackupLambdaPROD, Arn]
InvokeLambdaPermission:
Type: AWS::Lambda::Permission
Properties:
FunctionName: !GetAtt [ScheduledBackupLambdaPROD, Arn]
Action: lambda:InvokeFunction
Principal: events.amazonaws.com
SourceArn: !GetAtt [BackupSchedule, Arn]
ETLSchedule:
Type: AWS::Events::Rule
Properties:
Expand Down
7 changes: 0 additions & 7 deletions lambdas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ The lambda relies on SalesForce usernames/passwords which have been stored in AW

Only the PROD will rebuild automatically when a PR branch merges into `main`.

### MembershipSub-Promotions-Scheduled-Dynamo-Backup
A Lambda function to trigger the backup of the Campaigns and Promotions table and delete any old backups (retention days is defined in the code).

For dev work, we can manually run it in AWS and check it worked from the Dynamo page in the AWS console.

A single version (PROD) of this lambda exists in AWS, and will rebuild automatically when a PR branch merges into `main`.

### MembershipSub-Promotions-to-PromoCode-View
An Amazon DynamoDB trigger that creates a view of data associated with a particular promo code for the data pipeline to collect.

Expand Down
64 changes: 0 additions & 64 deletions lambdas/src/MembershipSub-Promotions-Scheduled-Dynamo-Backup.js

This file was deleted.

0 comments on commit 18b96e8

Please sign in to comment.