aws-samples / image-optimization

Simple, performant and cost efficient solution for optimizing images using Amazon CloudFront, Amazon S3 and AWS Lambda
MIT No Attribution
195 stars 116 forks source link

Deploy on already existed cloudfront distribution #20

Open HieronyM opened 10 months ago

HieronyM commented 10 months ago

actually I already comment on #10, But for visibility I will create another one.

So I want to deploy the solution on already existed Cloudfront distribution. I have a static website host in bucket X, but the web get assets (images, etc) from bucket Y.

To deploy it, what command should I use? cdk deploy -c S3_IMAGE_BUCKET_NAME='bucket-X' or cdk deploy -c S3_IMAGE_BUCKET_NAME='bucket-Y'?

Thank you,

achrafsouk commented 10 months ago

The current solution does not reuse an existing CloudFront distribution. In order to do that, you have to change the CDK code to import an existing CloudFront Distirbution using the following method fromDistributionAttributes

When you do that, bucket Y should be used, as it's the source of your images.

HieronyM commented 10 months ago

@achrafsouk ,

Currently I'm not really familiar with AWS CDK, is there any manual way to change or deploy this solution?

achrafsouk commented 10 months ago

Well of course you can do it in the console.

HieronyM commented 9 months ago

Thanks for the reply @achrafsouk ,

btw I have question regarding my 1st question, let's say I decide with this approach instead for the deployment cdk deploy -c S3_IMAGE_BUCKET_NAME='bucket-Y'

Is there any way the deployment harm the object in Bucket Y? Apparently, I used same S3 bucket to serve Dev and Prod assets.

yangcheng commented 8 months ago

I have a similar question, is it recommended to delete my old distribution and associate custom domains to new distributuion?