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

Cache bucket ARN not found when cache_enabled = "false" #38

Closed
roryhow opened this issue Mar 17, 2019 · 0 comments
Closed

Cache bucket ARN not found when cache_enabled = "false" #38

roryhow opened this issue Mar 17, 2019 · 0 comments

Comments

@roryhow
Copy link

roryhow commented Mar 17, 2019

It seems that when cache is disabled (i.e cache_enabled = "false"), terraform plan will fail with the following output:

Error: Error running plan: 1 error(s) occurred:

* module.build.data.aws_iam_policy_document.permissions_cache_bucket: 1 error(s) occurred:

* module.build.data.aws_iam_policy_document.permissions_cache_bucket: Resource 'aws_s3_bucket.cache_bucket' not found for variable 'aws_s3_bucket.cache_bucket.arn'

my assumption is that this is due to the following aws_iam_policy_document missing a check for var.cache_enabled. I made a fork where the permissions_cache_bucket is updated like so:

data "aws_iam_policy_document" "permissions_cache_bucket" {
  count = "${var.enabled == "true" && var.cache_enabled == "true" ? 1 : 0}"

  statement {
    sid = ""

    actions = [
      "s3:*",
    ]

    effect = "Allow"

    resources = [
      "${aws_s3_bucket.cache_bucket.arn}",
      "${aws_s3_bucket.cache_bucket.arn}/*",
    ]
  }
}

Please let me know if I'm doing something wrong (I'm pretty new to Terraform so this could definitely be the case), or if it's a bug, I can submit a PR. Thanks!

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

1 participant