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

Unable to use website inputs #141

Closed
jurgen-weber-deltatre opened this issue Mar 14, 2022 · 6 comments · Fixed by #158
Closed

Unable to use website inputs #141

jurgen-weber-deltatre opened this issue Mar 14, 2022 · 6 comments · Fixed by #158
Assignees
Labels
bug 🐛 An issue with the system

Comments

@jurgen-weber-deltatre
Copy link

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

Unable to use website inputs, attempting to upgrade from AWS provider v3 to v4 (hence updating to current).

│ Error: Invalid for_each set argument
│
│   on .terraform/modules/object_storage.s3_bucket/main.tf line 93, in resource "aws_s3_bucket_website_configuration" "default":
│   93:   for_each = local.enabled && var.website_inputs != null ? toset(var.website_inputs) : toset([])
│     ├────────────────
│     │ local.enabled is true
│     │ var.website_inputs is list of object with 1 element
│
│ The given "for_each" argument value is unsuitable: "for_each" supports maps and sets of strings, but you have provided a set containing type object.

Expected Behavior

I expect my plan to complete, creating the website inputs.

Steps to Reproduce

Steps to reproduce the behavior:

module "s3_bucket" {
  source                        = "cloudposse/s3-bucket/aws"

  acl                           = "private"
  allowed_bucket_actions        = ["s3:GetObject", "s3:ListBucket", "s    3:GetBucketLocation"]
  enabled                       = true
  ignore_public_acls            = true
  lifecycle_rules               = var.lifecycle_rules
  name                          = "com-mtribes-test-jurgen-delete-me"
  restrict_public_buckets       = true
  user_enabled                  = false
  versioning_enabled            = false
  website_inputs = [
    {
      index_document           = "index.html"
      error_document           = null 
      redirect_all_requests_to = []
      routing_rules            = []
    }
  ]
}

Screenshots

If applicable, add screenshots or logs to help explain your problem.

Environment (please complete the following information):

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

  • OS: OSX
  • Version 12.2.1
$ tf version
Terraform v1.1.7
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v4.5.0
+ provider registry.terraform.io/hashicorp/local v2.2.2
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/time v0.7.2

Additional Context

Add any other context about the problem here.

@Nuru
Copy link
Contributor

Nuru commented Mar 26, 2022

Confirmed. You probably cannot use CORS rules, either. Sorry about that.

@Nuru Nuru pinned this issue Mar 26, 2022
@jurgen-weber-deltatre
Copy link
Author

Sure, I have a PR open but I am not totally on top of your eco system so have some pending questions. Feel free to take over it or trash it as you please.

@Nuru
Copy link
Contributor

Nuru commented Mar 28, 2022

@jurgen-weber-deltatre I plan to fix this along with #137 when AWS provider v4.9.0 is released. You do not need to do any more work on fixing this problem, but if you could provide a test case under examples/complete (see, for example, lifecycle.us-east-2.tfvars), that would be a big help. If you can also include CORS rules, even better.

@rstml
Copy link

rstml commented Apr 14, 2022

Any update on this? Also, how can one get website_endpoint of bucket created using this module? Can't find anything in output.tf.

@Nuru
Copy link
Contributor

Nuru commented Apr 21, 2022

@rstml we are tracking a fix for this in #142
Meanwhile, you may want to use one of our other modules, terraform-aws-s3-website or terraform-aws-cloudfront-s3-cdn. Eventually those will be re-written to use this module, and there will be a migration step when that happens, but this is something you can do now to get a website up.

@rstml
Copy link

rstml commented Apr 21, 2022

Thanks for the update, @Nuru. Decided to use the following workaround and extend this module with vanilla tf:

module "s3_bucket" {
  source  = "cloudposse/s3-bucket/aws"
  version = "2.0.0"

  //...
}

resource "aws_s3_bucket_website_configuration" "s3_bucket_website" {
  bucket = module.s3_bucket.bucket_id

  //...
}

output "website_endpoint" {
  value = aws_s3_bucket_website_configuration.s3_bucket_website.website_endpoint
}

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
4 participants