Skip to content

Commit 0d4db69

Browse files
authored
Merge pull request #33 from Kevinwochan/develop
Namespace Refactoring - with updated events
2 parents ee894cb + 4b08163 commit 0d4db69

31 files changed

+287
-165
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
*.DotSettings.user
55
.vscode/*
66
UnicornProperties.sln.DotSettings.user
7+
**/cdk.out/

Unicorn.Contracts/Integration/event-schemas.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Resources:
2020
Properties:
2121
Description: 'Event schemas for Unicorn Contracts'
2222
RegistryName:
23-
Fn::Sub: "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}-${Stage}"
23+
Fn::Sub: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}-${Stage}"
2424

2525
EventRegistryPolicy:
2626
Type: AWS::EventSchemas::RegistryPolicy

Unicorn.Contracts/Integration/subscriber-policies.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ Resources:
4747
"events:creatorAccount": "${aws:PrincipalAccount}"
4848
StringEquals:
4949
"events:source":
50-
- Fn::Sub: "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
50+
- "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
5151
"Null":
5252
"events:source": "false"

Unicorn.Contracts/template.yaml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: MIT-0
3-
AWSTemplateFormatVersion: 2010-09-09
3+
AWSTemplateFormatVersion: "2010-09-09"
44
Transform:
55
- AWS::LanguageExtensions
66
- AWS::Serverless-2016-10-31
@@ -12,10 +12,10 @@ Metadata:
1212
config:
1313
ignore_checks:
1414
- ES4000 # Rule disabled because the CatchAll Rule doesn't need a DLQ
15-
- ES6000 # Rule disabled because SQS DLOs don't need a RedrivePolicy
15+
- ES6000 # Rule disabled because SQS DLQs don't need a RedrivePolicy
1616
- WS2001 # Rule disabled because check does not support !ToJsonString transform
1717
- ES1001 # Rule disabled because our Lambda functions don't need DestinationConfig.OnFailure
18-
- W3002
18+
- W3002 # Rule disabled as nested templates are being packaged
1919

2020
Parameters:
2121
Stage:
@@ -54,19 +54,19 @@ Globals:
5454
Environment:
5555
Variables:
5656
DYNAMODB_TABLE: !Ref ContractsTable
57-
SERVICE_NAMESPACE: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
57+
SERVICE_NAMESPACE: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
5858
POWERTOOLS_LOGGER_CASE: PascalCase
59-
POWERTOOLS_SERVICE_NAME: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
59+
POWERTOOLS_SERVICE_NAME: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
6060
POWERTOOLS_TRACE_DISABLED: "false" # Explicitly disables tracing, default
6161
POWERTOOLS_LOGGER_LOG_EVENT: !If [IsProd, "false", "true"] # Logs incoming event, default
6262
POWERTOOLS_LOGGER_SAMPLE_RATE: !If [IsProd, "0.1", "0"] # Debug log sampling percentage, default
63-
POWERTOOLS_METRICS_NAMESPACE: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
63+
POWERTOOLS_METRICS_NAMESPACE: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
6464
POWERTOOLS_LOG_LEVEL: INFO # Log level for Logger (INFO, DEBUG, etc.), default
6565
LOG_LEVEL: INFO # Log level for Logger
6666
Tags:
6767
stage: !Ref Stage
6868
project: !FindInMap [Constants, ProjectName, Value]
69-
namespace: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
69+
namespace: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
7070

7171
Resources:
7272
#### SSM PARAMETERS
@@ -149,8 +149,9 @@ Resources:
149149
Tags:
150150
stage: !Ref Stage
151151
project: !FindInMap [Constants, ProjectName, Value]
152-
namespace: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
152+
namespace: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
153153

154+
# API GW Cloudwatch Log Group
154155
UnicornContractsApiLogGroup:
155156
Type: AWS::Logs::LogGroup
156157
UpdateReplacePolicy: Delete
@@ -217,7 +218,7 @@ Resources:
217218
- Key: project
218219
Value: !FindInMap [Constants, ProjectName, Value]
219220
- Key: namespace
220-
Value: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
221+
Value: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
221222

222223
#### DEAD LETTER QUEUES
223224
# DeadLetterQueue for UnicornContractsIngestQueue. Contains messages that failed to be processed
@@ -235,7 +236,7 @@ Resources:
235236
- Key: project
236237
Value: !FindInMap [Constants, ProjectName, Value]
237238
- Key: namespace
238-
Value: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
239+
Value: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
239240

240241
#### DYNAMODB TABLE
241242
# Persist Contracts information in DynamoDB
@@ -259,7 +260,7 @@ Resources:
259260
- Key: project
260261
Value: !FindInMap [Constants, ProjectName, Value]
261262
- Key: namespace
262-
Value: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
263+
Value: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
263264

