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

fix: Use splat syntax for cluster name to avoid (known after apply) in managed node groups #868

Conversation

barryib
Copy link
Member

@barryib barryib commented May 6, 2020

PR o'clock

Description

After some tests, I've noticed that all inputs of the null_data_source are already know.

  # module.eks.data.null_data_source.node_groups[0] will be read during apply
  # (config refers to values not yet known)
 <= data "null_data_source" "node_groups"  {
      + has_computed_default = (known after apply)
      + id                   = (known after apply)
      + inputs               = {
          + "aws_auth"        = "kube-system/aws-auth"
          + "cluster_name"    = "test-eks-uIVr3XSp"
          + "role_CNI_Policy" = "test-eks-uIVr3XSp20200505210731845200000005-20200505210733402400000008"
          + "role_Container"  = "test-eks-uIVr3XSp20200505210731845200000005-20200505210733399800000007"
          + "role_NodePolicy" = "test-eks-uIVr3XSp20200505210731845200000005-20200505210733441800000009"
        }
      + outputs              = (known after apply)
      + random               = (known after apply)
    }

The unknown values are computed one like random, id, etc. and those will be read only during apply unless we remove the count. In that way Terraform will always read datas before apply and avoid the (known after apply) issue. Sounds like a Terraform magic again 🤷‍♂️

Resolves #843 #862

Checklist

@barryib barryib requested a review from dpiddockcmp May 6, 2020 13:04
@barryib barryib changed the title fix: Don't use count in null_data_source to avoid reading only during the apply fix: Don't use count in null_data_source to avoid reading only during the apply phase May 6, 2020
Copy link
Contributor

@dpiddockcmp dpiddockcmp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works. And fixes the issues 👍

I didn't know that TF 0.12 supported depends_on for variables. I thought this hadn't been implemented yet and the bug traffic I found had it potentially scheduled for 0.13. I would have gone that route if I'd known it existed when first implementing this module 😉

node_groups.tf Show resolved Hide resolved
node_groups.tf Show resolved Hide resolved
@barryib
Copy link
Member Author

barryib commented May 6, 2020

It works. And fixes the issues 👍

I didn't know that TF 0.12 supported depends_on for variables. I thought this hadn't been implemented yet and the bug traffic I found had it potentially scheduled for 0.13. I would have gone that route if I'd known it existed when first implementing this module 😉

@dpiddockcmp So should we go with #867 or continue on this PR ?

@barryib barryib changed the title fix: Don't use count in null_data_source to avoid reading only during the apply phase fix: Use splat syntax for cluster_name to avoid (known after apply) in managed node groups May 6, 2020
@barryib barryib force-pushed the tba/remove-count-null-datasource branch from a996b96 to 2ad1999 Compare May 6, 2020 19:26
@barryib barryib requested a review from dpiddockcmp May 6, 2020 19:28
@barryib
Copy link
Member Author

barryib commented May 6, 2020

It works. And fixes the issues 👍
I didn't know that TF 0.12 supported depends_on for variables. I thought this hadn't been implemented yet and the bug traffic I found had it potentially scheduled for 0.13. I would have gone that route if I'd known it existed when first implementing this module 😉

@dpiddockcmp So should we go with #867 or continue on this PR ?

Let's stick with this. It sounds to work without notable change.

@barryib barryib changed the title fix: Use splat syntax for cluster_name to avoid (known after apply) in managed node groups fix: Use splat syntax for cluster name to avoid (known after apply) in managed node groups May 6, 2020
@wwentland
Copy link
Contributor

wwentland commented May 6, 2020

Just wanted to mention that I find the approach in #867 to be much more explicit and easier to understand. While it is true that the PR consists of more notable changes to the make-up of the module, it might be preferred as it relies on less "magic" than the approach here.

That being said, I have tested the changes in here and can confirm that they address the issues at hand, but I am unsure as to why that is exactly.

Copy link
Contributor

@dpiddockcmp dpiddockcmp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does work and with minimal changes. Ignoring the confusion over why it works and breaking my mental model of Terraform 😁

@barryib barryib linked an issue May 7, 2020 that may be closed by this pull request
1 task
@barryib barryib merged commit 527d4bd into terraform-aws-modules:master May 7, 2020
@barryib barryib deleted the tba/remove-count-null-datasource branch May 7, 2020 07:17
@barryib barryib mentioned this pull request May 7, 2020
2 tasks
@barryib barryib mentioned this pull request May 20, 2020
2 tasks
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants