@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,339 @@
|
|
|
1
|
+
import type { CloudConfig } from '@stacksjs/ts-cloud-types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Traditional Web App Preset
|
|
5
|
+
* Perfect for: Server-rendered web apps, CMS platforms, admin panels
|
|
6
|
+
* Includes: EC2 + ALB + RDS + Redis + EFS (for session storage and uploads)
|
|
7
|
+
*/
|
|
8
|
+
export function createTraditionalWebAppPreset(options: {
|
|
9
|
+
name: string
|
|
10
|
+
slug: string
|
|
11
|
+
domain?: string
|
|
12
|
+
instanceType?: string
|
|
13
|
+
minInstances?: number
|
|
14
|
+
maxInstances?: number
|
|
15
|
+
databaseEngine?: 'mysql' | 'postgres'
|
|
16
|
+
sessionStore?: 'redis' | 'database'
|
|
17
|
+
}): Partial<CloudConfig> {
|
|
18
|
+
const {
|
|
19
|
+
name,
|
|
20
|
+
slug,
|
|
21
|
+
domain,
|
|
22
|
+
instanceType = 't3.medium',
|
|
23
|
+
minInstances = 2,
|
|
24
|
+
maxInstances = 10,
|
|
25
|
+
databaseEngine = 'mysql',
|
|
26
|
+
sessionStore = 'redis',
|
|
27
|
+
} = options
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
project: {
|
|
31
|
+
name,
|
|
32
|
+
slug,
|
|
33
|
+
region: 'us-east-1',
|
|
34
|
+
},
|
|
35
|
+
mode: 'server',
|
|
36
|
+
environments: {
|
|
37
|
+
production: {
|
|
38
|
+
type: 'production',
|
|
39
|
+
domain,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
infrastructure: {
|
|
43
|
+
network: {
|
|
44
|
+
vpc: {
|
|
45
|
+
cidr: '10.0.0.0/16',
|
|
46
|
+
availabilityZones: 2,
|
|
47
|
+
natGateways: 2, // Multi-AZ NAT for high availability
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
compute: {
|
|
51
|
+
server: {
|
|
52
|
+
instanceType,
|
|
53
|
+
ami: 'ubuntu-22.04',
|
|
54
|
+
autoScaling: {
|
|
55
|
+
min: minInstances,
|
|
56
|
+
max: maxInstances,
|
|
57
|
+
targetCPU: 70,
|
|
58
|
+
scaleUpCooldown: 300,
|
|
59
|
+
scaleDownCooldown: 300,
|
|
60
|
+
},
|
|
61
|
+
loadBalancer: {
|
|
62
|
+
type: 'application',
|
|
63
|
+
healthCheck: {
|
|
64
|
+
path: '/health',
|
|
65
|
+
interval: 30,
|
|
66
|
+
timeout: 5,
|
|
67
|
+
healthyThreshold: 2,
|
|
68
|
+
unhealthyThreshold: 3,
|
|
69
|
+
},
|
|
70
|
+
stickySession: {
|
|
71
|
+
enabled: true,
|
|
72
|
+
duration: 86400, // 24 hours
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
userData: `#!/bin/bash
|
|
76
|
+
# Install Node.js or PHP/Python based on app needs
|
|
77
|
+
# Configure application server (PM2, Nginx, Apache)
|
|
78
|
+
# Mount EFS for shared file storage
|
|
79
|
+
`,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
storage: {
|
|
83
|
+
uploads: {
|
|
84
|
+
// EFS for shared file storage across instances
|
|
85
|
+
type: 'efs',
|
|
86
|
+
performanceMode: 'generalPurpose',
|
|
87
|
+
throughputMode: 'bursting',
|
|
88
|
+
encrypted: true,
|
|
89
|
+
lifecyclePolicy: {
|
|
90
|
+
transitionToIA: 30, // Move to infrequent access after 30 days
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
backups: {
|
|
94
|
+
// S3 for backups and static assets
|
|
95
|
+
public: false,
|
|
96
|
+
versioning: true,
|
|
97
|
+
encryption: true,
|
|
98
|
+
lifecycleRules: [{
|
|
99
|
+
id: 'ArchiveOldBackups',
|
|
100
|
+
enabled: true,
|
|
101
|
+
transitions: [{
|
|
102
|
+
days: 90,
|
|
103
|
+
storageClass: 'GLACIER',
|
|
104
|
+
}],
|
|
105
|
+
}],
|
|
106
|
+
},
|
|
107
|
+
static: {
|
|
108
|
+
// S3 for static assets with CloudFront CDN
|
|
109
|
+
public: true,
|
|
110
|
+
versioning: false,
|
|
111
|
+
encryption: false,
|
|
112
|
+
cors: [{
|
|
113
|
+
allowedOrigins: [domain || '*'],
|
|
114
|
+
allowedMethods: ['GET', 'HEAD'],
|
|
115
|
+
}],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
cdn: {
|
|
119
|
+
enabled: true,
|
|
120
|
+
origins: [{
|
|
121
|
+
// Static assets from S3
|
|
122
|
+
originId: 'static-assets',
|
|
123
|
+
domainName: `${slug}-static.s3.amazonaws.com`,
|
|
124
|
+
pathPattern: '/static/*',
|
|
125
|
+
}],
|
|
126
|
+
customDomain: domain ? {
|
|
127
|
+
domain,
|
|
128
|
+
certificateArn: 'TO_BE_GENERATED',
|
|
129
|
+
} : undefined,
|
|
130
|
+
cachePolicy: {
|
|
131
|
+
minTTL: 0,
|
|
132
|
+
defaultTTL: 86400, // 1 day for static assets
|
|
133
|
+
maxTTL: 31536000, // 1 year max
|
|
134
|
+
},
|
|
135
|
+
compress: true,
|
|
136
|
+
http3: true,
|
|
137
|
+
},
|
|
138
|
+
databases: databaseEngine === 'mysql' ? {
|
|
139
|
+
mysql: {
|
|
140
|
+
engine: 'mysql',
|
|
141
|
+
version: '8.0',
|
|
142
|
+
instanceClass: 'db.t3.medium',
|
|
143
|
+
allocatedStorage: 100,
|
|
144
|
+
maxAllocatedStorage: 500, // Auto-scaling storage
|
|
145
|
+
multiAZ: true,
|
|
146
|
+
backupRetentionDays: 14,
|
|
147
|
+
preferredBackupWindow: '03:00-04:00',
|
|
148
|
+
preferredMaintenanceWindow: 'sun:04:00-sun:05:00',
|
|
149
|
+
enablePerformanceInsights: true,
|
|
150
|
+
performanceInsightsRetention: 7,
|
|
151
|
+
deletionProtection: true,
|
|
152
|
+
parameters: {
|
|
153
|
+
max_connections: '500',
|
|
154
|
+
innodb_buffer_pool_size: '{DBInstanceClassMemory*3/4}',
|
|
155
|
+
slow_query_log: '1',
|
|
156
|
+
long_query_time: '2',
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
} : {
|
|
160
|
+
postgres: {
|
|
161
|
+
engine: 'postgres',
|
|
162
|
+
version: '15',
|
|
163
|
+
instanceClass: 'db.t3.medium',
|
|
164
|
+
allocatedStorage: 100,
|
|
165
|
+
maxAllocatedStorage: 500,
|
|
166
|
+
multiAZ: true,
|
|
167
|
+
backupRetentionDays: 14,
|
|
168
|
+
preferredBackupWindow: '03:00-04:00',
|
|
169
|
+
preferredMaintenanceWindow: 'sun:04:00-sun:05:00',
|
|
170
|
+
enablePerformanceInsights: true,
|
|
171
|
+
performanceInsightsRetention: 7,
|
|
172
|
+
deletionProtection: true,
|
|
173
|
+
parameters: {
|
|
174
|
+
max_connections: '500',
|
|
175
|
+
shared_buffers: '{DBInstanceClassMemory/4}',
|
|
176
|
+
log_min_duration_statement: '2000', // Log slow queries > 2s
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
cache: sessionStore === 'redis' ? {
|
|
181
|
+
redis: {
|
|
182
|
+
nodeType: 'cache.t3.medium',
|
|
183
|
+
numCacheNodes: 2,
|
|
184
|
+
engine: 'redis',
|
|
185
|
+
engineVersion: '7.0',
|
|
186
|
+
port: 6379,
|
|
187
|
+
parameterGroup: {
|
|
188
|
+
maxmemoryPolicy: 'allkeys-lru',
|
|
189
|
+
timeout: '300',
|
|
190
|
+
},
|
|
191
|
+
snapshotRetentionLimit: 5,
|
|
192
|
+
snapshotWindow: '03:00-05:00',
|
|
193
|
+
automaticFailoverEnabled: true,
|
|
194
|
+
},
|
|
195
|
+
} : undefined,
|
|
196
|
+
queues: {
|
|
197
|
+
jobs: {
|
|
198
|
+
// Background job processing
|
|
199
|
+
fifo: false,
|
|
200
|
+
visibilityTimeout: 900, // 15 minutes
|
|
201
|
+
messageRetentionPeriod: 345600, // 4 days
|
|
202
|
+
receiveMessageWaitTime: 20, // Long polling
|
|
203
|
+
deadLetterQueue: true,
|
|
204
|
+
maxReceiveCount: 3,
|
|
205
|
+
},
|
|
206
|
+
emails: {
|
|
207
|
+
// Email queue
|
|
208
|
+
fifo: false,
|
|
209
|
+
visibilityTimeout: 300,
|
|
210
|
+
messageRetentionPeriod: 86400,
|
|
211
|
+
deadLetterQueue: true,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
functions: {
|
|
215
|
+
// Background job worker
|
|
216
|
+
'job-worker': {
|
|
217
|
+
runtime: 'nodejs20.x',
|
|
218
|
+
handler: 'dist/workers/jobs.handler',
|
|
219
|
+
memory: 2048,
|
|
220
|
+
timeout: 900, // 15 minutes
|
|
221
|
+
events: [{
|
|
222
|
+
type: 'sqs',
|
|
223
|
+
queueName: `${slug}-jobs`,
|
|
224
|
+
batchSize: 10,
|
|
225
|
+
}],
|
|
226
|
+
},
|
|
227
|
+
// Email sender
|
|
228
|
+
'email-sender': {
|
|
229
|
+
runtime: 'nodejs20.x',
|
|
230
|
+
handler: 'dist/workers/email.handler',
|
|
231
|
+
memory: 512,
|
|
232
|
+
timeout: 60,
|
|
233
|
+
events: [{
|
|
234
|
+
type: 'sqs',
|
|
235
|
+
queueName: `${slug}-emails`,
|
|
236
|
+
batchSize: 10,
|
|
237
|
+
}],
|
|
238
|
+
},
|
|
239
|
+
// Cleanup task
|
|
240
|
+
cleanup: {
|
|
241
|
+
runtime: 'nodejs20.x',
|
|
242
|
+
handler: 'dist/tasks/cleanup.handler',
|
|
243
|
+
memory: 512,
|
|
244
|
+
timeout: 300,
|
|
245
|
+
events: [{
|
|
246
|
+
type: 'schedule',
|
|
247
|
+
expression: 'cron(0 2 * * ? *)', // Daily at 2 AM
|
|
248
|
+
}],
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
monitoring: {
|
|
252
|
+
dashboard: {
|
|
253
|
+
name: `${slug}-web-app`,
|
|
254
|
+
widgets: [{
|
|
255
|
+
type: 'metric',
|
|
256
|
+
metrics: [
|
|
257
|
+
'EC2CPUUtilization',
|
|
258
|
+
'ALBRequestCount',
|
|
259
|
+
'ALBTargetResponseTime',
|
|
260
|
+
'RDSCPUUtilization',
|
|
261
|
+
'RDSDatabaseConnections',
|
|
262
|
+
'RDSReadLatency',
|
|
263
|
+
'RDSWriteLatency',
|
|
264
|
+
],
|
|
265
|
+
}],
|
|
266
|
+
},
|
|
267
|
+
alarms: [{
|
|
268
|
+
metric: 'EC2CPUUtilization',
|
|
269
|
+
threshold: 80,
|
|
270
|
+
evaluationPeriods: 2,
|
|
271
|
+
}, {
|
|
272
|
+
metric: 'RDSCPUUtilization',
|
|
273
|
+
threshold: 80,
|
|
274
|
+
evaluationPeriods: 2,
|
|
275
|
+
}, {
|
|
276
|
+
metric: 'RDSDatabaseConnections',
|
|
277
|
+
threshold: 400, // Alert at 80% of max connections
|
|
278
|
+
evaluationPeriods: 1,
|
|
279
|
+
}, {
|
|
280
|
+
metric: 'ALBTargetResponseTime',
|
|
281
|
+
threshold: 2000, // 2 seconds
|
|
282
|
+
evaluationPeriods: 2,
|
|
283
|
+
}, {
|
|
284
|
+
metric: 'ALBUnhealthyHostCount',
|
|
285
|
+
threshold: 1,
|
|
286
|
+
evaluationPeriods: 1,
|
|
287
|
+
}],
|
|
288
|
+
logs: {
|
|
289
|
+
retention: 14, // Days
|
|
290
|
+
groups: [
|
|
291
|
+
`${slug}-app`,
|
|
292
|
+
`${slug}-nginx`,
|
|
293
|
+
`${slug}-workers`,
|
|
294
|
+
],
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
security: {
|
|
298
|
+
certificate: domain ? {
|
|
299
|
+
domain,
|
|
300
|
+
validationMethod: 'DNS',
|
|
301
|
+
} : undefined,
|
|
302
|
+
waf: {
|
|
303
|
+
enabled: true,
|
|
304
|
+
rules: [
|
|
305
|
+
'rateLimit',
|
|
306
|
+
'sqlInjection',
|
|
307
|
+
'xss',
|
|
308
|
+
'knownBadInputs',
|
|
309
|
+
],
|
|
310
|
+
},
|
|
311
|
+
securityGroups: {
|
|
312
|
+
alb: {
|
|
313
|
+
ingress: [
|
|
314
|
+
{ port: 80, protocol: 'tcp', cidr: '0.0.0.0/0' },
|
|
315
|
+
{ port: 443, protocol: 'tcp', cidr: '0.0.0.0/0' },
|
|
316
|
+
],
|
|
317
|
+
},
|
|
318
|
+
app: {
|
|
319
|
+
ingress: [
|
|
320
|
+
{ port: 3000, protocol: 'tcp', source: 'alb-sg' },
|
|
321
|
+
],
|
|
322
|
+
},
|
|
323
|
+
database: {
|
|
324
|
+
ingress: [
|
|
325
|
+
{ port: databaseEngine === 'mysql' ? 3306 : 5432, protocol: 'tcp', source: 'app-sg' },
|
|
326
|
+
],
|
|
327
|
+
},
|
|
328
|
+
...(sessionStore === 'redis' && {
|
|
329
|
+
cache: {
|
|
330
|
+
ingress: [
|
|
331
|
+
{ port: 6379, protocol: 'tcp', source: 'app-sg' },
|
|
332
|
+
],
|
|
333
|
+
},
|
|
334
|
+
}),
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
}
|
|
339
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { CloudConfig } from '@stacksjs/ts-cloud-types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress Preset
|
|
5
|
+
* Perfect for: WordPress sites, blogs, CMS-based sites
|
|
6
|
+
* Includes: EC2 + RDS MySQL + EFS + CloudFront
|
|
7
|
+
*/
|
|
8
|
+
export function createWordPressPreset(options: {
|
|
9
|
+
name: string
|
|
10
|
+
slug: string
|
|
11
|
+
domain: string
|
|
12
|
+
instanceType?: string
|
|
13
|
+
}): Partial<CloudConfig> {
|
|
14
|
+
const {
|
|
15
|
+
name,
|
|
16
|
+
slug,
|
|
17
|
+
domain,
|
|
18
|
+
instanceType = 't3.small',
|
|
19
|
+
} = options
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
project: {
|
|
23
|
+
name,
|
|
24
|
+
slug,
|
|
25
|
+
region: 'us-east-1',
|
|
26
|
+
},
|
|
27
|
+
mode: 'server',
|
|
28
|
+
environments: {
|
|
29
|
+
production: {
|
|
30
|
+
type: 'production',
|
|
31
|
+
domain,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
infrastructure: {
|
|
35
|
+
network: {
|
|
36
|
+
vpc: {
|
|
37
|
+
cidr: '10.0.0.0/16',
|
|
38
|
+
availabilityZones: 2,
|
|
39
|
+
natGateways: 1,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
compute: {
|
|
43
|
+
server: {
|
|
44
|
+
instanceType,
|
|
45
|
+
ami: 'ubuntu-22.04',
|
|
46
|
+
keyPair: `${slug}-key`,
|
|
47
|
+
autoScaling: {
|
|
48
|
+
min: 2,
|
|
49
|
+
max: 6,
|
|
50
|
+
desired: 2,
|
|
51
|
+
targetCPU: 75,
|
|
52
|
+
},
|
|
53
|
+
loadBalancer: {
|
|
54
|
+
type: 'application',
|
|
55
|
+
healthCheck: {
|
|
56
|
+
path: '/wp-admin/install.php',
|
|
57
|
+
interval: 30,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
userData: {
|
|
61
|
+
packages: ['nginx', 'php8.1-fpm', 'php8.1-mysql', 'php8.1-curl', 'php8.1-gd', 'php8.1-mbstring', 'php8.1-xml', 'php8.1-zip'],
|
|
62
|
+
commands: [
|
|
63
|
+
// Download WordPress
|
|
64
|
+
'cd /var/www',
|
|
65
|
+
'wget https://wordpress.org/latest.tar.gz',
|
|
66
|
+
'tar -xzf latest.tar.gz',
|
|
67
|
+
'chown -R www-data:www-data wordpress',
|
|
68
|
+
// Configure Nginx
|
|
69
|
+
'rm /etc/nginx/sites-enabled/default',
|
|
70
|
+
'systemctl restart nginx',
|
|
71
|
+
'systemctl restart php8.1-fpm',
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
// Shared file system for uploads
|
|
77
|
+
fileSystem: {
|
|
78
|
+
uploads: {
|
|
79
|
+
performanceMode: 'generalPurpose',
|
|
80
|
+
throughputMode: 'bursting',
|
|
81
|
+
encrypted: true,
|
|
82
|
+
lifecyclePolicy: {
|
|
83
|
+
transitionToIA: 30, // Move to Infrequent Access after 30 days
|
|
84
|
+
},
|
|
85
|
+
mountPath: '/var/www/wordpress/wp-content/uploads',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
databases: {
|
|
89
|
+
mysql: {
|
|
90
|
+
engine: 'mysql',
|
|
91
|
+
version: '8.0',
|
|
92
|
+
instanceClass: 'db.t3.small',
|
|
93
|
+
allocatedStorage: 50,
|
|
94
|
+
multiAZ: true,
|
|
95
|
+
backupRetentionDays: 7,
|
|
96
|
+
deletionProtection: true,
|
|
97
|
+
databaseName: 'wordpress',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
cache: {
|
|
101
|
+
redis: {
|
|
102
|
+
nodeType: 'cache.t3.micro',
|
|
103
|
+
numCacheNodes: 1,
|
|
104
|
+
engine: 'redis',
|
|
105
|
+
engineVersion: '7.0',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
cdn: {
|
|
109
|
+
enabled: true,
|
|
110
|
+
customDomain: {
|
|
111
|
+
domain,
|
|
112
|
+
certificateArn: 'TO_BE_GENERATED',
|
|
113
|
+
},
|
|
114
|
+
cachePolicy: {
|
|
115
|
+
minTTL: 0,
|
|
116
|
+
defaultTTL: 86400,
|
|
117
|
+
maxTTL: 31536000,
|
|
118
|
+
},
|
|
119
|
+
compress: true,
|
|
120
|
+
origins: [{
|
|
121
|
+
type: 'alb',
|
|
122
|
+
pathPattern: '/wp-content/*',
|
|
123
|
+
}],
|
|
124
|
+
},
|
|
125
|
+
security: {
|
|
126
|
+
certificate: {
|
|
127
|
+
domain,
|
|
128
|
+
subdomains: [`www.${domain}`],
|
|
129
|
+
validationMethod: 'DNS',
|
|
130
|
+
},
|
|
131
|
+
waf: {
|
|
132
|
+
enabled: true,
|
|
133
|
+
rules: ['rateLimit', 'sqlInjection', 'xss', 'wordpressRules'],
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
}
|