Skip to content

Commit

Permalink
merge contact
Browse files Browse the repository at this point in the history
  • Loading branch information
4ppsec committed Aug 20, 2019
2 parents 829e34c + 3651d7b commit 5e15386
Show file tree
Hide file tree
Showing 11 changed files with 777 additions and 106 deletions.
18 changes: 18 additions & 0 deletions backend/serverless/resources/s3-buckets.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
Resources:
S3BucketFeedbackBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: {'Fn::Join': ['', ['dvsa-feedback-bucket-', {Ref: 'AWS::AccountId'}]]}
# Set the CORS policy
CorsConfiguration:
CorsRules:
- AllowedOrigins:
- '*'
AllowedHeaders:
- '*'
AllowedMethods:
- GET
- PUT
- POST
- DELETE
- HEAD
MaxAge: 3000
S3BucketReceiptsBucket:
Type: AWS::S3::Bucket
Properties:
Expand Down
6 changes: 5 additions & 1 deletion backend/src/functions/order-api/order-manager-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ exports.handler = (event, context, callback) => {
functionName = "DVSA-USER-INBOX";
break;

case "delete":
case "delete":
payload = { "action": "delete", "user": user, "msgId": req["msg-id"] };
functionName = "DVSA-USER-INBOX";
break;

case "feedback":
payload = { "user": user, "file": req["attachment"] };
functionName = "DVSA-FEEDBACK-UPLOADS";
break;

default:
isOk = false;
Expand Down
6 changes: 3 additions & 3 deletions backend/src/functions/order-api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions backend/src/functions/processing/feedback_uploads.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import json
import time
import boto3
import os
from botocore.exceptions import ClientError


def lambda_handler(event, context):
s3 = boto3.client('s3')
try:
response = s3.generate_presigned_url('get_object',
Params={
'Bucket': os.environ["FEEDBACK_BUCKET"],
'Key': event["file"]},
ExpiresIn=300)
except ClientError as e:
print str(e)
return None

return response
53 changes: 53 additions & 0 deletions backend/src/functions/processing/sls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ custom:
accountId: ${file(backend/serverless/scripts/vars.js):accountId}

functions:

FeedBackUploads:
name: DVSA-FEEDBACK-UPLOADS
handler: backend/src/functions/processing/feedback_uploads.lambda_handler
role: dvsaFeedbackRole
environment:
FEEDBACK_BUCKET: {'Fn::Join': ['', ['dvsa-feedback-bucket-', {Ref: 'AWS::AccountId'}]]}
timeout: 10
memorySize: 128
package:
include:
- backend/src/functions/processing/feedback_uploads.py
events:
- s3:
bucket: FeedbackBucket
event: s3:ObjectCreated:*

CreateReceipt:
name: DVSA-CREATE-RECEIPT
handler: backend/src/functions/processing/create_receipt.lambda_handler
Expand All @@ -29,6 +46,7 @@ functions:
- SQSQueue
- Arn
batchSize: 1

PaymentProcessor:
name: DVSA-PAYMENT-PROCESSOR
handler: backend/src/functions/processing/payment_processing.lambda_handler
Expand All @@ -44,6 +62,7 @@ functions:
include:
- backend/src/functions/processing/payment_processing.py
- backend/src/functions/processing/helper.pyc

GetTotal:
name: DVSA-GET-CART-TOTAL
handler: backend/src/functions/processing/get_cart_total.lambda_handler
Expand All @@ -60,6 +79,7 @@ functions:
package:
include:
- backend/src/functions/processing/get_cart_total.py

SendReceipt:
name: DVSA-SEND-RECEIPT-EMAIL
handler: backend/src/functions/processing/send_receipt_email.lambda_handler
Expand All @@ -85,6 +105,39 @@ resources:
Type: "AWS::SQS::Queue"
Properties:
QueueName: "dvsa-order-paid-sqs"
#--------------------------
# Role: dvsaFeedbackRole
#--------------------------
dvsaFeedbackRole:
Type: AWS::IAM::Role
Properties:
RoleName: dvsaFeedbackRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: DVSAFeedbackRolePolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: {'Fn::Join': [':', ['arn:aws:logs', {Ref: 'AWS::Region'}, {Ref: 'AWS::AccountId'}, 'log-group:/aws/lambda/*:*:*']]}
- Effect: "Allow"
Action:
- ses:*
- s3:*
Resource: "*"


#--------------------------
# Role: dvsaCreateReceiptRole
#--------------------------
Expand Down
Loading

0 comments on commit 5e15386

Please sign in to comment.