jenkins-x / terraform-aws-eks-jx

A Terraform module for creating Jenkins X infrastructure on AWS
Apache License 2.0
63 stars 41 forks source link

fix: Check existence of correct bucket for bucketrepo #341

Closed msvticket closed 2 years ago

msvticket commented 2 years ago

Description

When giving the variable enable_repository_storage = false to the module I got this error:

│ Error: Invalid index
│
│   on .terraform/modules/eks-jx/modules/cluster/irsa.tf line 361, in data "aws_iam_policy_document" "bucketrepo-policy":
│  361:     resources = [aws_s3_bucket.repository_jenkins_x.*.arn[0], "${aws_s3_bucket.repository_jenkins_x.*.arn[0]}/*"]
│     ├────────────────
│     │ aws_s3_bucket.repository_jenkins_x is empty tuple
│
│ The given key does not identify an element in this collection value: the
│ collection has no elements.
╵
╷
│ Error: Invalid index
│
│   on .terraform/modules/eks-jx/modules/cluster/irsa.tf line 361, in data "aws_iam_policy_document" "bucketrepo-policy":
│  361:     resources = [aws_s3_bucket.repository_jenkins_x.*.arn[0], "${aws_s3_bucket.repository_jenkins_x.*.arn[0]}/*"]
│     ├────────────────
│     │ aws_s3_bucket.repository_jenkins_x is empty tuple
│
│ The given key does not identify an element in this collection value: the
│ collection has no elements.

The work around now is to explicitly also give create_bucketrepo_role = false. With this PR that work around should be not be needed.