Skip to content

Commit 851b603

Browse files
authored
Merge pull request #38 from aws-samples/sliedig-ns-refactor
feat: namespace refactoring
2 parents a1d8cec + 0c095c4 commit 851b603

File tree

16 files changed

+204
-123
lines changed

16 files changed

+204
-123
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ deleteall.sh
1111
/unicorn_properties/PropertyFunctions/PropertyService.iml
1212
/unicorn_web/PropertyFunctions/PropertyWeb.iml
1313
/unicorn_contracts/ContractsFunction/ContractsModule.iml
14+
**/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,18 +54,18 @@ Globals:
5454
Environment:
5555
Variables:
5656
DYNAMODB_TABLE: !Ref ContractsTable
57-
SERVICE_NAMESPACE: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
58-
POWERTOOLS_SERVICE_NAME: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
57+
SERVICE_NAMESPACE: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
58+
POWERTOOLS_SERVICE_NAME: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
5959
POWERTOOLS_TRACE_DISABLED: "false" # Explicitly disables tracing, default
6060
POWERTOOLS_LOGGER_LOG_EVENT: !If [IsProd, "false", "true"] # Logs incoming event, default
6161
POWERTOOLS_LOGGER_SAMPLE_RATE: !If [IsProd, "0.1", "0"] # Debug log sampling percentage, default
62-
POWERTOOLS_METRICS_NAMESPACE: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
62+
POWERTOOLS_METRICS_NAMESPACE: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
6363
POWERTOOLS_LOG_LEVEL: INFO # Log level for Logger (INFO, DEBUG, etc.), default
6464
LOG_LEVEL: INFO # Log level for Logger
6565
Tags:
6666
stage: !Ref Stage
6767
project: !FindInMap [Constants, ProjectName, Value]
68-
namespace: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
68+
namespace: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
6969

7070
Resources:
7171
#### SSM PARAMETERS
@@ -148,8 +148,9 @@ Resources:
148148
Tags:
149149
stage: !Ref Stage
150150
project: !FindInMap [Constants, ProjectName, Value]
151-
namespace: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
151+
namespace: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
152152

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

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

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

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

288289
# Catchall rule used for development purposes.
289290
UnicornContractsCatchAllRule:
@@ -296,9 +297,9 @@ Resources:
296297
account:
297298
- !Ref AWS::AccountId
298299
source:
299-
- !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
300-
- !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornPropertiesNamespace}}"
301-
- !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornWebNamespace}}"
300+
- "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
301+
- "{{resolve:ssm:/uni-prop/UnicornPropertiesNamespace}}"
302+
- "{{resolve:ssm:/uni-prop/UnicornWebNamespace}}"
302303
State: ENABLED #You may want to disable this rule in production
303304
Targets:
304305
- Arn: !GetAtt UnicornContractsCatchAllLogGroup.Arn
@@ -313,7 +314,7 @@ Resources:
313314
LogGroupName: !Sub
314315
- "/aws/events/${Stage}/${NS}-catchall"
315316
- Stage: !Ref Stage
316-
NS: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
317+
NS: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
317318
RetentionInDays: !FindInMap
318319
- LogsRetentionPeriodMap
319320
- !Ref Stage
@@ -374,7 +375,7 @@ Resources:
374375
Target: !GetAtt UnicornContractsEventBus.Arn
375376
TargetParameters:
376377
EventBridgeEventBusParameters:
377-
Source: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
378+
Source: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
378379
DetailType: ContractStatusChanged
379380
InputTemplate: !ToJsonString
380381
property_id: "<$.dynamodb.NewImage.property_id.S>"
@@ -430,12 +431,14 @@ Resources:
430431
- Key: project
431432
Value: !FindInMap [Constants, ProjectName, Value]
432433
- Key: namespace
433-
Value: !Sub "{{resolve:ssm:/uni-prop/${Stage}/UnicornContractsNamespace}}"
434+
Value: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
434435

435436
#### CLOUDFORMATION NESTED STACKS
436437
# CloudFormation Stack with the Contracts Service Event Registry and Schemas
437438
EventSchemasStack:
438439
Type: AWS::Serverless::Application
440+
UpdateReplacePolicy: Delete
441+
DeletionPolicy: Delete
439442
Properties:
440443
Location: "integration/event-schemas.yaml"
441444
Parameters:
@@ -444,6 +447,8 @@ Resources:
444447
# CloudFormation Stack with the Cross-service EventBus policy for Contracts Service
445448
SubscriberPoliciesStack:
446449
Type: AWS::Serverless::Application
450+
UpdateReplacePolicy: Delete
451+
DeletionPolicy: Delete
447452
DependsOn:
448453
- UnicornContractsEventBusNameParam
449454
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: 7 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,9 @@ 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 ]

0 commit comments

Comments
 (0)