@stacksjs/cloud 0.67.0 → 0.68.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.
Files changed (45) hide show
  1. package/dist/ai.d.ts +20 -0
  2. package/dist/cdn.d.ts +271 -0
  3. package/dist/cli.d.ts +12 -0
  4. package/dist/compute.d.ts +221 -0
  5. package/dist/database.d.ts +29 -0
  6. package/dist/deployment.d.ts +60 -0
  7. package/dist/dns.d.ts +34 -0
  8. package/dist/docs.d.ts +34 -0
  9. package/dist/email.d.ts +336 -0
  10. package/dist/file-system.d.ts +32 -0
  11. package/dist/helpers.d.ts +50 -50
  12. package/dist/index.d.ts +2 -2
  13. package/dist/index.js +19 -28
  14. package/dist/jump-box.d.ts +42 -0
  15. package/dist/network.d.ts +29 -0
  16. package/dist/origin-request.d.ts +5 -0
  17. package/dist/permissions.d.ts +25 -0
  18. package/dist/queue.d.ts +144 -0
  19. package/dist/redirects.d.ts +45 -0
  20. package/dist/security.d.ts +149 -0
  21. package/dist/storage.d.ts +189 -0
  22. package/dist/types.d.ts +26 -25
  23. package/package.json +18 -18
  24. package/dist/cloud/ai.d.ts +0 -6
  25. package/dist/cloud/cache.d.ts +0 -0
  26. package/dist/cloud/cdn.d.ts +0 -34
  27. package/dist/cloud/cli.d.ts +0 -6
  28. package/dist/cloud/compute.d.ts +0 -17
  29. package/dist/cloud/dashboard.d.ts +0 -0
  30. package/dist/cloud/database.d.ts +0 -11
  31. package/dist/cloud/deployment.d.ts +0 -17
  32. package/dist/cloud/dns.d.ts +0 -7
  33. package/dist/cloud/docs.d.ts +0 -8
  34. package/dist/cloud/email.d.ts +0 -10
  35. package/dist/cloud/file-system.d.ts +0 -12
  36. package/dist/cloud/index.d.ts +0 -42
  37. package/dist/cloud/jump-box.d.ts +0 -12
  38. package/dist/cloud/network.d.ts +0 -8
  39. package/dist/cloud/permissions.d.ts +0 -6
  40. package/dist/cloud/queue.d.ts +0 -22
  41. package/dist/cloud/redirects.d.ts +0 -8
  42. package/dist/cloud/search-engine.d.ts +0 -0
  43. package/dist/cloud/security.d.ts +0 -15
  44. package/dist/cloud/storage.d.ts +0 -21
  45. package/dist/edge/origin-request.d.ts +0 -1
