@@ -19,19 +19,17 @@ export interface FrontendStackStackProps extends NestedStackProps {
1919 readonly customHeaderName : string ;
2020 readonly customHeaderValue : string ;
2121 readonly tilesApi : apigw . RestApi ;
22- readonly geotiffBucketVpcEndpointId : string ;
2322 readonly solaraSGs : string [ ] ;
2423 readonly solaraOriginLBDnsName : string ;
2524 readonly envName : string ;
25+ readonly geoTiffBucket : s3 . IBucket ;
26+ readonly geoTiffOriginAccessIdentity : cf . OriginAccessIdentity ;
2627}
2728
2829export class FrontendStack extends NestedStack {
2930
3031 public readonly staticContentBucket : s3 . Bucket ;
31- public readonly geoTiffBucket : s3 . Bucket ;
3232 public readonly frontendUrl : string ;
33- public readonly geotiffUrl : string ;
34- public readonly geotiffBucketName : string ;
3533 public readonly cloudFrontDistribution : cf . Distribution ;
3634 public readonly authorizerFunction : cf . experimental . EdgeFunction ;
3735
@@ -55,38 +53,6 @@ export class FrontendStack extends NestedStack {
5553 const staticContentOriginAccessIdentity = new cf . OriginAccessIdentity ( this , 'StaticContentOriginAccessIdentity' ) ;
5654 this . staticContentBucket . grantRead ( staticContentOriginAccessIdentity ) ;
5755
58- this . geoTiffBucket = new s3 . Bucket ( this , 'GeoTiffBucket' , {
59- bucketName : `aws-geofm-geotiff-bucket-${ this . account } -${ this . region } -${ props . envName } ` ,
60- blockPublicAccess : {
61- blockPublicAcls : true ,
62- restrictPublicBuckets : true ,
63- blockPublicPolicy : true ,
64- ignorePublicAcls : true
65- } ,
66- removalPolicy : RemovalPolicy . DESTROY ,
67- autoDeleteObjects : true ,
68- accessControl : s3 . BucketAccessControl . PRIVATE ,
69- enforceSSL : true ,
70- } ) ;
71-
72- this . geotiffUrl = this . geoTiffBucket . urlForObject ( ) ;
73- this . geotiffBucketName = this . geoTiffBucket . bucketName ;
74-
75- this . geoTiffBucket . addToResourcePolicy ( new iam . PolicyStatement ( {
76- actions : [ 's3:GetObject' ] ,
77- principals : [ new iam . AccountPrincipal ( this . account ) ] ,
78- resources : [ this . geoTiffBucket . arnForObjects ( '*' ) ] ,
79- conditions : {
80- StringEquals : {
81- "aws:sourceVpce" : `${ props . geotiffBucketVpcEndpointId } `
82- }
83- }
84- } ) ) ;
85-
86- // Allow direct access to GeoTiff images from the bucket using OAI
87- const geoTiffOriginAccessIdentity = new cf . OriginAccessIdentity ( this , 'GeoTiffOriginAccessIdentity' ) ;
88- this . geoTiffBucket . grantRead ( geoTiffOriginAccessIdentity ) ;
89-
9056 this . authorizerFunction = new cloudfront . experimental . EdgeFunction ( this , 'CloudFrontAuthorizer' , {
9157 runtime : lambda . Runtime . NODEJS_18_X ,
9258 handler : 'index.handler' ,
@@ -188,8 +154,8 @@ export class FrontendStack extends NestedStack {
188154 } ) ;
189155
190156 // The Geotiff images are located in geotiff/*.tif
191- this . cloudFrontDistribution . addBehavior ( 'geotiff/*' , new cfo . S3Origin ( this . geoTiffBucket , {
192- originAccessIdentity : geoTiffOriginAccessIdentity
157+ this . cloudFrontDistribution . addBehavior ( 'geotiff/*' , new cfo . S3Origin ( props . geoTiffBucket , {
158+ originAccessIdentity : props . geoTiffOriginAccessIdentity
193159 } ) ,
194160 {
195161 edgeLambdas : edgeLambda ,
0 commit comments