@stacksjs/ts-cloud-core 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +321 -0
- package/package.json +31 -0
- package/src/advanced-features.test.ts +465 -0
- package/src/aws/cloudformation.ts +421 -0
- package/src/aws/cloudfront.ts +158 -0
- package/src/aws/credentials.test.ts +132 -0
- package/src/aws/credentials.ts +545 -0
- package/src/aws/index.ts +87 -0
- package/src/aws/s3.test.ts +188 -0
- package/src/aws/s3.ts +1088 -0
- package/src/aws/signature.test.ts +670 -0
- package/src/aws/signature.ts +1155 -0
- package/src/backup/disaster-recovery.test.ts +726 -0
- package/src/backup/disaster-recovery.ts +500 -0
- package/src/backup/index.ts +34 -0
- package/src/backup/manager.test.ts +498 -0
- package/src/backup/manager.ts +432 -0
- package/src/cicd/circleci.ts +430 -0
- package/src/cicd/github-actions.ts +424 -0
- package/src/cicd/gitlab-ci.ts +255 -0
- package/src/cicd/index.ts +8 -0
- package/src/cli/history.ts +396 -0
- package/src/cli/index.ts +10 -0
- package/src/cli/progress.ts +458 -0
- package/src/cli/repl.ts +454 -0
- package/src/cli/suggestions.ts +327 -0
- package/src/cli/table.test.ts +319 -0
- package/src/cli/table.ts +332 -0
- package/src/cloudformation/builder.test.ts +327 -0
- package/src/cloudformation/builder.ts +378 -0
- package/src/cloudformation/builders/api-gateway.ts +449 -0
- package/src/cloudformation/builders/cache.ts +334 -0
- package/src/cloudformation/builders/cdn.ts +278 -0
- package/src/cloudformation/builders/compute.ts +485 -0
- package/src/cloudformation/builders/database.ts +392 -0
- package/src/cloudformation/builders/functions.ts +343 -0
- package/src/cloudformation/builders/messaging.ts +140 -0
- package/src/cloudformation/builders/monitoring.ts +300 -0
- package/src/cloudformation/builders/network.ts +264 -0
- package/src/cloudformation/builders/queue.ts +147 -0
- package/src/cloudformation/builders/security.ts +399 -0
- package/src/cloudformation/builders/storage.ts +285 -0
- package/src/cloudformation/index.ts +30 -0
- package/src/cloudformation/types.ts +173 -0
- package/src/compliance/aws-config.ts +543 -0
- package/src/compliance/cloudtrail.ts +376 -0
- package/src/compliance/compliance.test.ts +423 -0
- package/src/compliance/guardduty.ts +446 -0
- package/src/compliance/index.ts +66 -0
- package/src/compliance/security-hub.ts +456 -0
- package/src/containers/build-optimization.ts +416 -0
- package/src/containers/containers.test.ts +508 -0
- package/src/containers/image-scanning.ts +360 -0
- package/src/containers/index.ts +9 -0
- package/src/containers/registry.ts +293 -0
- package/src/containers/service-mesh.ts +520 -0
- package/src/database/database.test.ts +762 -0
- package/src/database/index.ts +9 -0
- package/src/database/migrations.ts +444 -0
- package/src/database/performance.ts +528 -0
- package/src/database/replicas.ts +534 -0
- package/src/database/users.ts +494 -0
- package/src/dependency-graph.ts +143 -0
- package/src/deployment/ab-testing.ts +582 -0
- package/src/deployment/blue-green.ts +452 -0
- package/src/deployment/canary.ts +500 -0
- package/src/deployment/deployment.test.ts +526 -0
- package/src/deployment/index.ts +61 -0
- package/src/deployment/progressive.ts +62 -0
- package/src/dns/dns.test.ts +641 -0
- package/src/dns/dnssec.ts +315 -0
- package/src/dns/index.ts +8 -0
- package/src/dns/resolver.ts +496 -0
- package/src/dns/routing.ts +593 -0
- package/src/email/advanced/analytics.ts +445 -0
- package/src/email/advanced/index.ts +11 -0
- package/src/email/advanced/rules.ts +465 -0
- package/src/email/advanced/scheduling.ts +352 -0
- package/src/email/advanced/search.ts +412 -0
- package/src/email/advanced/shared-mailboxes.ts +404 -0
- package/src/email/advanced/templates.ts +455 -0
- package/src/email/advanced/threading.ts +281 -0
- package/src/email/analytics.ts +467 -0
- package/src/email/bounce-handling.ts +425 -0
- package/src/email/email.test.ts +431 -0
- package/src/email/handlers/__tests__/inbound.test.ts +38 -0
- package/src/email/handlers/__tests__/outbound.test.ts +37 -0
- package/src/email/handlers/converter.ts +227 -0
- package/src/email/handlers/feedback.ts +228 -0
- package/src/email/handlers/inbound.ts +169 -0
- package/src/email/handlers/outbound.ts +178 -0
- package/src/email/index.ts +15 -0
- package/src/email/reputation.ts +303 -0
- package/src/email/templates.ts +352 -0
- package/src/errors/index.test.ts +434 -0
- package/src/errors/index.ts +416 -0
- package/src/health-checks/index.ts +40 -0
- package/src/index.ts +360 -0
- package/src/intrinsic-functions.ts +118 -0
- package/src/lambda/concurrency.ts +330 -0
- package/src/lambda/destinations.ts +345 -0
- package/src/lambda/dlq.ts +425 -0
- package/src/lambda/index.ts +11 -0
- package/src/lambda/lambda.test.ts +840 -0
- package/src/lambda/layers.ts +263 -0
- package/src/lambda/versions.ts +376 -0
- package/src/lambda/vpc.ts +399 -0
- package/src/local/config.ts +114 -0
- package/src/local/index.ts +6 -0
- package/src/local/mock-aws.ts +351 -0
- package/src/modules/ai.ts +340 -0
- package/src/modules/api.ts +478 -0
- package/src/modules/auth.ts +805 -0
- package/src/modules/cache.ts +417 -0
- package/src/modules/cdn.ts +1062 -0
- package/src/modules/communication.ts +1094 -0
- package/src/modules/compute.ts +3348 -0
- package/src/modules/database.ts +554 -0
- package/src/modules/deployment.ts +1079 -0
- package/src/modules/dns.ts +337 -0
- package/src/modules/email.ts +1538 -0
- package/src/modules/filesystem.ts +515 -0
- package/src/modules/index.ts +32 -0
- package/src/modules/messaging.ts +486 -0
- package/src/modules/monitoring.ts +2086 -0
- package/src/modules/network.ts +664 -0
- package/src/modules/parameter-store.ts +325 -0
- package/src/modules/permissions.ts +1081 -0
- package/src/modules/phone.ts +494 -0
- package/src/modules/queue.ts +1260 -0
- package/src/modules/redirects.ts +464 -0
- package/src/modules/registry.ts +699 -0
- package/src/modules/search.ts +401 -0
- package/src/modules/secrets.ts +416 -0
- package/src/modules/security.ts +731 -0
- package/src/modules/sms.ts +389 -0
- package/src/modules/storage.ts +1120 -0
- package/src/modules/workflow.ts +680 -0
- package/src/multi-account/config.ts +521 -0
- package/src/multi-account/index.ts +7 -0
- package/src/multi-account/manager.ts +427 -0
- package/src/multi-region/cross-region.ts +410 -0
- package/src/multi-region/index.ts +8 -0
- package/src/multi-region/manager.ts +483 -0
- package/src/multi-region/regions.ts +435 -0
- package/src/network-security/index.ts +48 -0
- package/src/observability/index.ts +9 -0
- package/src/observability/logs.ts +522 -0
- package/src/observability/metrics.ts +460 -0
- package/src/observability/observability.test.ts +782 -0
- package/src/observability/synthetics.ts +568 -0
- package/src/observability/xray.ts +358 -0
- package/src/phone/advanced/analytics.ts +349 -0
- package/src/phone/advanced/callbacks.ts +428 -0
- package/src/phone/advanced/index.ts +8 -0
- package/src/phone/advanced/ivr-builder.ts +504 -0
- package/src/phone/advanced/recording.ts +310 -0
- package/src/phone/handlers/__tests__/incoming-call.test.ts +40 -0
- package/src/phone/handlers/incoming-call.ts +117 -0
- package/src/phone/handlers/missed-call.ts +116 -0
- package/src/phone/handlers/voicemail.ts +179 -0
- package/src/phone/index.ts +9 -0
- package/src/presets/api-backend.ts +134 -0
- package/src/presets/data-pipeline.ts +204 -0
- package/src/presets/extend.test.ts +295 -0
- package/src/presets/extend.ts +297 -0
- package/src/presets/fullstack-app.ts +144 -0
- package/src/presets/index.ts +27 -0
- package/src/presets/jamstack.ts +135 -0
- package/src/presets/microservices.ts +167 -0
- package/src/presets/ml-api.ts +208 -0
- package/src/presets/nodejs-server.ts +104 -0
- package/src/presets/nodejs-serverless.ts +114 -0
- package/src/presets/realtime-app.ts +184 -0
- package/src/presets/static-site.ts +64 -0
- package/src/presets/traditional-web-app.ts +339 -0
- package/src/presets/wordpress.ts +138 -0
- package/src/preview/github.test.ts +249 -0
- package/src/preview/github.ts +297 -0
- package/src/preview/index.ts +37 -0
- package/src/preview/manager.test.ts +440 -0
- package/src/preview/manager.ts +326 -0
- package/src/preview/notifications.test.ts +582 -0
- package/src/preview/notifications.ts +341 -0
- package/src/queue/batch-processing.ts +402 -0
- package/src/queue/dlq-monitoring.ts +402 -0
- package/src/queue/fifo.ts +342 -0
- package/src/queue/index.ts +9 -0
- package/src/queue/management.ts +428 -0
- package/src/queue/queue.test.ts +429 -0
- package/src/resource-mgmt/index.ts +39 -0
- package/src/resource-naming.ts +62 -0
- package/src/s3/index.ts +523 -0
- package/src/schema/cloud-config.schema.json +554 -0
- package/src/schema/index.ts +68 -0
- package/src/security/certificate-manager.ts +492 -0
- package/src/security/index.ts +9 -0
- package/src/security/scanning.ts +545 -0
- package/src/security/secrets-manager.ts +476 -0
- package/src/security/secrets-rotation.ts +456 -0
- package/src/security/security.test.ts +738 -0
- package/src/sms/advanced/ab-testing.ts +389 -0
- package/src/sms/advanced/analytics.ts +336 -0
- package/src/sms/advanced/campaigns.ts +523 -0
- package/src/sms/advanced/chatbot.ts +224 -0
- package/src/sms/advanced/index.ts +10 -0
- package/src/sms/advanced/link-tracking.ts +248 -0
- package/src/sms/advanced/mms.ts +308 -0
- package/src/sms/handlers/__tests__/send.test.ts +40 -0
- package/src/sms/handlers/delivery-status.ts +133 -0
- package/src/sms/handlers/receive.ts +162 -0
- package/src/sms/handlers/send.ts +174 -0
- package/src/sms/index.ts +9 -0
- package/src/stack-diff.ts +389 -0
- package/src/static-site/index.ts +85 -0
- package/src/template-builder.ts +110 -0
- package/src/template-validator.ts +574 -0
- package/src/utils/cache.ts +291 -0
- package/src/utils/diff.ts +269 -0
- package/src/utils/hash.ts +227 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/parallel.ts +294 -0
- package/src/validators/credentials.test.ts +274 -0
- package/src/validators/credentials.ts +233 -0
- package/src/validators/quotas.test.ts +434 -0
- package/src/validators/quotas.ts +217 -0
- package/test/ai.test.ts +327 -0
- package/test/api.test.ts +511 -0
- package/test/auth.test.ts +632 -0
- package/test/cache.test.ts +406 -0
- package/test/cdn.test.ts +247 -0
- package/test/compute.test.ts +861 -0
- package/test/database.test.ts +523 -0
- package/test/deployment.test.ts +499 -0
- package/test/dns.test.ts +270 -0
- package/test/email.test.ts +439 -0
- package/test/filesystem.test.ts +382 -0
- package/test/integration.test.ts +350 -0
- package/test/messaging.test.ts +514 -0
- package/test/monitoring.test.ts +634 -0
- package/test/network.test.ts +425 -0
- package/test/permissions.test.ts +488 -0
- package/test/queue.test.ts +484 -0
- package/test/registry.test.ts +306 -0
- package/test/security.test.ts +462 -0
- package/test/storage.test.ts +463 -0
- package/test/template-validator.test.ts +559 -0
- package/test/workflow.test.ts +592 -0
- package/tsconfig.json +16 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS Region utilities
|
|
3
|
+
* Region selection, validation, and configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface RegionInfo {
|
|
7
|
+
code: string
|
|
8
|
+
name: string
|
|
9
|
+
location: string
|
|
10
|
+
launchYear: number
|
|
11
|
+
availabilityZones: number
|
|
12
|
+
localZones?: number
|
|
13
|
+
wavelengthZones?: number
|
|
14
|
+
services: {
|
|
15
|
+
compute: boolean
|
|
16
|
+
storage: boolean
|
|
17
|
+
database: boolean
|
|
18
|
+
networking: boolean
|
|
19
|
+
ml: boolean
|
|
20
|
+
analytics: boolean
|
|
21
|
+
}
|
|
22
|
+
pricing: {
|
|
23
|
+
tier: 'standard' | 'reduced' | 'premium'
|
|
24
|
+
multiplier: number
|
|
25
|
+
}
|
|
26
|
+
compliance: string[]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* AWS Region database
|
|
31
|
+
*/
|
|
32
|
+
export const AWS_REGIONS: RegionInfo[] = [
|
|
33
|
+
{
|
|
34
|
+
code: 'us-east-1',
|
|
35
|
+
name: 'US East (N. Virginia)',
|
|
36
|
+
location: 'Virginia, USA',
|
|
37
|
+
launchYear: 2006,
|
|
38
|
+
availabilityZones: 6,
|
|
39
|
+
localZones: 16,
|
|
40
|
+
services: {
|
|
41
|
+
compute: true,
|
|
42
|
+
storage: true,
|
|
43
|
+
database: true,
|
|
44
|
+
networking: true,
|
|
45
|
+
ml: true,
|
|
46
|
+
analytics: true,
|
|
47
|
+
},
|
|
48
|
+
pricing: {
|
|
49
|
+
tier: 'standard',
|
|
50
|
+
multiplier: 1.0,
|
|
51
|
+
},
|
|
52
|
+
compliance: ['PCI-DSS', 'HIPAA', 'SOC', 'ISO', 'FedRAMP'],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
code: 'us-east-2',
|
|
56
|
+
name: 'US East (Ohio)',
|
|
57
|
+
location: 'Ohio, USA',
|
|
58
|
+
launchYear: 2016,
|
|
59
|
+
availabilityZones: 3,
|
|
60
|
+
services: {
|
|
61
|
+
compute: true,
|
|
62
|
+
storage: true,
|
|
63
|
+
database: true,
|
|
64
|
+
networking: true,
|
|
65
|
+
ml: true,
|
|
66
|
+
analytics: true,
|
|
67
|
+
},
|
|
68
|
+
pricing: {
|
|
69
|
+
tier: 'standard',
|
|
70
|
+
multiplier: 1.0,
|
|
71
|
+
},
|
|
72
|
+
compliance: ['PCI-DSS', 'HIPAA', 'SOC', 'ISO'],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
code: 'us-west-1',
|
|
76
|
+
name: 'US West (N. California)',
|
|
77
|
+
location: 'California, USA',
|
|
78
|
+
launchYear: 2009,
|
|
79
|
+
availabilityZones: 3,
|
|
80
|
+
services: {
|
|
81
|
+
compute: true,
|
|
82
|
+
storage: true,
|
|
83
|
+
database: true,
|
|
84
|
+
networking: true,
|
|
85
|
+
ml: true,
|
|
86
|
+
analytics: true,
|
|
87
|
+
},
|
|
88
|
+
pricing: {
|
|
89
|
+
tier: 'premium',
|
|
90
|
+
multiplier: 1.1,
|
|
91
|
+
},
|
|
92
|
+
compliance: ['PCI-DSS', 'HIPAA', 'SOC', 'ISO'],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
code: 'us-west-2',
|
|
96
|
+
name: 'US West (Oregon)',
|
|
97
|
+
location: 'Oregon, USA',
|
|
98
|
+
launchYear: 2011,
|
|
99
|
+
availabilityZones: 4,
|
|
100
|
+
localZones: 2,
|
|
101
|
+
services: {
|
|
102
|
+
compute: true,
|
|
103
|
+
storage: true,
|
|
104
|
+
database: true,
|
|
105
|
+
networking: true,
|
|
106
|
+
ml: true,
|
|
107
|
+
analytics: true,
|
|
108
|
+
},
|
|
109
|
+
pricing: {
|
|
110
|
+
tier: 'standard',
|
|
111
|
+
multiplier: 1.0,
|
|
112
|
+
},
|
|
113
|
+
compliance: ['PCI-DSS', 'HIPAA', 'SOC', 'ISO'],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
code: 'eu-west-1',
|
|
117
|
+
name: 'Europe (Ireland)',
|
|
118
|
+
location: 'Dublin, Ireland',
|
|
119
|
+
launchYear: 2007,
|
|
120
|
+
availabilityZones: 3,
|
|
121
|
+
services: {
|
|
122
|
+
compute: true,
|
|
123
|
+
storage: true,
|
|
124
|
+
database: true,
|
|
125
|
+
networking: true,
|
|
126
|
+
ml: true,
|
|
127
|
+
analytics: true,
|
|
128
|
+
},
|
|
129
|
+
pricing: {
|
|
130
|
+
tier: 'standard',
|
|
131
|
+
multiplier: 1.05,
|
|
132
|
+
},
|
|
133
|
+
compliance: ['PCI-DSS', 'GDPR', 'SOC', 'ISO'],
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
code: 'eu-central-1',
|
|
137
|
+
name: 'Europe (Frankfurt)',
|
|
138
|
+
location: 'Frankfurt, Germany',
|
|
139
|
+
launchYear: 2014,
|
|
140
|
+
availabilityZones: 3,
|
|
141
|
+
services: {
|
|
142
|
+
compute: true,
|
|
143
|
+
storage: true,
|
|
144
|
+
database: true,
|
|
145
|
+
networking: true,
|
|
146
|
+
ml: true,
|
|
147
|
+
analytics: true,
|
|
148
|
+
},
|
|
149
|
+
pricing: {
|
|
150
|
+
tier: 'premium',
|
|
151
|
+
multiplier: 1.1,
|
|
152
|
+
},
|
|
153
|
+
compliance: ['PCI-DSS', 'GDPR', 'SOC', 'ISO'],
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
code: 'ap-southeast-1',
|
|
157
|
+
name: 'Asia Pacific (Singapore)',
|
|
158
|
+
location: 'Singapore',
|
|
159
|
+
launchYear: 2010,
|
|
160
|
+
availabilityZones: 3,
|
|
161
|
+
services: {
|
|
162
|
+
compute: true,
|
|
163
|
+
storage: true,
|
|
164
|
+
database: true,
|
|
165
|
+
networking: true,
|
|
166
|
+
ml: true,
|
|
167
|
+
analytics: true,
|
|
168
|
+
},
|
|
169
|
+
pricing: {
|
|
170
|
+
tier: 'premium',
|
|
171
|
+
multiplier: 1.12,
|
|
172
|
+
},
|
|
173
|
+
compliance: ['PCI-DSS', 'SOC', 'ISO', 'MTCS'],
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
code: 'ap-northeast-1',
|
|
177
|
+
name: 'Asia Pacific (Tokyo)',
|
|
178
|
+
location: 'Tokyo, Japan',
|
|
179
|
+
launchYear: 2011,
|
|
180
|
+
availabilityZones: 4,
|
|
181
|
+
services: {
|
|
182
|
+
compute: true,
|
|
183
|
+
storage: true,
|
|
184
|
+
database: true,
|
|
185
|
+
networking: true,
|
|
186
|
+
ml: true,
|
|
187
|
+
analytics: true,
|
|
188
|
+
},
|
|
189
|
+
pricing: {
|
|
190
|
+
tier: 'premium',
|
|
191
|
+
multiplier: 1.15,
|
|
192
|
+
},
|
|
193
|
+
compliance: ['PCI-DSS', 'SOC', 'ISO'],
|
|
194
|
+
},
|
|
195
|
+
]
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Get region by code
|
|
199
|
+
*/
|
|
200
|
+
export function getRegion(code: string): RegionInfo | undefined {
|
|
201
|
+
return AWS_REGIONS.find(r => r.code === code)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Get all regions
|
|
206
|
+
*/
|
|
207
|
+
export function getAllRegions(): RegionInfo[] {
|
|
208
|
+
return AWS_REGIONS
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Get regions by location
|
|
213
|
+
*/
|
|
214
|
+
export function getRegionsByLocation(location: string): RegionInfo[] {
|
|
215
|
+
const lowerLocation = location.toLowerCase()
|
|
216
|
+
return AWS_REGIONS.filter(r => r.location.toLowerCase().includes(lowerLocation))
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Get regions with specific compliance
|
|
221
|
+
*/
|
|
222
|
+
export function getRegionsByCompliance(compliance: string): RegionInfo[] {
|
|
223
|
+
return AWS_REGIONS.filter(r => r.compliance.includes(compliance))
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Get regions by pricing tier
|
|
228
|
+
*/
|
|
229
|
+
export function getRegionsByPricingTier(tier: 'standard' | 'reduced' | 'premium'): RegionInfo[] {
|
|
230
|
+
return AWS_REGIONS.filter(r => r.pricing.tier === tier)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Validate region code
|
|
235
|
+
*/
|
|
236
|
+
export function isValidRegion(code: string): boolean {
|
|
237
|
+
return AWS_REGIONS.some(r => r.code === code)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Get closest region to user location
|
|
242
|
+
*/
|
|
243
|
+
export function getClosestRegion(userLocation: {
|
|
244
|
+
continent?: string
|
|
245
|
+
country?: string
|
|
246
|
+
}): RegionInfo {
|
|
247
|
+
// Simple heuristic based on location
|
|
248
|
+
if (userLocation.continent === 'North America') {
|
|
249
|
+
return getRegion('us-east-1')!
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (userLocation.continent === 'Europe') {
|
|
253
|
+
return getRegion('eu-west-1')!
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (userLocation.continent === 'Asia') {
|
|
257
|
+
return getRegion('ap-southeast-1')!
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Default to us-east-1
|
|
261
|
+
return getRegion('us-east-1')!
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Suggest regions based on requirements
|
|
266
|
+
*/
|
|
267
|
+
export interface RegionRequirements {
|
|
268
|
+
compliance?: string[]
|
|
269
|
+
pricingSensitive?: boolean
|
|
270
|
+
lowLatency?: boolean
|
|
271
|
+
userLocations?: string[]
|
|
272
|
+
requiredServices?: Array<keyof RegionInfo['services']>
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export function suggestRegions(requirements: RegionRequirements): RegionInfo[] {
|
|
276
|
+
let candidates = [...AWS_REGIONS]
|
|
277
|
+
|
|
278
|
+
// Filter by compliance
|
|
279
|
+
if (requirements.compliance) {
|
|
280
|
+
candidates = candidates.filter(r =>
|
|
281
|
+
requirements.compliance!.every(c => r.compliance.includes(c)),
|
|
282
|
+
)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Filter by required services
|
|
286
|
+
if (requirements.requiredServices) {
|
|
287
|
+
candidates = candidates.filter(r =>
|
|
288
|
+
requirements.requiredServices!.every(s => r.services[s]),
|
|
289
|
+
)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Sort by pricing if price sensitive
|
|
293
|
+
if (requirements.pricingSensitive) {
|
|
294
|
+
candidates.sort((a, b) => a.pricing.multiplier - b.pricing.multiplier)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return candidates.slice(0, 5) // Return top 5
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Calculate region pairs for failover
|
|
302
|
+
*/
|
|
303
|
+
export interface RegionPairSuggestion {
|
|
304
|
+
primary: RegionInfo
|
|
305
|
+
secondary: RegionInfo
|
|
306
|
+
distance: number
|
|
307
|
+
sameContinent: boolean
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export function suggestRegionPairs(primaryRegion: string): RegionPairSuggestion[] {
|
|
311
|
+
const primary = getRegion(primaryRegion)
|
|
312
|
+
|
|
313
|
+
if (!primary) {
|
|
314
|
+
throw new Error(`Invalid region: ${primaryRegion}`)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const suggestions: RegionPairSuggestion[] = []
|
|
318
|
+
|
|
319
|
+
for (const region of AWS_REGIONS) {
|
|
320
|
+
if (region.code === primaryRegion) continue
|
|
321
|
+
|
|
322
|
+
// Calculate geographic distance (simplified)
|
|
323
|
+
const distance = calculateDistance(primary, region)
|
|
324
|
+
const sameContinent = isSameContinent(primary, region)
|
|
325
|
+
|
|
326
|
+
suggestions.push({
|
|
327
|
+
primary,
|
|
328
|
+
secondary: region,
|
|
329
|
+
distance,
|
|
330
|
+
sameContinent,
|
|
331
|
+
})
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Sort by distance (prefer geographically distributed)
|
|
335
|
+
suggestions.sort((a, b) => {
|
|
336
|
+
// Prefer different continents
|
|
337
|
+
if (a.sameContinent !== b.sameContinent) {
|
|
338
|
+
return a.sameContinent ? 1 : -1
|
|
339
|
+
}
|
|
340
|
+
// Then by distance
|
|
341
|
+
return a.distance - b.distance
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
return suggestions.slice(0, 3) // Return top 3
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Calculate simplified distance between regions
|
|
349
|
+
*/
|
|
350
|
+
function calculateDistance(region1: RegionInfo, region2: RegionInfo): number {
|
|
351
|
+
// Simplified distance calculation
|
|
352
|
+
// In real implementation, would use actual lat/lon coordinates
|
|
353
|
+
const continents = {
|
|
354
|
+
'North America': 0,
|
|
355
|
+
'South America': 1,
|
|
356
|
+
'Europe': 2,
|
|
357
|
+
'Asia': 3,
|
|
358
|
+
'Africa': 4,
|
|
359
|
+
'Oceania': 5,
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const continent1 = getContinentFromLocation(region1.location)
|
|
363
|
+
const continent2 = getContinentFromLocation(region2.location)
|
|
364
|
+
|
|
365
|
+
return Math.abs(
|
|
366
|
+
(continents[continent1 as keyof typeof continents] || 0)
|
|
367
|
+
- (continents[continent2 as keyof typeof continents] || 0),
|
|
368
|
+
)
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Check if regions are on the same continent
|
|
373
|
+
*/
|
|
374
|
+
function isSameContinent(region1: RegionInfo, region2: RegionInfo): boolean {
|
|
375
|
+
return getContinentFromLocation(region1.location) === getContinentFromLocation(region2.location)
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Get continent from location string
|
|
380
|
+
*/
|
|
381
|
+
function getContinentFromLocation(location: string): string {
|
|
382
|
+
if (location.includes('USA') || location.includes('Canada')) {
|
|
383
|
+
return 'North America'
|
|
384
|
+
}
|
|
385
|
+
if (location.includes('Europe') || location.includes('Ireland') || location.includes('Germany')) {
|
|
386
|
+
return 'Europe'
|
|
387
|
+
}
|
|
388
|
+
if (location.includes('Asia') || location.includes('Singapore') || location.includes('Japan')) {
|
|
389
|
+
return 'Asia'
|
|
390
|
+
}
|
|
391
|
+
if (location.includes('Brazil')) {
|
|
392
|
+
return 'South America'
|
|
393
|
+
}
|
|
394
|
+
if (location.includes('Australia')) {
|
|
395
|
+
return 'Oceania'
|
|
396
|
+
}
|
|
397
|
+
return 'Unknown'
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Format region for display
|
|
402
|
+
*/
|
|
403
|
+
export function formatRegion(region: RegionInfo): string {
|
|
404
|
+
return `${region.name} (${region.code})`
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Format region list for display
|
|
409
|
+
*/
|
|
410
|
+
export function formatRegionList(regions: RegionInfo[]): string {
|
|
411
|
+
return regions.map(r => formatRegion(r)).join('\n')
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Get region statistics
|
|
416
|
+
*/
|
|
417
|
+
export function getRegionStats(): {
|
|
418
|
+
total: number
|
|
419
|
+
byContinent: Record<string, number>
|
|
420
|
+
byPricingTier: Record<string, number>
|
|
421
|
+
} {
|
|
422
|
+
const stats = {
|
|
423
|
+
total: AWS_REGIONS.length,
|
|
424
|
+
byContinent: {} as Record<string, number>,
|
|
425
|
+
byPricingTier: {} as Record<string, number>,
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
for (const region of AWS_REGIONS) {
|
|
429
|
+
const continent = getContinentFromLocation(region.location)
|
|
430
|
+
stats.byContinent[continent] = (stats.byContinent[continent] || 0) + 1
|
|
431
|
+
stats.byPricingTier[region.pricing.tier] = (stats.byPricingTier[region.pricing.tier] || 0) + 1
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
return stats
|
|
435
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Security - WAF, Shield, security groups, NACLs
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export interface WAFRule { id: string; name: string; priority: number; action: 'allow' | 'block' | 'count'; conditions: string[] }
|
|
6
|
+
export interface ShieldProtection { id: string; resourceArn: string; protectionType: 'standard' | 'advanced' }
|
|
7
|
+
export interface SecurityGroup { id: string; name: string; vpcId: string; rules: Array<{ protocol: string; port: number; source: string }> }
|
|
8
|
+
export interface NACL { id: string; vpcId: string; rules: Array<{ ruleNumber: number; protocol: string; action: 'allow' | 'deny' }> }
|
|
9
|
+
|
|
10
|
+
export class NetworkSecurityManager {
|
|
11
|
+
private wafRules = new Map<string, WAFRule>()
|
|
12
|
+
private shieldProtections = new Map<string, ShieldProtection>()
|
|
13
|
+
private securityGroups = new Map<string, SecurityGroup>()
|
|
14
|
+
private nacls = new Map<string, NACL>()
|
|
15
|
+
private counter = 0
|
|
16
|
+
|
|
17
|
+
createWAFRule(name: string, priority: number, action: 'allow' | 'block' | 'count', conditions: string[]): WAFRule {
|
|
18
|
+
const id = `waf-${Date.now()}-${this.counter++}`
|
|
19
|
+
const rule = { id, name, priority, action, conditions }
|
|
20
|
+
this.wafRules.set(id, rule)
|
|
21
|
+
return rule
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
enableShield(resourceArn: string, protectionType: 'standard' | 'advanced' = 'standard'): ShieldProtection {
|
|
25
|
+
const id = `shield-${Date.now()}-${this.counter++}`
|
|
26
|
+
const protection = { id, resourceArn, protectionType }
|
|
27
|
+
this.shieldProtections.set(id, protection)
|
|
28
|
+
return protection
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
createSecurityGroup(name: string, vpcId: string, rules: Array<{ protocol: string; port: number; source: string }>): SecurityGroup {
|
|
32
|
+
const id = `sg-${Date.now()}-${this.counter++}`
|
|
33
|
+
const sg = { id, name, vpcId, rules }
|
|
34
|
+
this.securityGroups.set(id, sg)
|
|
35
|
+
return sg
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
createNACL(vpcId: string, rules: Array<{ ruleNumber: number; protocol: string; action: 'allow' | 'deny' }>): NACL {
|
|
39
|
+
const id = `nacl-${Date.now()}-${this.counter++}`
|
|
40
|
+
const nacl = { id, vpcId, rules }
|
|
41
|
+
this.nacls.set(id, nacl)
|
|
42
|
+
return nacl
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
clear(): void { this.wafRules.clear(); this.shieldProtections.clear(); this.securityGroups.clear(); this.nacls.clear() }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const networkSecurityManager: NetworkSecurityManager = new NetworkSecurityManager()
|