@@ -0,0 +1,336 @@
1
+ import type { Construct } from 'constructs';
2
+ import type { NestedCloudProps } from '../types';
3
+
4
+ export declare interface EmailStackProps extends NestedCloudProps {
5
+ zone: route53.IHostedZone
6
+ }
7
+ export declare class EmailStack {
8
+ emailBucket: s3.Bucket
9
+
10
+ constructor(scope: Construct, props: EmailStackProps) {
11
+ const bucketPrefix = `${props.slug}-${props.appEnv}`
12
+ this.emailBucket = new s3.Bucket(scope, 'EmailBucket', {
13
+ bucketName: `${bucketPrefix}-email-${props.timestamp}`,
14
+ versioned: true,
15
+ removalPolicy: RemovalPolicy.DESTROY,
16
+ autoDeleteObjects: true,
17
+ encryption: s3.BucketEncryption.S3_MANAGED,
18
+ lifecycleRules: [
19
+ {
20
+ id: '24h',
21
+ enabled: true,
22
+ expiration: Duration.days(1),
23
+ noncurrentVersionExpiration: Duration.days(1),
24
+ prefix: 'today/',
25
+ },
26
+ {
27
+ id: 'Intelligent transition for Inbox',
28
+ enabled: true,
29
+ prefix: 'inbox/',
30
+ transitions: [
31
+ {
32
+ storageClass: s3.StorageClass.INTELLIGENT_TIERING,
33
+ transitionAfter: Duration.days(0),
34
+ },
35
+ ],
36
+ },
37
+ {
38
+ id: 'Intelligent transition for Sent',
39
+ enabled: true,
40
+ prefix: 'sent/',
41
+ transitions: [
42
+ {
43
+ storageClass: s3.StorageClass.INTELLIGENT_TIERING,
44
+ transitionAfter: Duration.days(0),
45
+ },
46
+ ],
47
+ },
48
+ ],
49
+ })
50
+
51
+ Tags.of(this.emailBucket).add('daily-backup', 'true')
52
+
53
+ const sesPrincipal = new iam.ServicePrincipal('ses.amazonaws.com')
54
+ const ruleSetName = `${props.slug}-${props.appEnv}-email-receipt-rule-set`
55
+ const receiptRuleName = `${props.slug}-${props.appEnv}-email-receipt-rule`
56
+
57
+ const ruleSet = new ses.CfnReceiptRuleSet(scope, 'SESReceiptRuleSet', {
58
+ ruleSetName,
59
+ })
60
+
61
+ this.emailBucket.addToResourcePolicy(
62
+ new iam.PolicyStatement({
63
+ sid: 'AllowSESPuts',
64
+ effect: iam.Effect.ALLOW,
65
+ principals: [sesPrincipal],
66
+ actions: ['s3:PutObject'],
67
+ resources: [`${this.emailBucket.bucketArn}/*`],
68
+ conditions: {
69
+ StringEquals: {
70
+ 'aws:SourceAccount': Stack.of(scope).account,
71
+ },
72
+ ArnLike: {
73
+ 'aws:SourceArn': `arn:aws:ses:${Stack.of(scope).region}:${
74
+ Stack.of(scope).account
75
+ }:receipt-rule-set/${ruleSetName}:receipt-rule/${receiptRuleName}`,
76
+ },
77
+ },
78
+ }),
79
+ )
80
+
81
+ const receiptRule = new ses.CfnReceiptRule(scope, 'SESReceiptRule', {
82
+ ruleSetName: ruleSet.ref,
83
+ rule: {
84
+ name: receiptRuleName,
85
+ enabled: true,
86
+ actions: [
87
+ {
88
+ s3Action: {
89
+ bucketName: this.emailBucket.bucketName,
90
+ objectKeyPrefix: 'tmp/email_in/',
91
+ },
92
+ },
93
+ ],
94
+ recipients: config.email.mailboxes || [],
95
+ scanEnabled: config.email.server?.scan || true,
96
+ tlsPolicy: 'Require',
97
+ },
98
+ })
99
+
100
+ receiptRule.node.addDependency(this.emailBucket)
101
+
102
+ const iamGroup = new iam.Group(scope, 'IAMGroup', {
103
+ groupName: `${props.slug}-${props.appEnv}-email-management-s3-group`,
104
+ })
105
+
106
+ const listBucketsPolicyStatement = new iam.PolicyStatement({
107
+ effect: iam.Effect.ALLOW,
108
+ actions: ['s3:ListAllMyBuckets'],
109
+ resources: ['*'],
110
+ })
111
+
112
+ const policyStatement = new iam.PolicyStatement({
113
+ effect: iam.Effect.ALLOW,
114
+ actions: [
115
+ 's3:ListBucket',
116
+ 's3:GetObject',
117
+ 's3:PutObject',
118
+ 's3:DeleteObject',
119
+ 's3:GetObjectAcl',
120
+ 's3:GetObjectVersionAcl',
121
+ 's3:PutObjectAcl',
122
+ 's3:PutObjectVersionAcl',
123
+ ],
124
+ resources: [this.emailBucket.bucketArn, `${this.emailBucket.bucketArn}/*`],
125
+ })
126
+
127
+ const policy = new iam.Policy(scope, 'EmailAccessPolicy', {
128
+ policyName: `${props.slug}-${props.appEnv}-email-management-s3-policy`,
129
+ statements: [policyStatement, listBucketsPolicyStatement],
130
+ })
131
+
132
+ iamGroup.attachInlinePolicy(policy)
133
+
134
+ const sesIdentity = new ses.CfnEmailIdentity(scope, 'DomainIdentity', {
135
+ emailIdentity: props.domain,
136
+
137
+ dkimSigningAttributes: {
138
+ nextSigningKeyLength: 'RSA_2048_BIT',
139
+ },
140
+
141
+ dkimAttributes: {
142
+ signingEnabled: true,
143
+ },
144
+
145
+ mailFromAttributes: {
146
+ behaviorOnMxFailure: 'USE_DEFAULT_VALUE',
147
+ mailFromDomain: `mail.${props.domain}`,
148
+ },
149
+
150
+ feedbackAttributes: {
151
+ emailForwardingEnabled: true,
152
+ },
153
+ })
154
+
155
+ new route53.CfnRecordSet(scope, 'DkimRecord1', {
156
+ hostedZoneName: `${props.zone.zoneName}.`,
157
+ name: sesIdentity.attrDkimDnsTokenName1,
158
+ type: 'CNAME',
159
+ resourceRecords: [sesIdentity.attrDkimDnsTokenValue1],
160
+ ttl: '1800',
161
+ })
162
+
163
+ new route53.CfnRecordSet(scope, 'DkimRecord2', {
164
+ hostedZoneName: `${props.zone.zoneName}.`,
165
+ name: sesIdentity.attrDkimDnsTokenName2,
166
+ type: 'CNAME',
167
+ resourceRecords: [sesIdentity.attrDkimDnsTokenValue2],
168
+ ttl: '1800',
169
+ })
170
+
171
+ new route53.CfnRecordSet(scope, 'DkimRecord3', {
172
+ hostedZoneName: `${props.zone.zoneName}.`,
173
+ name: sesIdentity.attrDkimDnsTokenName3,
174
+ type: 'CNAME',
175
+ resourceRecords: [sesIdentity.attrDkimDnsTokenValue3],
176
+ ttl: '1800',
177
+ })
178
+
179
+ new route53.MxRecord(scope, 'MxRecord', {
180
+ zone: props.zone,
181
+ recordName: 'mail',
182
+ values: [
183
+ {
184
+ priority: 10,
185
+ hostName: 'feedback-smtp.us-east-1.amazonses.com',
186
+ },
187
+ ],
188
+ })
189
+
190
+ new route53.TxtRecord(scope, 'TxtSpfRecord', {
191
+ zone: props.zone,
192
+ recordName: 'mail',
193
+ values: ['v=spf1 include:amazonses.com ~all'],
194
+ })
195
+
196
+ new route53.TxtRecord(scope, 'TxtDmarcRecord', {
197
+ zone: props.zone,
198
+ recordName: '_dmarc',
199
+ values: [`v=DMARC1;p=quarantine;pct=25;rua=mailto:dmarcreports@${props.domain}`],
200
+ })
201
+
202
+ const lambdaEmailOutboundRole = new iam.Role(scope, 'LambdaEmailOutboundRole', {
203
+ roleName: `${props.slug}-${props.appEnv}-email-outbound`,
204
+ assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
205
+ managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaBasicExecutionRole')],
206
+ })
207
+
208
+ const lambdaEmailOutbound = new lambda.Function(scope, 'LambdaEmailOutbound', {
209
+ functionName: `${props.slug}-${props.appEnv}-email-outbound`,
210
+ description: 'Take the JSON and convert it in to an raw email.',
211
+ code: lambda.Code.fromInline('exports.handler = async (event) => {return true;};'),
212
+ handler: 'index.handler',
213
+ memorySize: 256,
214
+ runtime: lambda.Runtime.NODEJS_18_X,
215
+ timeout: Duration.seconds(60),
216
+ environment: {
217
+ BUCKET: this.emailBucket.bucketName,
218
+ },
219
+ role: lambdaEmailOutboundRole,
220
+ })
221
+
222
+ lambdaEmailOutboundRole.addToPolicy(policyStatement)
223
+
224
+ const sesPolicyStatement = new iam.PolicyStatement({
225
+ effect: iam.Effect.ALLOW,
226
+ actions: ['ses:SendRawEmail'],
227
+ resources: ['*'],
228
+ })
229
+
230
+ lambdaEmailOutboundRole.addToPolicy(sesPolicyStatement)
231
+
232
+ const lambdaEmailInboundRole = new iam.Role(scope, 'LambdaEmailInboundRole', {
233
+ roleName: `${props.slug}-${props.appEnv}-email-inbound`,
234
+ assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
235
+ managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaBasicExecutionRole')],
236
+ })
237
+
238
+ const lambdaEmailInbound = new lambda.Function(scope, 'LambdaEmailInbound', {
239
+ functionName: `${props.slug}-${props.appEnv}-email-inbound`,
240
+ description: 'This Lambda organizes all the incoming emails based on the From and To field.',
241
+ code: lambda.Code.fromInline('exports.handler = async (event) => {return true;};'),
242
+ handler: 'index.handler',
243
+ memorySize: 256,
244
+ role: lambdaEmailInboundRole,
245
+ runtime: lambda.Runtime.NODEJS_18_X,
246
+ timeout: Duration.seconds(60),
247
+ environment: {
248
+ BUCKET: this.emailBucket.bucketName,
249
+ },
250
+ })
251
+
252
+ new lambda.CfnPermission(scope, 'S3InboundPermission', {
253
+ action: 'lambda:InvokeFunction',
254
+ functionName: lambdaEmailInbound.functionName,
255
+ principal: 's3.amazonaws.com',
256
+ })
257
+
258
+ const inboundS3PolicyStatement = new iam.PolicyStatement({
259
+ effect: iam.Effect.ALLOW,
260
+ actions: ['s3:*'],
261
+ resources: [this.emailBucket.bucketArn, `${this.emailBucket.bucketArn}/*`],
262
+ })
263
+
264
+ lambdaEmailInboundRole.addToPolicy(inboundS3PolicyStatement)
265
+
266
+ const sesInboundPolicyStatement = new iam.PolicyStatement({
267
+ effect: iam.Effect.ALLOW,
268
+ actions: ['ses:ListIdentities'],
269
+ resources: ['*'],
270
+ })
271
+
272
+ lambdaEmailInboundRole.addToPolicy(sesInboundPolicyStatement)
273
+
274
+ const lambdaEmailConverterRole = new iam.Role(scope, 'LambdaEmailConverterRole', {
275
+ roleName: `${props.slug}-${props.appEnv}-email-converter`,
276
+ assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
277
+ managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaBasicExecutionRole')],
278
+ })
279
+
280
+ const lambdaEmailConverter = new lambda.Function(scope, 'LambdaEmailConverter', {
281
+ functionName: `${props.slug}-${props.appEnv}-email-converter`,
282
+ description: 'This Lambda converts raw emails files in to HTML and text.',
283
+ code: lambda.Code.fromInline(
284
+ 'exports.handler = async (event) => {console.log("hello world email converter");return true;};',
285
+ ),
286
+ handler: 'index.handler',
287
+ memorySize: 256,
288
+ role: lambdaEmailConverterRole,
289
+ runtime: lambda.Runtime.NODEJS_18_X,
290
+ timeout: Duration.seconds(60),
291
+ environment: {
292
+ BUCKET: this.emailBucket.bucketName,
293
+ },
294
+ })
295
+
296
+ const converterS3PolicyStatement = new iam.PolicyStatement({
297
+ effect: iam.Effect.ALLOW,
298
+ actions: ['s3:*'],
299
+ resources: [this.emailBucket.bucketArn, `${this.emailBucket.bucketArn}/*`],
300
+ })
301
+
302
+ new lambda.CfnPermission(scope, 'S3ConverterPermission', {
303
+ action: 'lambda:InvokeFunction',
304
+ functionName: lambdaEmailConverter.functionName,
305
+ principal: 's3.amazonaws.com',
306
+ })
307
+
308
+ lambdaEmailConverterRole.addToPolicy(converterS3PolicyStatement)
309
+
310
+ this.emailBucket.addEventNotification(
311
+ s3.EventType.OBJECT_CREATED_PUT,
312
+ new s3n.LambdaDestination(lambdaEmailInbound),
313
+ { prefix: 'tmp/email_in/' },
314
+ )
315
+ this.emailBucket.addEventNotification(
316
+ s3.EventType.OBJECT_CREATED_PUT,
317
+ new s3n.LambdaDestination(lambdaEmailOutbound),
318
+ { prefix: 'tmp/email_out/json/' },
319
+ )
320
+ this.emailBucket.addEventNotification(
321
+ s3.EventType.OBJECT_CREATED_COPY,
322
+ new s3n.LambdaDestination(lambdaEmailConverter),
323
+ { prefix: 'sent/' },
324
+ )
325
+ this.emailBucket.addEventNotification(
326
+ s3.EventType.OBJECT_CREATED_COPY,
327
+ new s3n.LambdaDestination(lambdaEmailConverter),
328
+ { prefix: 'inbox/' },
329
+ )
330
+ this.emailBucket.addEventNotification(
331
+ s3.EventType.OBJECT_CREATED_COPY,
332
+ new s3n.LambdaDestination(lambdaEmailConverter),
333
+ { prefix: 'today/' },
334
+ )
335
+ }
336
+ }
@@ -0,0 +1,32 @@
1
+ import type { Construct } from 'constructs';
2
+ import type { NestedCloudProps } from '../types';
3
+
4
+ export declare interface FileSystemStackProps extends NestedCloudProps {
5
+ vpc: ec2.Vpc
6
+ }
7
+ export declare class FileSystemStack {
8
+ fileSystem: efs.FileSystem
9
+ accessPoint: efs.AccessPoint
10
+
11
+ constructor(scope: Construct, props: FileSystemStackProps) {
12
+ this.fileSystem = new efs.FileSystem(scope, 'FileSystem', {
13
+ fileSystemName: `${props.slug}-${props.appEnv}-efs`,
14
+ vpc: props.vpc,
15
+ removalPolicy: RemovalPolicy.DESTROY,
16
+ lifecyclePolicy: efs.LifecyclePolicy.AFTER_7_DAYS,
17
+ performanceMode: efs.PerformanceMode.GENERAL_PURPOSE,
18
+ throughputMode: efs.ThroughputMode.BURSTING,
19
+ enableAutomaticBackups: true,
20
+ encrypted: true,
21
+ })
22
+
23
+ this.accessPoint = new efs.AccessPoint(scope, 'FileSystemAccessPoint', {
24
+ fileSystem: this.fileSystem,
25
+ path: '/',
26
+ posixUser: {
27
+ uid: '1000',
28
+ gid: '1000',
29
+ },
30
+ })
31
+ }
32
+ }
package/dist/helpers.d.ts CHANGED
@@ -1,54 +1,54 @@
1
- import type { CountryCode, RegisterDomainCommandOutput } from "@aws-sdk/client-route-53-domains";
2
- import { _InstanceType as InstanceType } from "@aws-sdk/client-ec2";
3
- import { ContactType } from "@aws-sdk/client-route-53-domains";
4
- import { type Result } from "@stacksjs/error-handling";
5
- export { InstanceType };
1
+ import type { CountryCode, RegisterDomainCommandOutput } from '@aws-sdk/client-route-53-domains';
2
+ import type { Result } from '@stacksjs/error-handling';
3
+
4
+ export { InstanceType }
5
+ declare const appEnv: unknown;
6
6
  export declare function getSecurityGroupId(securityGroupName: string): Promise<Result<string | undefined, string>>;
