Skip to content

Commit

Permalink
Add instructions for running locally
Browse files Browse the repository at this point in the history
  • Loading branch information
lindseydew committed Feb 27, 2024
1 parent 4f75a59 commit 8c06187
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 0 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,40 @@ Try(mapper.readValue[List[SavedArticle]](json)) match {
*NB: I found that when a user record has 350+ articles the resultant string in too long for idea to handle.
## Running apps locally
### Pre-requisites
- Mobile credentials from [Janus](https://janus.gutools.co.uk/login)
- Install [AWS Sam](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html)
- Install [Docker](https://docs.docker.com/engine/install/)
- Make sure you run the app with Java8
### Mobile Save For Later
Build a jar of the project by running:
- `sbt "project mobile-save-for-later" riffRaffPackageType`
Navigate to the project
- `cd mobile-save-for-later`
Run the lambda service
- `DOCKER_HOST=unix://$HOME/.docker/run/docker.sock sam local start-lambda --debug`
Execute a function
- `aws lambda invoke --function-name "mobilesaveforlaterFETCHcdkCODE" --endpoint-url "http://127.0.0.1:3001" --no-verify-ssl out.txt --profile mobile --region eu-west-1`
### Mobile Save For Later User Deletion
Build a jar of the project by running:
- `sbt "project mobile-save-for-later-user-deletion" riffRaffPackageType`
Navigate to the project
- `cd mobile-save-for-later-user-deletion`
Run the lambda service
- `DOCKER_HOST=unix://$HOME/.docker/run/docker.sock sam local start-lambda --debug`
Execute a function
- `aws lambda invoke --function-name "mobilesaveforlateruserdeletionCODE" --endpoint-url "http://127.0.0.1:3001" --no-verify-ssl out.txt --profile mobile --region eu-west-1`
## Testing the Apps on CODE
Expand Down
84 changes: 84 additions & 0 deletions mobile-save-for-later-user-deletion/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# This AWS SAM template has been generated from your function's configuration. If
# your function has one or more triggers, note that the AWS resources associated
# with these triggers aren't fully specified in this template and include
# placeholder values. Open this template in AWS Application Composer or your
# favorite IDE and modify it to specify a serverless application with other AWS
# resources.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An AWS Serverless Application Model template describing your function.
Resources:
mobilesaveforlateruserdeletionCODE:
Type: AWS::Serverless::Function
Properties:
CodeUri: 'target/scala-2.12/mobile-save-for-later-user-deletion.jar'
Description: Lamba that deletes saved for later data for deleted users
MemorySize: 384
Timeout: 300
Handler: com.gu.sfl.userdeletion.UserDeletionLambda::handler
Runtime: java8
Architectures:
- x86_64
EphemeralStorage:
Size: 512
Environment:
Variables:
App: mobile-save-for-later-user-deletion
SaveForLaterApp: mobile-save-for-later
Stack: mobile
Stage: CODE
EventInvokeConfig:
MaximumEventAgeInSeconds: 21600
MaximumRetryAttempts: 2
PackageType: Zip
Policies:
- Statement:
- Action:
- dynamodb:*
Resource:
- >-
arn:aws:dynamodb:eu-west-1:201359054765:table/mobile-save-for-later-CODE-articles
Effect: Allow
- Action:
- lamda:InvokeFunction
Resource:
- >-
arn:aws:lambda:eu-west-1:201359054765:function:mobile-save-for-later-user-deletion-CODE
Effect: Allow
- Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: '*'
Effect: Allow
- Action:
- sqs:ReceiveMessage
- sqs:DeleteMessage
- sqs:GetQueueAttributes
Resource:
- arn:aws:sqs:eu-west-1:201359054765:UserIdDeleteQueue-CODE
Effect: Allow
SnapStart:
ApplyOn: None
Tags:
App: mobile-save-for-later-user-deletion
Stack: mobile
Stage: CODE
gu:build-tool: guardian/actions-riff-raff
gu:repo: guardian/mobile-save-for-later
Events:
SQS1:
Type: SQS
Properties:
Queue:
Fn::GetAtt:
- SQSQueue1
- Arn
BatchSize: 5
RuntimeManagementConfig:
UpdateRuntimeOn: Auto
SQSQueue1:
Type: AWS::SQS::Queue
Properties:
QueueName: SQSQueue1
SqsManagedSseEnabled: true
97 changes: 97 additions & 0 deletions mobile-save-for-later/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# This AWS SAM template has been generated from your function's configuration. If
# your function has one or more triggers, note that the AWS resources associated
# with these triggers aren't fully specified in this template and include
# placeholder values. Open this template in AWS Application Composer or your
# favorite IDE and modify it to specify a serverless application with other AWS
# resources.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An AWS Serverless Application Model template describing your function.
Resources:
mobilesaveforlaterFETCHcdkCODE:
Type: AWS::Serverless::Function
Properties:
CodeUri: 'target/scala-2.12/mobile-save-for-later.jar'
Description: ''
MemorySize: 1024
Timeout: 20
Handler: com.gu.sfl.lambda.FetchArticlesLambda::handleRequest
Runtime: java8
Architectures:
- x86_64
EphemeralStorage:
Size: 512
Environment:
Variables:
App: mobile-save-for-later
APP: mobile-save-for-later
IdentityApiHost: https://id.code.dev-guardianapis.com
STACK: mobile
Stack: mobile
IdentityOktaAudience: https://profile.code.dev-theguardian.com/
IdentityOktaIssuerUrl: https://profile.code.dev-theguardian.com/oauth2/aus3v9gla95Toj0EE0x7
STAGE: CODE
Stage: CODE
EventInvokeConfig:
MaximumEventAgeInSeconds: 21600
MaximumRetryAttempts: 2
PackageType: Zip
Policies:
- Statement:
- Action:
- s3:GetObject*
- s3:GetBucket*
- s3:List*
Resource:
- arn:aws:s3:::mobile-dist
- arn:aws:s3:::mobile-dist/*
Effect: Allow
- Action:
- ssm:GetParametersByPath
Resource: >-
arn:aws:ssm:eu-west-1:201359054765:parameter/CODE/mobile/mobile-save-for-later
Effect: Allow
- Action:
- ssm:GetParameters
- ssm:GetParameter
Resource: >-
arn:aws:ssm:eu-west-1:201359054765:parameter/CODE/mobile/mobile-save-for-later/*
Effect: Allow
- Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:Query
Resource: >-
arn:aws:dynamodb:eu-west-1:201359054765:table/mobile-save-for-later-CODE-articles
Effect: Allow
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: '*'
Architecture:
x86_64
ReservedConcurrentExecutions: 1
SnapStart:
ApplyOn: None
Tags:
App: mobile-save-for-later
Stack: mobile
Stage: CODE
gu:build-tool: guardian/actions-riff-raff
gu:cdk:version: 45.1.0
gu:repo: guardian/mobile-save-for-later
Events:
Api1:
Type: Api
Properties:
Path: /syncedPrefs/me
Method: GET
Api2:
Type: Api
Properties:
Path: /syncedPrefs/me
Method: GET

0 comments on commit 8c06187

Please sign in to comment.