Edit Order Notification Infrastructure

Summary

The Edit Order Notification solution uses the ECS task pattern coupled with a BigQuery Table for test reporting.

Components

@startuml Edit Order Notification Infrastructure

skinparam defaultTextAlignment center 

package "Edit Order Notification Infrastructure" {
    [New SSM attribute] as AWSSSMAttribute <<SSM Attribute>>
    [New AWS role for running ECS Task] as AWSRole <<AWS Role>>
    [AWS Log Group for ECS Task] as AWSCloudWatchGroup <<AWS Cloudwatch Group>>
    [New AWS ECR Repository for ECS task container] as S3FileProcesser <<AWS ECR Repository>>
    [New ECS Task ] as AWSECSTask <<AWS ECS Task>>
    [New CloudWatch Rule to trigger ECS Task] as AWSCloudWatchRule <<AWS Cloudwatch Rule>>
    [New Big Query View for Edit Order Cutoff] as BigQueryCutoffView <<BigQuery View>>
    [New Big Query Table for Report Details] as BigQueryNotificationReport <<BigQuery Table>>
    [New Metric Monitoring Service Datadog] as MonitoringService<<Monitoring Service>>
}

@enduml

Component

Description

Activity

Ref

<<SSM Attribute>>

New SSM key specifically for edit order notifications to protect the content

New

SSM Key

<<AWS Role>>

New AWS Role to segregate the ECS Task execution context so we can secure the SSM Key

New

AWS Role

<<AWS Cloudwatch Group>>

New CloudWatch log group to collect the task logs in

New

AWS Cloudwatch Group

<<AWS ECR Repository>>

New repository to hold the docker container for the task

New

AWS ECR Repository

<<AWS ECS Task>>

New ECS task to execute the actual code for the notification

New

AWS ECS Task

<<AWS Cloudwatch Rule>>

New trigger rule to run the ECS task daily at 9am

New

AWS Cloudwatch Rule

<<BigQuery View>>

New view in big query to retrieve customer orders for edit cutoff

New

Big Query Cutoff Time Tomorrow View

<<BigQuery Table>>

New table in big query to send notification report data

New

Big Query Report

<<Monitoring Service>>

New monitoring service using Datadog

New

Monitoring Service - Datadog

SSM Key

The security credentials will be stored in the following security credentials in the digital Jenkins.

storepick_edit_order_apikey_sandpit
storepick_edit_order_apikey_nonprod
storepick_edit_order_apikey_prod

These credentials are used to populate the SSM key below in the respective environments. This secure attribute is created from the common-infrastructure repository.

storepick_edit_order_apikey

Values Example for Dev environment with Google Credentials (private/authorisation values are shown as empty):

{
    "API_KEY": "",
    "AUTHORISATION": "",
    "GOOGLE_CREDENTIALS_DEV":
        {
            "type": "service_account",
            "project_id": "mrw-storepick-dev",
            "private_key_id": "",
            "private_key": "",
            "client_email": "store-pick-real-time@mrw-storepick-dev.iam.gserviceaccount.com",
            "client_id": "",
            "auth_uri": "https://accounts.google.com/o/oauth2/auth",
            "token_uri": "https://oauth2.googleapis.com/token",
            "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
            "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/store-pick-real-time%40mrw-storepick-dev.iam.gserviceaccount.com"
        }
}

AWS Role

AWS Cloudwatch Group

Environment

Log Group

dev

clg-euw1-dev-storepick-edit-order-001/clg-euw1-dev-storepick-edit-order-001/edit-order-dev-001/

sit

clg-euw1-sit-storepick-edit-order-001/clg-euw1-sit-storepick-edit-order-001/edit-order-sit-001/

uat

clg-euw1-uat-storepick-edit-order-001/clg-euw1-uat-storepick-edit-order-001/edit-order-uat-001/

prd

clg-euw1-prd-storepick-edit-order-001/clg-euw1-prd-storepick-edit-order-001/edit-order-prd-001/

AWS ECR Repository

Environment

ECR Repository

dev

storepick/edit-order-confirmation-task-v1-dev

sit

storepick/edit-order-confirmation-task-v1-sit

uat

storepick/edit-order-confirmation-task-v1-uat

prd

storepick/edit-order-confirmation-task-v1-prd

AWS ECS Task

Environment

ECS Task Definition

dev

edit-order-dev-001

sit

edit-order-sit-001

uat

edit-order-uat-001

prd

edit-order-prd-001

AWS Cloudwatch Rule

Rule

Target

Schedule

cwrule-euw1-dev-digital-edit-order-notification-001

edit-order-dev-001

Fires every day at 9 am

cwrule-euw1-sit-digital-edit-order-notification-001

edit-order-sit-001

Fires every day at 9 am

cwrule-euw1-uat-digital-edit-order-notification-001

edit-order-uat-001

Fires every day at 9 am

cwrule-euw1-prd-digital-edit-order-notification-001

edit-order-prd-001

Fires every day at 9 am

Big Query Role

Big Query Cutoff Time Tomorrow View

To find the customers and orders that require edit order notifications based on the cutoff. The orderId and retailerCustomerId values are retrieved from following big query views:

Environment

View

dev

mrw-storepick-dev.store_pick_views.edit_cutoff_time_tomorrow

sit

mrw-sit-storepick.store_pick_views.edit_cutoff_time_tomorrow

prd

mrw-prod-storepick.store_pick_views.edit_cutoff_time_tomorrow

Big Query Report

To assist with testing we will publish a report with details of notification failures and successes to the following big query tables:

Environment

Table

dev

mrw-storepick-dev.store_pick.Edit_Order_Notification_Report

sit

mrw-sit-storepick.store_pick.Edit_Order_Notification_Report

prd

mrw-prod-storepick.store_pick.Edit_Order_Notification_Report

Monitoring Service - Datadog

To allow detailed monitoring of metrics and important values within the application process, including the health of the process. During the running of the application, logs are made in a specific format shown below, which are then picked up by the Datadog service from the CloudWatch logs.

The MetricMonitoring class is used within the code to produce these logs (see Metric Monitoring (i.e. Datadog)), and this relies on the correct config for monitoring format (see: Configuration (from config service)).

Example log format needed to be picked up by Datadog:

"MONITORING|{timestamp}|{metric value}|{metric type}|sp_{app short name}_{metric name}_{environment}_{metric type}|app:{application name},env:{environment}"

Example of an “ok” (0 value) check log sent during running of the edit order notifications application:

"MONITORING|1581675879.286664|0|check|sp_eon_app_health_dev_check|app:storepick-edit-order-notification,env:dev"