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

Website bucket domain name issue #178

Open
robvadai opened this issue Jul 24, 2021 · 2 comments
Open

Website bucket domain name issue #178

robvadai opened this issue Jul 24, 2021 · 2 comments
Labels
bug 🐛 An issue with the system

Comments

@robvadai
Copy link

Describe the Bug

  1. Created a bucket without a website, to then realise I need a website bucket to load index.html for 'folder' like URLs ending with /. CloudFront should use the website origin that will do the web serving.
  2. All I did was, added website_enabled = true to my config.
  3. Got this error:
 321: resource "aws_cloudfront_distribution" "default" {

The argument "origin.0.domain_name" is required, but no definition was found.

I think it's because of some circular dependency.

By setting website_enabled = true:

  1. This variable will evaluate to true: https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn/blob/master/main.tf#L8
  2. This line will look for key new: https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn/blob/master/main.tf#L30
  3. This line will look for bucket origin that is NOT yet created: https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn/blob/master/main.tf#L25

Expected Behavior

Origin bucket deleted, new bucket with website name created with no error.
Everything else (CloudFront distribution, SSL certificate) should stay intact.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Add website_enabled = true
  2. Run terraform plan
  3. See error

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • OS: macOS 10.15.7
  • Terraform version: v0.13.5
@robvadai robvadai added the bug 🐛 An issue with the system label Jul 24, 2021
@robvadai
Copy link
Author

By destroying the whole module (all resources created by this module) using the terraform destroy command and re-creating everything from scratch worked.

But it's not ideal, we should avoid the need of using terraform destroy.

@reda-sj
Copy link

reda-sj commented Nov 18, 2021

got that error since I created the bucket previously without website enabled.
just Enable website on the previously created s3 bucket.

Then give the bucket to the cdn module: origin_bucket = "your_bucket_name"
it will find what it needs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

2 participants