1
1
import { app } from '@stacksjs/config'
2
- import { publicPath } from '@stacksjs/path'
2
+ // import { publicPath } from '@stacksjs/path'
3
3
import {
4
4
Duration ,
5
5
Fn ,
@@ -35,20 +35,22 @@ export class StacksCloud extends Stack {
35
35
validation : acm . CertificateValidation . fromDns ( zone ) , // Use DNS validation
36
36
} )
37
37
38
- const websiteBucket = new s3 . Bucket ( this , 'WebsiteBucket' , {
38
+ const webBucket = new s3 . Bucket ( this , 'WebBucket' , {
39
+ bucketName : `stacksjs.com-${ app . env } -web` ,
39
40
versioned : true ,
40
41
removalPolicy : RemovalPolicy . DESTROY ,
41
42
autoDeleteObjects : true ,
42
43
} )
43
44
44
45
// Create an S3 bucket for CloudFront access logs
45
- const logBucket = new s3 . Bucket ( this , 'LogBucket' , {
46
+ const logsBucket = new s3 . Bucket ( this , 'LogBucket' , {
47
+ bucketName : `stacksjs.com-${ app . env } -logs` ,
46
48
removalPolicy : RemovalPolicy . DESTROY ,
47
49
autoDeleteObjects : true ,
48
50
objectOwnership : s3 . ObjectOwnership . BUCKET_OWNER_PREFERRED ,
49
51
} )
50
52
51
- logBucket . addLifecycleRule ( {
53
+ logsBucket . addLifecycleRule ( {
52
54
enabled : true ,
53
55
expiration : Duration . days ( 30 ) ,
54
56
id : 'rule' ,
@@ -93,7 +95,7 @@ export class StacksCloud extends Stack {
93
95
certificate,
94
96
originShieldEnabled : true ,
95
97
enableLogging : true ,
96
- logBucket,
98
+ logBucket : logsBucket ,
97
99
httpVersion : cloudfront . HttpVersion . HTTP2_AND_3 ,
98
100
priceClass : cloudfront . PriceClass . PRICE_CLASS_ALL ,
99
101
enabled : true ,
@@ -102,7 +104,7 @@ export class StacksCloud extends Stack {
102
104
enableIpv6 : true ,
103
105
104
106
defaultBehavior : {
105
- origin : new origins . S3Origin ( websiteBucket , {
107
+ origin : new origins . S3Origin ( webBucket , {
106
108
originAccessIdentity,
107
109
} ) ,
108
110
compress : true ,
@@ -149,24 +151,31 @@ export class StacksCloud extends Stack {
149
151
150
152
// eslint-disable-next-line no-new
151
153
new s3deploy . BucketDeployment ( this , 'DeployWebsite' , {
152
- sources : [ s3deploy . Source . asset ( publicPath ( ) ) ] ,
153
- destinationBucket : websiteBucket ,
154
+ sources : [ s3deploy . Source . asset ( '../../../storage/public' ) ] ,
155
+ destinationBucket : webBucket ,
154
156
distribution,
155
157
distributionPaths : [ '/*' ] ,
156
158
} )
157
159
158
160
// Prints out the web endpoint to the terminal
159
161
// eslint-disable-next-line no-new
160
162
new Output ( this , 'AppUrl' , {
161
- value : distribution . domainName ,
163
+ value : `https://stacksjs.com` ,
162
164
description : 'The URL of the deployed application' ,
163
165
} )
164
166
165
- // Output the nameservers of the hosted zone
167
+ // Prints out the web endpoint to the terminal
166
168
// eslint-disable-next-line no-new
167
- new Output ( this , 'Nameservers ' , {
168
- value : Fn . join ( ', ' , zone . hostedZoneNameServers ) ,
169
- description : 'Nameservers for the application domain ' ,
169
+ new Output ( this , 'VanityUrl ' , {
170
+ value : distribution . domainName ,
171
+ description : 'The vanity URL of the deployed application ' ,
170
172
} )
173
+
174
+ // Output the nameservers of the hosted zone
175
+ // eslint-disable-next-line no-new
176
+ // new Output(this, 'Nameservers', {
177
+ // value: Fn.join(', ', zone.hostedZoneNameServers),
178
+ // description: 'Nameservers for the application domain',
179
+ // })
171
180
}
172
181
}
0 commit comments