Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy on already existed cloudfront distribution #20

Open
HieronyM opened this issue Nov 28, 2023 · 5 comments
Open

Deploy on already existed cloudfront distribution #20

HieronyM opened this issue Nov 28, 2023 · 5 comments

Comments

@HieronyM
Copy link

HieronyM commented Nov 28, 2023

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
Copy link
Contributor

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
Copy link
Author

HieronyM commented Dec 6, 2023

@achrafsouk ,

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

@achrafsouk
Copy link
Contributor

Well of course you can do it in the console.

  • You have to create a new cache behavior in your existing CloudFront distribution dediated for serving images (e.g. /images/* or *.jpg, *.png, etc..)
  • Then mimic the configuration of this cache behavior using the deployed CloudFront distribution in the solution: Associate the CloudFront Function on the viewer event, configure the origin failover with appropriate origins, etc...

@HieronyM
Copy link
Author

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants