forked from formkiq/formkiq-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegrationTests.yaml
More file actions
221 lines (198 loc) · 6.69 KB
/
integrationTests.yaml
File metadata and controls
221 lines (198 loc) · 6.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
AWSTemplateFormatVersion: '2010-09-09'
Description: FormKiq Integration Tests Template
Parameters:
AppEnvironment:
Type: String
Description: Application environment (e.g., dev, qa, prod)
Resources:
# === NEW Event Bus we are creating ===
ActionsEventBus:
Type: AWS::Events::EventBus
Properties:
Name: !Sub 'FormKiQ-Actions-${AppEnvironment}'
# === Queues ===
SnsQueue:
Type: AWS::SQS::Queue
Properties:
MessageRetentionPeriod: 60
ReceiveMessageWaitTimeSeconds: 20
EventBridgeQueue:
Type: AWS::SQS::Queue
Properties:
MessageRetentionPeriod: 60
ReceiveMessageWaitTimeSeconds: 20
ActionsEventQueue:
Type: AWS::SQS::Queue
Properties:
MessageRetentionPeriod: 60
ReceiveMessageWaitTimeSeconds: 20
# === Rule on the EXISTING bus -> EventBridgeQueue ===
EventBridgeRuleToEventBridgeQueue:
Type: AWS::Events::Rule
Properties:
Name: !Sub 'event-to-sqs-${AppEnvironment}'
Description: !Sub 'Route formkiq.${AppEnvironment} events to EventBridgeQueue (existing bus)'
EventBusName: !Sub 'FormKiQ-DocumentEvents-${AppEnvironment}' # existing bus, not created here
EventPattern:
source:
- !Sub 'formkiq.${AppEnvironment}'
Targets:
- Id: EventBridgeQueueTarget
Arn: !GetAtt EventBridgeQueue.Arn
EventBridgeQueuePolicy:
Type: AWS::SQS::QueuePolicy
Properties:
Queues:
- !Ref EventBridgeQueue
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AllowEventBridgeSpecificRule
Effect: Allow
Principal:
Service: events.amazonaws.com
Action: sqs:SendMessage
Resource: !GetAtt EventBridgeQueue.Arn
Condition:
ArnEquals:
aws:SourceArn: !GetAtt EventBridgeRuleToEventBridgeQueue.Arn
# === Rule on the NEW ActionsEventBus (match ALL events) -> ActionsEventQueue ===
ActionsAllEventsRule:
Type: AWS::Events::Rule
Properties:
Name: !Sub 'all-events-to-sqs-${AppEnvironment}'
Description: !Sub 'Route ALL events on FormKiQ-Actions-${AppEnvironment} to ActionsEventQueue'
EventBusName: !Ref ActionsEventBus
EventPattern:
source:
- !Sub 'formkiq.${AppEnvironment}'
Targets:
- Id: ActionsEventQueueTarget
Arn: !GetAtt ActionsEventQueue.Arn
ActionsEventQueuePolicy:
Type: AWS::SQS::QueuePolicy
Properties:
Queues:
- !Ref ActionsEventQueue
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AllowEventBridgeAllEventsRule
Effect: Allow
Principal:
Service: events.amazonaws.com
Action: sqs:SendMessage
Resource: !GetAtt ActionsEventQueue.Arn
Condition:
ArnEquals:
aws:SourceArn: !GetAtt ActionsAllEventsRule.Arn
# ===== SNS → SnsQueue wiring (topic ARN from SSM) =====
SnsTopicSubscription:
Type: AWS::SNS::Subscription
Properties:
Protocol: sqs
TopicArn: !Sub '{{resolve:ssm:/formkiq/${AppEnvironment}/sns/DocumentEventArn}}'
Endpoint: !GetAtt SnsQueue.Arn
RawMessageDelivery: true
DependsOn:
- SnsQueuePolicy
SnsQueuePolicy:
Type: AWS::SQS::QueuePolicy
Properties:
Queues:
- !Ref SnsQueue
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AllowSnsTopicToSend
Effect: Allow
Principal:
Service: sns.amazonaws.com
Action: sqs:SendMessage
Resource: !GetAtt SnsQueue.Arn
Condition:
ArnEquals:
aws:SourceArn: !Sub '{{resolve:ssm:/formkiq/${AppEnvironment}/sns/DocumentEventArn}}'
# -------- SSM Parameters --------
# SnsQueue
SnsQueueUrlParam:
Type: AWS::SSM::Parameter
Properties:
Name: !Sub '/formkiq/${AppEnvironment}/sqs/sns-queue/url'
Type: String
Description: !Sub 'SnsQueue URL for ${AppEnvironment}'
Value: !Ref SnsQueue
SnsQueueArnParam:
Type: AWS::SSM::Parameter
Properties:
Name: !Sub '/formkiq/${AppEnvironment}/sqs/sns-queue/arn'
Type: String
Description: !Sub 'SnsQueue ARN for ${AppEnvironment}'
Value: !GetAtt SnsQueue.Arn
# EventBridgeQueue
EventBridgeQueueUrlParam:
Type: AWS::SSM::Parameter
Properties:
Name: !Sub '/formkiq/${AppEnvironment}/sqs/eventbridge-queue/url'
Type: String
Description: !Sub 'EventBridgeQueue URL for ${AppEnvironment}'
Value: !Ref EventBridgeQueue
EventBridgeQueueArnParam:
Type: AWS::SSM::Parameter
Properties:
Name: !Sub '/formkiq/${AppEnvironment}/sqs/eventbridge-queue/arn'
Type: String
Description: !Sub 'EventBridgeQueue ARN for ${AppEnvironment}'
Value: !GetAtt EventBridgeQueue.Arn
# ActionsEventQueue (renamed from AllEventsQueue)
ActionsEventQueueUrlParam:
Type: AWS::SSM::Parameter
Properties:
Name: !Sub '/formkiq/${AppEnvironment}/sqs/actions-event-queue/url'
Type: String
Description: !Sub 'ActionsEventQueue URL for ${AppEnvironment}'
Value: !Ref ActionsEventQueue
ActionsEventQueueArnParam:
Type: AWS::SSM::Parameter
Properties:
Name: !Sub '/formkiq/${AppEnvironment}/sqs/actions-event-queue/arn'
Type: String
Description: !Sub 'ActionsEventQueue ARN for ${AppEnvironment}'
Value: !GetAtt ActionsEventQueue.Arn
# ActionsEventBus (name & ARN)
ActionsEventBusNameParam:
Type: AWS::SSM::Parameter
Properties:
Name: !Sub '/formkiq/${AppEnvironment}/eventbridge/actions-event-bus/name'
Type: String
Description: !Sub 'ActionsEventBus name for ${AppEnvironment}'
Value: !Ref ActionsEventBus
ActionsEventBusArnParam:
Type: AWS::SSM::Parameter
Properties:
Name: !Sub '/formkiq/${AppEnvironment}/eventbridge/actions-event-bus/arn'
Type: String
Description: !Sub 'ActionsEventBus ARN for ${AppEnvironment}'
Value: !GetAtt ActionsEventBus.Arn
Outputs:
ActionsEventBusNameOut:
Description: The name of the newly created Actions EventBridge bus
Value: !Ref ActionsEventBus
SnsQueueUrl:
Description: URL of SnsQueue
Value: !Ref SnsQueue
SnsQueueArn:
Description: ARN of SnsQueue
Value: !GetAtt SnsQueue.Arn
EventBridgeQueueUrl:
Description: URL of EventBridgeQueue
Value: !Ref EventBridgeQueue
EventBridgeQueueArn:
Description: ARN of EventBridgeQueue
Value: !GetAtt EventBridgeQueue.Arn
ActionsEventQueueUrl:
Description: URL of ActionsEventQueue
Value: !Ref ActionsEventQueue
ActionsEventQueueArn:
Description: ARN of ActionsEventQueue
Value: !GetAtt ActionsEventQueue.Arn