264265
#### EVENT BUS
265266
# Event bus for Unicorn Contract Service used to publish and consume events
@@ -284,7 +285,7 @@ Resources:
284285
Condition:
285286
StringEquals:
286287
events:source:
287-
- !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
288+
- "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
288289

289290
# Catchall rule used for development purposes.
290291
UnicornContractsCatchAllRule:
@@ -297,9 +298,9 @@ Resources:
297298
account:
298299
- !Ref AWS::AccountId
299300
source:
300-
- !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
301-
- !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornPropertiesNamespace}}"
302-
- !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornWebNamespace}}"
301+
- "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
302+
- "{{resolve:ssm:/uni-prop/UnicornPropertiesNamespace}}"
303+
- "{{resolve:ssm:/uni-prop/UnicornWebNamespace}}"
303304
State: ENABLED #You may want to disable this rule in production
304305
Targets:
305306
- Arn: !GetAtt UnicornContractsCatchAllLogGroup.Arn
@@ -314,7 +315,7 @@ Resources:
314315
LogGroupName: !Sub
315316
- "/aws/events/${Stage}/${NS}-catchall"
316317
- Stage: !Ref Stage
317-
NS: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
318+
NS: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
318319
RetentionInDays: !FindInMap
319320
- LogsRetentionPeriodMap
320321
- !Ref Stage
@@ -375,7 +376,7 @@ Resources:
375376
Target: !GetAtt UnicornContractsEventBus.Arn
376377
TargetParameters:
377378
EventBridgeEventBusParameters:
378-
Source: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
379+
Source: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
379380
DetailType: ContractStatusChanged
380381
InputTemplate: !ToJsonString
381382
PropertyId: "<$.dynamodb.NewImage.PropertyId.S>"
@@ -431,12 +432,14 @@ Resources:
431432
- Key: project
432433
Value: !FindInMap [Constants, ProjectName, Value]
433434
- Key: namespace
434-
Value: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
435+
Value: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
435436

436437
#### CLOUDFORMATION NESTED STACKS
437438
# CloudFormation Stack with the Contracts Service Event Registry and Schemas
438439
EventSchemasStack:
439440
Type: AWS::Serverless::Application
441+
UpdateReplacePolicy: Delete
442+
DeletionPolicy: Delete
440443
Properties:
441444
Location: "Integration/event-schemas.yaml"
442445
Parameters:
@@ -445,6 +448,8 @@ Resources:
445448
# CloudFormation Stack with the Cross-service EventBus policy for Contracts Service
446449
SubscriberPoliciesStack:
447450
Type: AWS::Serverless::Application
451+
UpdateReplacePolicy: Delete
452+
DeletionPolicy: Delete
448453
DependsOn:
449454
- UnicornContractsEventBusNameParam
450455
Properties:

Unicorn.Properties/Integration/event-schemas.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: MIT-0
3-
AWSTemplateFormatVersion: '2010-09-09'
3+
AWSTemplateFormatVersion: "2010-09-09"
44
Description: Event Schemas for use by the Properties Service
55

66
Parameters:
@@ -18,7 +18,7 @@ Resources:
1818
Properties:
1919
Description: 'Event schemas for Unicorn Properties'
2020
RegistryName:
21-
Fn::Sub: "{{resolve:ssm:/uni-prop/${Stage}/UnicornPropertiesNamespace}}-${Stage}"
21+
Fn::Sub: "{{resolve:ssm:/uni-prop/UnicornPropertiesNamespace}}-${Stage}"
2222

2323
EventRegistryPolicy:
2424
Type: AWS::EventSchemas::RegistryPolicy

Unicorn.Properties/Integration/subscriber-policies.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: MIT-0
3-
AWSTemplateFormatVersion: '2010-09-09'
3+
AWSTemplateFormatVersion: "2010-09-09"
44
Description: >
55
Defines the event bus policies that determine who can create rules on the event bus to
66
subscribe to events published by Unicorn Properties Service.
@@ -46,6 +46,6 @@ Resources:
4646
"events:creatorAccount": "${aws:PrincipalAccount}"
4747
StringEquals:
4848
"events:source":
49-
- Fn::Sub: "{{resolve:ssm:/uni-prop/${Stage}/UnicornPropertiesNamespace}}"
49+
- "{{resolve:ssm:/uni-prop/UnicornPropertiesNamespace}}"
5050
"Null":
5151
"events:source": "false"

Unicorn.Properties/Integration/subscriptions.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: MIT-0
3-
AWSTemplateFormatVersion: '2010-09-09'
3+
AWSTemplateFormatVersion: "2010-09-09"
44
Description: Defines the rule for the events (subscriptions) that Unicorn Properties wants to consume.
55

