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

Invalid index error when emrcontainers or step functions (sfn) are not enabled #43

Closed
1 task done
bdellegrazie opened this issue Jul 3, 2023 · 0 comments · Fixed by #44
Closed
1 task done
Labels
bug Something isn't working

Comments

@bdellegrazie
Copy link
Contributor

Description

If, using the existing example, you disable the emrcontainers and/or step functions as follows:

# Controllers to enable
# ... other parts elided
enable_emrcontainers = false
enable_sfn = false

Then terraform responds with the following output:

│ Error: Invalid index
│ 
│   on .terraform/modules/eks_ack_addons/main.tf line 592, in module "emrcontainers":
│  592:     AmazonEmrContainers = aws_iam_policy.emrcontainers[0].arn
│     ├────────────────
│     │ aws_iam_policy.emrcontainers 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_ack_addons/main.tf line 773, in module "sfn":
│  773:     AWSStepFunctionsIamPassRole = aws_iam_policy.sfnpasspolicy[0].arn
│     ├────────────────
│     │ aws_iam_policy.sfnpasspolicy is empty tuple
│ 
│ The given key does not identify an element in this collection value: the collection has no elements.

This is always reproducible with v2.0.0 of the provider (latest at time of writing)

  • ✋ I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version: v2.0.0

  • Terraform version: 1.5.2

  • Provider version(s):

Terraform v1.5.2
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v5.6.2
+ provider registry.terraform.io/hashicorp/helm v2.10.1
+ provider registry.terraform.io/hashicorp/kubernetes v2.21.1

Reproduction Code

See example above in the description.
This is verifiable with the example code in this repository.

Expected behavior

Resources to be provisioned

Actual behavior

Error reported as above.

Terminal Output Screenshot(s)

Error reported as above.

Additional context

I believe this can easily be solved by either a conditional assignment:
(e.g.)

AmazonEmrContainers = var.enable_emrcontainers ? aws_iam_policy.emrcontainers[0].arn : null

or by the use of try:

AmazonEmrContainers = try(aws_iam_policy.emrcontainers[0].arn, null)
bdellegrazie added a commit to bdellegrazie/terraform-aws-eks-ack-addons that referenced this issue Jul 5, 2023
When emrcontainers or step function capabilties were disabled, Terraform
would try to assign the associated policy. The policy doesn't exist
because that component is disabled.

fixes: aws-ia#43
bdellegrazie added a commit to bdellegrazie/terraform-aws-eks-ack-addons that referenced this issue Jul 5, 2023
When emrcontainers or step function capabilties were disabled, Terraform
would try to assign the associated policy. The policy doesn't exist
because that component is disabled.

As a test, an all controllers disabled module has been added to the example.

fixes: aws-ia#43
bdellegrazie added a commit to bdellegrazie/terraform-aws-eks-ack-addons that referenced this issue Jul 5, 2023
When emrcontainers or step function capabilties were disabled, Terraform
would try to assign the associated policy. The policy doesn't exist
because that component is disabled.

As a test, an all controllers disabled module has been added to the example.

fixes: aws-ia#43
bdellegrazie added a commit to bdellegrazie/terraform-aws-eks-ack-addons that referenced this issue Jul 5, 2023
When emrcontainers or step function capabilties were disabled, Terraform
would try to assign the associated policy. The policy doesn't exist
because that component is disabled.

As a test, an all controllers disabled module has been added to the example.

fixes: aws-ia#43
@askulkarni2 askulkarni2 added the bug Something isn't working label Jul 5, 2023
bdellegrazie added a commit to bdellegrazie/terraform-aws-eks-ack-addons that referenced this issue Jul 5, 2023
When emrcontainers or step function capabilties were disabled, Terraform
would try to assign the associated policy. The policy doesn't exist
because that component is disabled.

As a test, an all controllers disabled module has been added to the example.

fixes: aws-ia#43
@askulkarni2 askulkarni2 moved this to Done in EKS Blueprints Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants