Skip to content

Commit 8260389

Browse files
authored
Fix: [AEA-0000] - Redeploy notification table stage 1 (#1657)
## Summary - ⚠️ Potential issues that might be caused by this change ### Details Remove references to the table, whilst also reverting the table definition to the old one so collisions are prevented!
1 parent 67de8c0 commit 8260389

1 file changed

Lines changed: 69 additions & 6 deletions

File tree

SAMtemplates/tables/main.yaml

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,19 +426,29 @@ Resources:
426426
PointInTimeRecoverySpecification:
427427
PointInTimeRecoveryEnabled: true
428428
AttributeDefinitions:
429-
- AttributeName: NHSNumber
429+
- AttributeName: PrescriptionID
430430
AttributeType: S
431-
- AttributeName: ODSCode
431+
- AttributeName: NHSNumber
432432
AttributeType: S
433433
KeySchema:
434-
- AttributeName: NHSNumber
435-
KeyType: HASH # Partition key
436-
- AttributeName: ODSCode
437-
KeyType: RANGE # Sort key
434+
- AttributeName: PrescriptionID
435+
KeyType: HASH
438436
BillingMode: !If
439437
- EnableDynamoDBAutoScalingCondition
440438
- PROVISIONED
441439
- PAY_PER_REQUEST
440+
GlobalSecondaryIndexes:
441+
- IndexName: NotificationNHSNumberIndex
442+
KeySchema:
443+
- AttributeName: NHSNumber
444+
KeyType: HASH
445+
Projection:
446+
ProjectionType: ALL
447+
ProvisionedThroughput: !If
448+
- EnableDynamoDBAutoScalingCondition
449+
- ReadCapacityUnits: 1
450+
WriteCapacityUnits: !Ref MinWritePrescriptionNotificationStateCapacity
451+
- !Ref "AWS::NoValue"
442452
ProvisionedThroughput: !If
443453
- EnableDynamoDBAutoScalingCondition
444454
- ReadCapacityUnits: 1
@@ -514,6 +524,59 @@ Resources:
514524
PredefinedMetricSpecification:
515525
PredefinedMetricType: DynamoDBReadCapacityUtilization
516526

527+
# Scaling for the indexes
528+
NotificationNHSNumberIndexScalingWriteTarget:
529+
Type: AWS::ApplicationAutoScaling::ScalableTarget
530+
DependsOn: PrescriptionNotificationStateTable
531+
Condition: EnableDynamoDBAutoScalingCondition
532+
Properties:
533+
MinCapacity: !Ref MinWritePrescriptionNotificationStateCapacity
534+
MaxCapacity: !Ref MaxWritePrescriptionNotificationStateCapacity
535+
ResourceId: !Sub table/${PrescriptionNotificationStateTable}/index/NotificationNHSNumberIndex
536+
RoleARN: !GetAtt DynamoDbScalingRole.Arn
537+
ScalableDimension: "dynamodb:index:WriteCapacityUnits"
538+
ServiceNamespace: dynamodb
539+
540+
NotificationNHSNumberIndexScalingWritePolicy:
541+
Type: AWS::ApplicationAutoScaling::ScalingPolicy
542+
Condition: EnableDynamoDBAutoScalingCondition
543+
Properties:
544+
PolicyName: NotificationNHSNumberIndexScalingWritePolicy
545+
PolicyType: TargetTrackingScaling
546+
ScalingTargetId: !Ref NotificationNHSNumberIndexScalingWriteTarget
547+
TargetTrackingScalingPolicyConfiguration:
548+
TargetValue: 50
549+
ScaleInCooldown: 600
550+
ScaleOutCooldown: 0
551+
PredefinedMetricSpecification:
552+
PredefinedMetricType: DynamoDBWriteCapacityUtilization
553+
554+
NotificationNHSNumberIndexScalingReadTarget:
555+
Type: AWS::ApplicationAutoScaling::ScalableTarget
556+
DependsOn: PrescriptionNotificationStateTable
557+
Condition: EnableDynamoDBAutoScalingCondition
558+
Properties:
559+
MinCapacity: 1
560+
MaxCapacity: 100
561+
ResourceId: !Sub table/${PrescriptionNotificationStateTable}/index/NotificationNHSNumberIndex
562+
RoleARN: !GetAtt DynamoDbScalingRole.Arn
563+
ScalableDimension: "dynamodb:index:ReadCapacityUnits"
564+
ServiceNamespace: dynamodb
565+
566+
NotificationNHSNumberIndexScalingReadPolicy:
567+
Type: AWS::ApplicationAutoScaling::ScalingPolicy
568+
Condition: EnableDynamoDBAutoScalingCondition
569+
Properties:
570+
PolicyName: NotificationNHSNumberIndexReadScalingPolicy
571+
PolicyType: TargetTrackingScaling
572+
ScalingTargetId: !Ref NotificationNHSNumberIndexScalingReadTarget
573+
TargetTrackingScalingPolicyConfiguration:
574+
TargetValue: 70
575+
ScaleInCooldown: 60
576+
ScaleOutCooldown: 60
577+
PredefinedMetricSpecification:
578+
PredefinedMetricType: DynamoDBReadCapacityUtilization
579+
517580
Outputs:
518581
PrescriptionStatusUpdatesTableName:
519582
Description: PrescriptionStatusUpdates table name

0 commit comments

Comments
 (0)