66
Parameters:
@@ -23,7 +23,7 @@ Resources:
2323
Fn::Sub: "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsEventBusArn}}"
2424
EventPattern:
2525
source:
26-
- Fn::Sub: "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
26+
- "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
2727
detail-type:
2828
- ContractStatusChanged
2929
State: ENABLED
@@ -32,7 +32,7 @@ Resources:
3232
Arn:
3333
Fn::Sub: "{{resolve:ssm:/uni-prop/${Stage}/UnicornPropertiesEventBusArn}}"
3434
RoleArn:
35-
Fn::GetAtt: UnicornPropertiesSubscriptionRole.Arn
35+
Fn::GetAtt: [ UnicornPropertiesSubscriptionRole, Arn ]
3636

3737
#### UNICORN WEB EVENT SUBSCRIPTIONS
3838
PublicationApprovalRequestedSubscriptionRule:
@@ -44,7 +44,7 @@ Resources:
4444
Fn::Sub: "{{resolve:ssm:/uni-prop/${Stage}/UnicornWebEventBusArn}}"
4545
EventPattern:
4646
source:
47-
- Fn::Sub: "{{resolve:ssm:/uni-prop/${Stage}/UnicornWebNamespace}}"
47+
- "{{resolve:ssm:/uni-prop/UnicornWebNamespace}}"
4848
detail-type:
4949
- PublicationApprovalRequested
5050
State: ENABLED
@@ -53,7 +53,7 @@ Resources:
5353
Arn:
5454
Fn::Sub: "{{resolve:ssm:/uni-prop/${Stage}/UnicornPropertiesEventBusArn}}"
5555
RoleArn:
56-
Fn::GetAtt: UnicornPropertiesSubscriptionRole.Arn
56+
Fn::GetAtt: [ UnicornPropertiesSubscriptionRole, Arn ]
5757

5858

5959
# This IAM role allows EventBridge to assume the permissions necessary to send events
@@ -81,9 +81,10 @@ Outputs:
8181
ContractStatusChangedSubscription:
8282
Description: Rule ARN for Contract service event subscription
8383
Value:
84-
Fn::GetAtt: ContractStatusChangedSubscriptionRule.Arn
84+
Fn::GetAtt: [ ContractStatusChangedSubscriptionRule, Arn ]
8585

8686
PublicationApprovalRequestedSubscription:
8787
Description: Rule ARN for Web service event subscription
8888
Value:
89-
Fn::GetAtt: PublicationApprovalRequestedSubscriptionRule.Arn
89+
Fn::GetAtt: [ PublicationApprovalRequestedSubscriptionRule, Arn ]
90+

Unicorn.Properties/PropertiesService.Tests/events/EventBridge/contract_status_changed_event_contract_1_approved.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"DetailType": "ContractStatusChanged",
44
"Source": "unicorn.contracts",
5-
"EventBusName": "UnicornPropertiesEventBus-Local",
5+
"EventBusName": "UnicornPropertiesBus-local",
66
"Detail": "{ \"ContractUpdatedOn\": \"10/08/2022 19:56:30\", \"ContractId\": \"f2bedc80-3dc8-4544-9140-9b606d71a6ee\", \"PropertyId\": \"usa/anytown/main-street/111\", \"ContractStatus\": \"APPROVED\" }"
77
}
88
]

Unicorn.Properties/PropertiesService.Tests/events/EventBridge/contract_status_changed_event_contract_1_draft.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"DetailType": "ContractStatusChanged",
44
"Source": "unicorn.contracts",
5-
"EventBusName": "UnicornPropertiesEventBus-Local",
5+
"EventBusName": "UnicornPropertiesBus-local",
66
"Detail": "{ \"ContractUpdatedOn\": \"10/08/2022 19:56:30\", \"ContractId\": \"f2bedc80-3dc8-4544-9140-9b606d71a6ee\", \"PropertyId\": \"usa/anytown/main-street/111\", \"ContractStatus\": \"DRAFT\" }"
77
}
88
]

Unicorn.Properties/PropertiesService.Tests/events/EventBridge/contract_status_changed_event_contract_2_approved.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"DetailType": "ContractStatusChanged",
44
"Source": "unicorn.contracts",
5-
"EventBusName": "UnicornPropertiesEventBus-Local",
5+
"EventBusName": "UnicornPropertiesBus-local",
66
"Detail": "{ \"ContractUpdatedOn\": \"10/08/2022 19:56:30\", \"ContractId\": \"9183453b-d284-4466-a2d9-f00b1d569ad7\", \"PropertyId\": \"usa/anytown/main-street/222\", \"ContractStatus\": \"APPROVED\" }"
77
}
88
]

0 commit comments

Comments
 (0)