-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mParticle Integration - Final Updates (#276)
* mParticle workshop and code This contains the code to set the environment variables, handle mParticle logic within the analyticshandler.js and include the main npm module within the main.js * update workshop * Added lambda and cf templates * Updated bundle for mparticle lambda * Added environment variables for lambda * Added campaign arn parameter to lambda * Updates to CF template for lambdas * Added mParticle API keys to master template * Updated go mod file for lambda deployment * Removed encryption tag * Spelling error fix * Removed docs ref to manual Go deps install * Add all npm deps to lambda * Added conda_python3 env to mParticle notebook * Added workshops to the main README page * Added mParticle logo SVG * Corrected link to Real Time Events notebook * Updated events workshop to support SSM parameters * Updated roles and CF parameters to conform to original workshop * Corrected org id spelling and deleted mp trust role * Role syntax error fix * Added string subs for role resources * Set events wkshop notebook to conda_python3 * Added unique name for cross-account role * Added IAM update role permissions to support changes * Added branch to sagemaker git deploys * Added github branch to base template * Default branch is set to 'master' * CodeRepositoryUrl added * Added stream name and region spec * Fixed role update code * Fixed repeated content * Update Analytics Handler Add missing variables * Update AnalyticsHandler.js cart quantity variable is missing * Update mParitcle Real Time Events Documentation Update mParitcle Real Time Events Documentation * Updated Jupyter notebooks for mParticle Updated Jupyter notebooks for mParticle * Added mP params + removed cell outputs in ipynb * buildspec params for webui * Removed keys from CF and into buildspec.yml * changes mP SSM variables to conform to best practices * fixed role creation permissions and code * Added delete step for roles created in mP workshop * all caps lambda envs and replaced lambda code * Add Enable Kinesis Stream Screenshot in Lambda Add Enable Kinesis Stream Screenshot in Lambda * Add Enable Kinesis Stream Screenshot in Lambda Add Enable Kinesis Stream Screenshot in Lambda * Update mParticle docs to format images and include additional step to enable AWS Kinesis component in Lambda Update mParticle docs to format images and include additional step to enable AWS Kinesis component in Lambda * Format pictures to standardized dimensions * Added license statement to mp js code * Refactor variable names and move globals to function scope * notbook github repo name mapped to stack and region * Uid passed to mp resource names for same account deploys * Reformatted for style + removed console.log * Stylistic changes plus review comment * Fixed Uids for notebook repos and mP resources * Removed console.log from Analytics library * Replaced static cart IDs with cart.id * Editing mP Lambda JS code * Added services url ssm and lookup code in lambda * Fixed SSM params * Remove mParticle OrgID default value from base templates * Added SSM params for mP Lambda function * Fix param passing to base template * Shrank mP Lambda package; update to perms for SSM * Added SSM param reads to mP lambda * Product URL fix * Clarifying comment * Synced params to mParticle notebook * Updated instructions to use SSM parameters * missing mParticle params missing mParticle params * Update Readme md mParticle section Update Readme md mParticle section * Update workshop email contact and code Update workshop email contact and code * Update mailto markdown * Update mail to link * Update Mail To * Fixed some syntax errors; variable naming * Proposed changes to lambda structure * Update mParticle-personalize.js Support async function * Update mparticle-personalize.js Updated Code * Update mParticle-personalize.js Revert back to using const personalizeRuntime = new AWS.PersonalizeRuntime(); as the new code introduced by Igor was throwing errors. * Update workshop to support new changes Update workshop to support new changes * Updated lambda code to use async/await * Update mparticle-personalize.js Updated lambda hanlder using Igor's code and Jeff's code. * Update workshop Update workshop with recent changes * Update Workshop mParticle Personalize Update IAM Creation Policy step * Update workshop Clear outputs * Refactor last part of code for mP calls * Removed checked-in s2s keys from code * Update mparticle-perosnalize.js trackingID renamed to personalizeTrackerID. Remove discount * Add image to workshop Add Kinesis Component Screenshot * Update workshop Added new screenshots * Fixed resource policies * Update mparticle-personalize.js Fixes as per Jame's feedback/comments. PR comment - #276 * Replaced npm install with npm ci * remove unused env variables for mp lambda * Added mP S2S params to top of master template Co-authored-by: hawjefferson <[email protected]>
- Loading branch information
1 parent
695bbac
commit 9e31800
Showing
92 changed files
with
2,189 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
--- | ||
AWSTemplateFormatVersion: 2010-09-09 | ||
|
||
Description: > | ||
This template deploys a Kinesis stream and two Lambda functions for use with the Amazon Personalize destination | ||
in the Personalize and CDP workshops, along with the execution roles required to run the Lambda and for mParticle | ||
to be able to access the Lambda from the Personalize destination. | ||
Parameters: | ||
ResourceBucket: | ||
Type: String | ||
Description: > | ||
S3 bucket name where the Retail Demo Store deployment resources are staged (product images, nested CloudFormation templates, source code snapshot, | ||
notebooks, deployment Lambda code, etc). You can substitute your own bucket here if needed. | ||
ResourceBucketRelativePath: | ||
Type: String | ||
Description: > | ||
Optional path in the Deployment Resources Staging bucket where the deployment resources are stored (e.g. path/path2/). | ||
Leave blank if resources are at the root of the Staging Resource Bucket. If specified, MUST end with '/'. | ||
Uid: | ||
Type: String | ||
Description: > | ||
Uid generated from the root template to provide unique resource names | ||
mParticleOrgId: | ||
Type: String | ||
Description: > | ||
The OrgID for your mParticle instance. This will be used to enable assume role for mParticle to write to Kinesis. | ||
Resources: | ||
mParticlePersonalizeEventsKinesisStream: | ||
Type: AWS::Kinesis::Stream | ||
Properties: | ||
Name: !Sub '${Uid}-mParticlePersonalizeEventsKinesisStream' | ||
ShardCount: 1 | ||
|
||
mParticlePersonalizeLambda: | ||
Type: 'AWS::Lambda::Function' | ||
Properties: | ||
Description: 'Handles sending events passed from mParticle to the Personalize tracker for user-item interactions.' | ||
Handler: mparticle-personalize.handler | ||
Role: !GetAtt | ||
- mParticlePersonalizeLambdaExecutionRole | ||
- Arn | ||
Code: | ||
S3Bucket: !Ref ResourceBucket | ||
S3Key: !Sub '${ResourceBucketRelativePath}aws-lambda/mparticle-personalize.zip' | ||
Runtime: nodejs12.x | ||
Timeout: 900 | ||
FunctionName: !Sub '${Uid}-mParticlePersonalizeLambda' | ||
|
||
mParticleKinesisCrossAccountRole: | ||
Type: 'AWS::IAM::Role' | ||
Properties: | ||
RoleName: !Sub '${Uid}-mParticleKinesisCrossAccountRole' | ||
Description: 'Allows mParticle to write messages to your Kinesis stream.' | ||
AssumeRolePolicyDocument: | ||
Version: 2012-10-17 | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
AWS: | ||
- "arn:aws:iam::338661164609:role/role-lambda-verifyrequest" | ||
- "arn:aws:iam::338661164609:role/role-ecs-mp-notification-httpservertoserverprocessor" | ||
Action: | ||
- 'sts:AssumeRole' | ||
Condition: | ||
StringEquals: | ||
"sts:ExternalId": !Sub 'orgid:${mParticleOrgId}' | ||
Path: / | ||
Policies: | ||
- PolicyName: root | ||
PolicyDocument: | ||
Version: 2012-10-17 | ||
Statement: | ||
- Effect: Allow | ||
Action: | ||
- 'kinesis:PutRecord' | ||
Resource: | ||
- !Sub 'arn:aws:kinesis:${AWS::Region}:${AWS::AccountId}:stream/${Uid}-mParticlePersonalizeEventsKinesisStream' | ||
|
||
mParticlePersonalizeLambdaExecutionRole: | ||
Type: 'AWS::IAM::Role' | ||
Properties: | ||
Description: 'Execution role for the Lambda provided with the mParticle workshop.' | ||
AssumeRolePolicyDocument: | ||
Version: 2012-10-17 | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: | ||
- lambda.amazonaws.com | ||
Action: | ||
- 'sts:AssumeRole' | ||
Path: / | ||
ManagedPolicyArns: | ||
- 'arn:aws:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole' | ||
Policies: | ||
- PolicyName: root | ||
PolicyDocument: | ||
Version: 2012-10-17 | ||
Statement: | ||
- Effect: Allow | ||
Action: | ||
- logs:CreateLogStream | ||
- logs:PutLogEvents | ||
Resource: | ||
- !Sub 'arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/${Uid}-mParticlePersonalizeLambda*:log-stream:*' | ||
- !Sub 'arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/${Uid}-mParticlePersonalizeLambda*' | ||
- Effect: Allow | ||
Action: | ||
- ssm:GetParameter | ||
- ssm:GetParameters | ||
Resource: | ||
- !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/retaildemostore-*' | ||
- !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/retaildemostore*' | ||
- Effect: Allow | ||
Action: | ||
- logs:CreateLogGroup | ||
- personalize:GetRecommendations | ||
- personalize:PutEvents | ||
Resource: '*' | ||
|
||
Outputs: | ||
mParticlePersonalizeLambdaFunctionArn: | ||
Description: Lambda function ARN for the mParticle Personalize Lambda function. | ||
Value: !GetAtt mParticlePersonalizeLambda.Arn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.