7
- export interface PurchaseOptions {
8
- domain: string;
9
- years: number;
10
- privacy: boolean;
11
- autoRenew: boolean;
12
- adminFirstName: string;
13
- adminLastName: string;
14
- adminOrganization: string;
15
- adminAddressLine1: string;
16
- adminAddressLine2: string;
17
- adminCity: string;
18
- adminState: string;
19
- adminCountry: CountryCode;
20
- adminZip: string;
21
- adminPhone: string;
22
- adminEmail: string;
23
- techFirstName: string;
24
- techLastName: string;
25
- techOrganization: string;
26
- techAddressLine1: string;
27
- techAddressLine2: string;
28
- techCity: string;
29
- techState: string;
30
- techCountry: CountryCode;
31
- techZip: string;
32
- techPhone: string;
33
- techEmail: string;
34
- registrantFirstName: string;
35
- registrantLastName: string;
36
- registrantOrganization: string;
37
- registrantAddressLine1: string;
38
- registrantAddressLine2: string;
39
- registrantCity: string;
40
- registrantState: string;
41
- registrantCountry: CountryCode;
42
- registrantZip: string;
43
- registrantPhone: string;
44
- registrantEmail: string;
45
- privacyAdmin: boolean;
46
- privacyTech: boolean;
47
- privacyRegistrant: boolean;
48
- contactType: ContactType;
49
- verbose: boolean;
7
+ export declare interface PurchaseOptions {
8
+ domain: string
9
+ years: number
10
+ privacy: boolean
11
+ autoRenew: boolean
12
+ adminFirstName: string
13
+ adminLastName: string
14
+ adminOrganization: string
15
+ adminAddressLine1: string
16
+ adminAddressLine2: string
17
+ adminCity: string
18
+ adminState: string
19
+ adminCountry: CountryCode
20
+ adminZip: string
21
+ adminPhone: string
22
+ adminEmail: string
23
+ techFirstName: string
24
+ techLastName: string
25
+ techOrganization: string
26
+ techAddressLine1: string
27
+ techAddressLine2: string
28
+ techCity: string
29
+ techState: string
30
+ techCountry: CountryCode
31
+ techZip: string
32
+ techPhone: string
33
+ techEmail: string
34
+ registrantFirstName: string
35
+ registrantLastName: string
36
+ registrantOrganization: string
37
+ registrantAddressLine1: string
38
+ registrantAddressLine2: string
39
+ registrantCity: string
40
+ registrantState: string
41
+ registrantCountry: CountryCode
42
+ registrantZip: string
43
+ registrantPhone: string
44
+ registrantEmail: string
45
+ privacyAdmin: boolean
46
+ privacyTech: boolean
47
+ privacyRegistrant: boolean
48
+ contactType: ContactType
49
+ verbose: boolean
50
50
  }
51
- export declare function purchaseDomain(domain: string, options: PurchaseOptions): Result<Promise<RegisterDomainCommandOutput>, Error>;
51
+ export declare function purchaseDomain(domain: string, options: PurchaseOptions,): Result<Promise<RegisterDomainCommandOutput>, Error>;
52
52
  export declare function getJumpBoxInstanceId(name?: string): Promise<string | undefined>;
53
53
  export declare function deleteEc2Instance(id: string, stackName?: string): Promise<Result<string, string>>;
54
54
  export declare function deleteJumpBox(stackName?: string): Promise<Result<string, string>>;
@@ -68,4 +68,4 @@ export declare function getSecurityGroupFromInstanceId(instanceId: string): Prom
68
68
  export declare function isFirstDeployment(): Promise<boolean>;
69
69
  export declare function isFailedState(): Promise<boolean>;
70
70
  export declare function getOrCreateTimestamp(): Promise<string>;
71
- export declare function getCloudFrontDistributionId(): Promise<string>;
71
+ export declare function getCloudFrontDistributionId(): Promise<string>;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./cloud";
2
- export * from "./helpers";
1
+ export * from './cloud'
2
+ export * from './helpers'