@stacksjs/ts-cloud-aws-types 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 ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2024 Open Web Foundation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,321 @@
1
+ <p align="center"><img src=".github/art/cover.jpg" alt="Social Card of this repo"></p>
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![GitHub Actions][github-actions-src]][github-actions-href]
5
+ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
6
+ <!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
7
+ <!-- [![Codecov][codecov-src]][codecov-href] -->
8
+
9
+ # ts-cloud
10
+
11
+ > Zero-dependency AWS infrastructure as TypeScript. Deploy production-ready cloud infrastructure without AWS SDK or CLI.
12
+
13
+ ## Overview
14
+
15
+ ts-cloud is a modern infrastructure-as-code framework that lets you define AWS infrastructure using TypeScript configuration files. Unlike AWS CDK or Terraform, ts-cloud:
16
+
17
+ - **Zero AWS Dependencies** - No AWS SDK, no AWS CLI. Direct AWS API calls only.
18
+ - **Type-Safe Configuration** - Full TypeScript types for all AWS resources
19
+ - **Production-Ready Presets** - 13 battle-tested infrastructure templates
20
+ - **Bun-Powered** - Lightning-fast builds and deployments
21
+ - **CloudFormation Native** - Generate clean, reviewable CloudFormation templates
22
+
23
+ ## Features
24
+
25
+ ### 🚀 Configuration Presets
26
+
27
+ Skip the boilerplate with production-ready presets for common architectures:
28
+
29
+ - **Static Sites** - S3 + CloudFront for SPAs and static websites
30
+ - **Node.js Servers** - EC2 + ALB + RDS + Redis for traditional apps
31
+ - **Serverless Apps** - ECS Fargate + ALB + DynamoDB for scalable services
32
+ - **Full-Stack Apps** - Complete frontend + backend + database stack
33
+ - **API Backends** - API Gateway + Lambda + DynamoDB for serverless APIs
34
+ - **WordPress** - Optimized WordPress hosting with RDS + EFS + CloudFront
35
+ - **JAMstack** - Modern static sites with Lambda@Edge for SSR
36
+ - **Microservices** - Multi-service architecture with service discovery
37
+ - **Real-time Apps** - WebSocket API + Lambda + DynamoDB Streams
38
+ - **Data Pipelines** - Kinesis + Lambda + S3 + Athena + Glue for ETL
39
+ - **ML APIs** - SageMaker + API Gateway for ML inference
40
+ - **Traditional Web Apps** - Session-based apps with EFS + Redis + ALB
41
+
42
+ ### 🛠️ Infrastructure Builders
43
+
44
+ Complete CloudFormation template builders for:
45
+
46
+ - **Network** - VPC, subnets, NAT gateways, routing, security groups
47
+ - **Storage** - S3 buckets with versioning, encryption, lifecycle rules, EFS
48
+ - **Compute** - EC2 Auto Scaling, ECS Fargate, Lambda functions
49
+ - **Database** - RDS (PostgreSQL/MySQL), DynamoDB with streams and GSIs
50
+ - **Cache** - ElastiCache Redis/Memcached with replication
51
+ - **CDN** - CloudFront distributions with custom domains and Lambda@Edge
52
+ - **API Gateway** - HTTP, REST, and WebSocket APIs
53
+ - **Queue** - SQS queues with dead letter queues
54
+ - **Messaging** - SNS topics and subscriptions
55
+ - **Monitoring** - CloudWatch dashboards, alarms, and log groups
56
+ - **Security** - ACM certificates, WAF rules, security groups
57
+
58
+ ### ☁️ Direct AWS Integration
59
+
60
+ No SDK, no CLI - pure AWS Signature V4 API calls:
61
+
62
+ - **CloudFormation** - CreateStack, UpdateStack, DeleteStack, DescribeStacks
63
+ - **S3** - PutObject, multipart upload, sync directory
64
+ - **CloudFront** - Cache invalidations with wait support
65
+ - **Credentials** - Resolve from env vars, ~/.aws/credentials, or IAM roles
66
+
67
+ ## Quick Start
68
+
69
+ ### Installation
70
+
71
+ ```bash
72
+ bun add ts-cloud
73
+ ```
74
+
75
+ ### Your First Deployment
76
+
77
+ Create a `cloud.config.ts`:
78
+
79
+ ```typescript
80
+ import { createStaticSitePreset } from 'ts-cloud/presets'
81
+
82
+ export default createStaticSitePreset({
83
+ name: 'My Website',
84
+ slug: 'my-website',
85
+ domain: 'example.com',
86
+ })
87
+ ```
88
+
89
+ Deploy:
90
+
91
+ ```bash
92
+ bun run cloud deploy
93
+ ```
94
+
95
+ That's it! You now have:
96
+
97
+ - ✅ S3 bucket with static website hosting
98
+ - ✅ CloudFront CDN with HTTPS
99
+ - ✅ Route53 DNS configuration
100
+ - ✅ ACM SSL certificate
101
+
102
+ ### More Examples
103
+
104
+ #### Full-Stack Application
105
+
106
+ ```typescript
107
+ import { createFullStackAppPreset } from 'ts-cloud/presets'
108
+
109
+ export default createFullStackAppPreset({
110
+ name: 'My App',
111
+ slug: 'my-app',
112
+ domain: 'app.example.com',
113
+ apiSubdomain: 'api.example.com',
114
+ })
115
+ ```
116
+
117
+ Includes:
118
+
119
+ - Frontend: S3 + CloudFront
120
+ - Backend: ECS Fargate with auto-scaling
121
+ - Database: PostgreSQL RDS with Multi-AZ
122
+ - Cache: Redis ElastiCache
123
+ - Queue: SQS for background jobs
124
+
125
+ #### Serverless API
126
+
127
+ ```typescript
128
+ import { createApiBackendPreset } from 'ts-cloud/presets'
129
+
130
+ export default createApiBackendPreset({
131
+ name: 'My API',
132
+ slug: 'my-api',
133
+ domain: 'api.example.com',
134
+ })
135
+ ```
136
+
137
+ Includes:
138
+
139
+ - API Gateway HTTP API
140
+ - Lambda functions with auto-scaling
141
+ - DynamoDB tables with on-demand billing
142
+ - CloudWatch monitoring and alarms
143
+
144
+ ## Configuration
145
+
146
+ ### Extending Presets
147
+
148
+ You can extend any preset with custom configuration:
149
+
150
+ ```typescript
151
+ import { createNodeJsServerPreset, extendPreset } from 'ts-cloud/presets'
152
+
153
+ export default extendPreset(
154
+ createNodeJsServerPreset({
155
+ name: 'My App',
156
+ slug: 'my-app',
157
+ }),
158
+ {
159
+ infrastructure: {
160
+ compute: {
161
+ server: {
162
+ instanceType: 't3.large', // Upgrade instance type
163
+ autoScaling: {
164
+ max: 20, // Increase max instances
165
+ },
166
+ },
167
+ },
168
+ },
169
+ }
170
+ )
171
+ ```
172
+
173
+ ### Composing Presets
174
+
175
+ Combine multiple presets:
176
+
177
+ ```typescript
178
+ import { composePresets, createStaticSitePreset, createApiBackendPreset } from 'ts-cloud/presets'
179
+
180
+ export default composePresets(
181
+ createStaticSitePreset({ name: 'Frontend', slug: 'frontend', domain: 'example.com' }),
182
+ createApiBackendPreset({ name: 'Backend', slug: 'backend' }),
183
+ {
184
+ // Custom overrides
185
+ infrastructure: {
186
+ monitoring: {
187
+ alarms: [{ metric: 'Errors', threshold: 10 }],
188
+ },
189
+ },
190
+ }
191
+ )
192
+ ```
193
+
194
+ ## Advanced Usage
195
+
196
+ ### Custom CloudFormation
197
+
198
+ Generate templates programmatically:
199
+
200
+ ```typescript
201
+ import { CloudFormationBuilder } from 'ts-cloud/cloudformation'
202
+
203
+ const builder = new CloudFormationBuilder(config)
204
+ const template = builder.build()
205
+
206
+ console.log(JSON.stringify(template, null, 2))
207
+ ```
208
+
209
+ ### Direct AWS API Calls
210
+
211
+ Use the AWS clients directly:
212
+
213
+ ```typescript
214
+ import { CloudFormationClient, S3Client, CloudFrontClient } from 'ts-cloud/aws'
215
+
216
+ // CloudFormation
217
+ const cfn = new CloudFormationClient('us-east-1')
218
+ await cfn.createStack({
219
+ stackName: 'my-stack',
220
+ templateBody: JSON.stringify(template),
221
+ })
222
+
223
+ // S3
224
+ const s3 = new S3Client('us-east-1')
225
+ await s3.putObject({
226
+ bucket: 'my-bucket',
227
+ key: 'file.txt',
228
+ body: 'Hello World',
229
+ })
230
+
231
+ // CloudFront
232
+ const cloudfront = new CloudFrontClient()
233
+ await cloudfront.createInvalidation({
234
+ distributionId: 'E1234567890',
235
+ paths: ['/*'],
236
+ })
237
+ ```
238
+
239
+ ## Development
240
+
241
+ ```bash
242
+ # Install dependencies
243
+ bun install
244
+
245
+ # Run tests
246
+ bun test
247
+
248
+ # Build
249
+ bun run build
250
+
251
+ # Type check
252
+ bun run typecheck
253
+ ```
254
+
255
+ ## Architecture
256
+
257
+ ### How It Works
258
+
259
+ 1. **Configuration** - Define infrastructure in TypeScript
260
+ 2. **CloudFormation Generation** - Convert config to CloudFormation templates
261
+ 3. **AWS API Calls** - Direct HTTPS calls to AWS CloudFormation API
262
+ 4. **Deployment** - Create/update stacks with change sets
263
+ 5. **Monitoring** - Track deployment progress with real-time events
264
+
265
+ ### No Dependencies
266
+
267
+ ts-cloud uses **zero external dependencies** for AWS operations:
268
+
269
+ - **AWS Signature V4** - Manual request signing for authentication
270
+ - **Direct HTTPS** - Native `fetch()` for API calls
271
+ - **Credentials** - Parse ~/.aws/credentials without SDK
272
+ - **CloudFormation** - XML/JSON parsing for responses
273
+
274
+ This means:
275
+
276
+ - ⚡ Faster startup and execution
277
+ - 📦 Smaller bundle size
278
+ - 🔒 Better security (no supply chain attacks)
279
+ - 🎯 Full control over AWS interactions
280
+
281
+ ## Contributing
282
+
283
+ Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
284
+
285
+ ## Community
286
+
287
+ For help, discussion about best practices, or any other conversation that would benefit from being searchable:
288
+
289
+ [Discussions on GitHub](https://github.com/stacksjs/ts-cloud/discussions)
290
+
291
+ For casual chit-chat with others using this package:
292
+
293
+ [Join the Stacks Discord Server](https://discord.gg/stacksjs)
294
+
295
+ ## Postcardware
296
+
297
+ "Software that is free, but hopes for a postcard." We love receiving postcards from around the world showing where Stacks is being used! We showcase them on our website too.
298
+
299
+ Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎
300
+
301
+ ## Sponsors
302
+
303
+ We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
304
+
305
+ - [JetBrains](https://www.jetbrains.com/)
306
+ - [The Solana Foundation](https://solana.com/)
307
+
308
+ ## License
309
+
310
+ The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.
311
+
312
+ Made with 💙
313
+
314
+ <!-- Badges -->
315
+ [npm-version-src]: https://img.shields.io/npm/v/ts-cloud?style=flat-square
316
+ [npm-version-href]: https://npmjs.com/package/ts-cloud
317
+ [github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/ts-cloud/ci.yml?style=flat-square&branch=main
318
+ [github-actions-href]: https://github.com/stacksjs/ts-cloud/actions?query=workflow%3Aci
319
+
320
+ <!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/ts-cloud/main?style=flat-square
321
+ [codecov-href]: https://codecov.io/gh/stacksjs/ts-cloud -->
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@stacksjs/ts-cloud-aws-types",
3
+ "version": "0.1.1",
4
+ "type": "module",
5
+ "description": "AWS CloudFormation resource type definitions (without AWS SDK)",
6
+ "author": "Chris Breuer <chris@stacksjs.com>",
7
+ "license": "MIT",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "main": "./dist/index.js",
15
+ "module": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "bun build src/index.ts --outdir dist --target bun",
22
+ "typecheck": "tsc --noEmit"
23
+ },
24
+ "devDependencies": {
25
+ "typescript": "^5.9.3"
26
+ }
27
+ }
package/src/acm.ts ADDED
@@ -0,0 +1,20 @@
1
+ import type { CloudFormationResource } from './index'
2
+
3
+ export interface ACMCertificate extends CloudFormationResource {
4
+ Type: 'AWS::CertificateManager::Certificate'
5
+ Properties: {
6
+ DomainName: string
7
+ SubjectAlternativeNames?: string[]
8
+ DomainValidationOptions?: Array<{
9
+ DomainName: string
10
+ HostedZoneId?: string
11
+ ValidationDomain?: string
12
+ }>
13
+ ValidationMethod?: 'DNS' | 'EMAIL'
14
+ CertificateTransparencyLoggingPreference?: 'ENABLED' | 'DISABLED'
15
+ Tags?: Array<{
16
+ Key: string
17
+ Value: string
18
+ }>
19
+ }
20
+ }
package/src/alb.ts ADDED
@@ -0,0 +1,73 @@
1
+ import type { CloudFormationResource } from './index'
2
+
3
+ export interface ApplicationLoadBalancer extends CloudFormationResource {
4
+ Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
5
+ Properties: {
6
+ Name?: string
7
+ Scheme?: 'internet-facing' | 'internal'
8
+ Type?: 'application' | 'network' | 'gateway'
9
+ IpAddressType?: 'ipv4' | 'dualstack'
10
+ Subnets?: string[]
11
+ SecurityGroups?: string[]
12
+ Tags?: Array<{
13
+ Key: string
14
+ Value: string
15
+ }>
16
+ }
17
+ }
18
+
19
+ export interface TargetGroup extends CloudFormationResource {
20
+ Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
21
+ Properties: {
22
+ Name?: string
23
+ Port: number
24
+ Protocol: 'HTTP' | 'HTTPS' | 'TCP' | 'TLS' | 'UDP' | 'TCP_UDP'
25
+ VpcId: string | { Ref: string }
26
+ TargetType?: 'instance' | 'ip' | 'lambda' | 'alb'
27
+ HealthCheckEnabled?: boolean
28
+ HealthCheckProtocol?: 'HTTP' | 'HTTPS' | 'TCP' | 'TLS' | 'UDP' | 'TCP_UDP'
29
+ HealthCheckPath?: string
30
+ HealthCheckIntervalSeconds?: number
31
+ HealthCheckTimeoutSeconds?: number
32
+ HealthyThresholdCount?: number
33
+ UnhealthyThresholdCount?: number
34
+ Matcher?: {
35
+ HttpCode?: string
36
+ GrpcCode?: string
37
+ }
38
+ Tags?: Array<{
39
+ Key: string
40
+ Value: string
41
+ }>
42
+ }
43
+ }
44
+
45
+ export interface Listener extends CloudFormationResource {
46
+ Type: 'AWS::ElasticLoadBalancingV2::Listener'
47
+ Properties: {
48
+ LoadBalancerArn: string | { Ref: string }
49
+ Port: number
50
+ Protocol: 'HTTP' | 'HTTPS' | 'TCP' | 'TLS' | 'UDP' | 'TCP_UDP'
51
+ Certificates?: Array<{
52
+ CertificateArn: string
53
+ }>
54
+ SslPolicy?: string
55
+ DefaultActions: Array<{
56
+ Type: 'forward' | 'redirect' | 'fixed-response' | 'authenticate-cognito' | 'authenticate-oidc'
57
+ TargetGroupArn?: string | { Ref: string }
58
+ RedirectConfig?: {
59
+ Protocol?: string
60
+ Port?: string
61
+ Host?: string
62
+ Path?: string
63
+ Query?: string
64
+ StatusCode: 'HTTP_301' | 'HTTP_302'
65
+ }
66
+ FixedResponseConfig?: {
67
+ StatusCode: string
68
+ ContentType?: string
69
+ MessageBody?: string
70
+ }
71
+ }>
72
+ }
73
+ }
@@ -0,0 +1,85 @@
1
+ import type { CloudFormationResource } from './index'
2
+
3
+ export interface ApiGatewayRestApi extends CloudFormationResource {
4
+ Type: 'AWS::ApiGateway::RestApi'
5
+ Properties: {
6
+ Name: string
7
+ Description?: string
8
+ EndpointConfiguration?: {
9
+ Types: ('EDGE' | 'REGIONAL' | 'PRIVATE')[]
10
+ }
11
+ Policy?: unknown
12
+ BinaryMediaTypes?: string[]
13
+ MinimumCompressionSize?: number
14
+ Tags?: Array<{
15
+ Key: string
16
+ Value: string
17
+ }>
18
+ }
19
+ }
20
+
21
+ export interface ApiGatewayHttpApi extends CloudFormationResource {
22
+ Type: 'AWS::ApiGatewayV2::Api'
23
+ Properties: {
24
+ Name: string
25
+ Description?: string
26
+ ProtocolType: 'HTTP' | 'WEBSOCKET'
27
+ CorsConfiguration?: {
28
+ AllowOrigins?: string[]
29
+ AllowMethods?: string[]
30
+ AllowHeaders?: string[]
31
+ ExposeHeaders?: string[]
32
+ MaxAge?: number
33
+ AllowCredentials?: boolean
34
+ }
35
+ Tags?: Record<string, string>
36
+ }
37
+ }
38
+
39
+ export interface ApiGatewayStage extends CloudFormationResource {
40
+ Type: 'AWS::ApiGateway::Stage'
41
+ Properties: {
42
+ StageName: string
43
+ RestApiId: string | { Ref: string }
44
+ DeploymentId: string | { Ref: string }
45
+ Description?: string
46
+ CacheClusterEnabled?: boolean
47
+ CacheClusterSize?: string
48
+ Variables?: Record<string, string>
49
+ MethodSettings?: Array<{
50
+ HttpMethod: string
51
+ ResourcePath: string
52
+ CachingEnabled?: boolean
53
+ CacheTtlInSeconds?: number
54
+ ThrottlingBurstLimit?: number
55
+ ThrottlingRateLimit?: number
56
+ }>
57
+ Tags?: Array<{
58
+ Key: string
59
+ Value: string
60
+ }>
61
+ }
62
+ }
63
+
64
+ export interface ApiGatewayDeployment extends CloudFormationResource {
65
+ Type: 'AWS::ApiGateway::Deployment'
66
+ Properties: {
67
+ RestApiId: string | { Ref: string }
68
+ Description?: string
69
+ StageName?: string
70
+ }
71
+ }
72
+
73
+ export interface ApiGatewayAuthorizer extends CloudFormationResource {
74
+ Type: 'AWS::ApiGateway::Authorizer'
75
+ Properties: {
76
+ Name: string
77
+ Type: 'TOKEN' | 'REQUEST' | 'COGNITO_USER_POOLS'
78
+ RestApiId: string | { Ref: string }
79
+ AuthorizerUri?: string
80
+ AuthorizerCredentials?: string
81
+ IdentitySource?: string
82
+ ProviderARNs?: string[]
83
+ AuthorizerResultTtlInSeconds?: number
84
+ }
85
+ }