Skip to content

Commit

Permalink
Fixed issues
Browse files Browse the repository at this point in the history
2, 6, 18, 19, 20, 21
  • Loading branch information
lhtan-dev committed Jul 6, 2023
1 parent 8dcfde5 commit 417dd15
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 170 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ node_modules
.DS_Store
packaged.yaml
deploy.sh
samconfig.toml
*.toml
8 changes: 3 additions & 5 deletions src/entitlement-sqs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const AWS = require('aws-sdk');

const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10', region: 'us-east-1' });
const { NewSubscribersTableName: newSubscribersTableName, AWS_REGION: aws_region } = process.env;
// MarketplaceEntitlementService is instantianise only in the us-east-1 https://docs.aws.amazon.com/general/latest/gr/aws-marketplace.html#marketplaceentitlement
const marketplaceEntitlementService = new AWS.MarketplaceEntitlementService({ apiVersion: '2017-01-11', region: 'us-east-1' });
const { NewSubscribersTableName: newSubscribersTableName } = process.env;
const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10', region: aws_region });

exports.handler = async (event) => {
await Promise.all(event.Records.map(async (record) => {
Expand Down Expand Up @@ -47,7 +47,5 @@ exports.handler = async (event) => {
throw new Error(`Unhandled action - msg: ${JSON.stringify(record)}`);
}
}));


return {};
};
1 change: 0 additions & 1 deletion src/grant-revoke-access-to-product.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const winston = require('winston');
const AWS = require('aws-sdk');

const SNS = new AWS.SNS({ apiVersion: '2010-03-31' });
const { SupportSNSArn: TopicArn } = process.env;
const logger = winston.createLogger({
Expand Down
22 changes: 0 additions & 22 deletions src/lambda-edge/edge-redirect.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/lambda-edge/package.json

This file was deleted.

9 changes: 4 additions & 5 deletions src/metering-hourly-job.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const AWS = require('aws-sdk');

const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10', region: 'us-east-1' });
const sqs = new AWS.SQS({ apiVersion: '2012-11-05', region: 'us-east-1' });

const { SQSMeteringRecordsUrl: QueueUrl, AWSMarketplaceMeteringRecordsTableName } = process.env;
const { AWS_REGION: aws_region } = process.env;
const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10', region: aws_region });
const sqs = new AWS.SQS({ apiVersion: '2012-11-05', region: aws_region });
const { SQSMeteringRecordsUrl: QueueUrl, AWSMarketplaceMeteringRecordsTableName: AWSMarketplaceMeteringRecordsTableName } = process.env;


async function asyncForEach(array, callback) {
Expand Down
8 changes: 3 additions & 5 deletions src/metering-sqs.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
const AWS = require('aws-sdk');

const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10', region: 'us-east-1' });
const { ProductCode: ProductCode, AWSMarketplaceMeteringRecordsTableName: AWSMarketplaceMeteringRecordsTableName , AWS_REGION: aws_region } = process.env;
const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10', region: aws_region });
// MarketplaceMetering is instantianize in us-east-1 as all SaaS product listing ARN is stored in us-east-1.
const marketplacemetering = new AWS.MarketplaceMetering({ apiVersion: '2016-01-14', region: 'us-east-1' });
const { ProductCode, AWSMarketplaceMeteringRecordsTableName } = process.env;


exports.handler = async (event) => {
await Promise.all(event.Records.map(async (record) => {
const body = JSON.parse(record.body);
console.log(`SQS message body: ${record.body}`);


const timestmpNow = new Date();

const UsageRecords = [];
Expand Down
15 changes: 15 additions & 0 deletions src/redirect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { RedirectUrl: landingPageUrl } = process.env;

exports.redirecthandler = async(event, context, callback) => {

const redirectUrl = landingPageUrl + "?" + event['body'];
const response = {
statusCode: 302,
headers: {
Location: redirectUrl
},
};

return response;

};
11 changes: 6 additions & 5 deletions src/register-new-subscriber.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const AWS = require('aws-sdk');
const ses = new AWS.SES({ region: "us-east-1" });
const marketplacemetering = new AWS.MarketplaceMetering({ apiVersion: '2016-01-14', region: 'us-east-1' });
const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10', region: 'us-east-1' });
const sqs = new AWS.SQS({ apiVersion: '2012-11-05', region: 'us-east-1' });
const { NewSubscribersTableName: newSubscribersTableName, EntitlementQueueUrl: entitlementQueueUrl, MarketplaceSellerEmail: marketplaceSellerEmail } = process.env;
const { NewSubscribersTableName: newSubscribersTableName, EntitlementQueueUrl: entitlementQueueUrl, MarketplaceSellerEmail: marketplaceSellerEmail, AWS_REGION:aws_region } = process.env;
const ses = new AWS.SES({ region: aws_region});
// Require confirmation on whether this has dependency on the marketplace seller account origin.
const marketplacemetering = new AWS.MarketplaceMetering({ apiVersion: '2016-01-14', region: aws_region });
const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10', region: aws_region });
const sqs = new AWS.SQS({ apiVersion: '2012-11-05', region: aws_region });

const lambdaResponse = (statusCode, body) => ({
statusCode,
Expand Down
6 changes: 3 additions & 3 deletions src/subscription-sqs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const AWS = require('aws-sdk');

const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10', region: 'us-east-1' });
const { SupportSNSArn: TopicArn, NewSubscribersTableName: newSubscribersTableName, AWS_REGION: aws_region } = process.env;
const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10', region: aws_region });
const SNS = new AWS.SNS({ apiVersion: '2010-03-31' });
const { SupportSNSArn: TopicArn, NewSubscribersTableName: newSubscribersTableName } = process.env;


exports.SQSHandler = async (event) => {
await Promise.all(event.Records.map(async (record) => {
Expand Down
Loading

0 comments on commit 417dd15

Please sign in to comment.