-
Notifications
You must be signed in to change notification settings - Fork 137
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
The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. #8
The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. #8
Comments
@jmhale, thanks for the review on the previous pull requests. Could you share any initial pointers to get me started on how we can fix this issue? |
@sheeeng This is a strange one. I'm not quite sure what's going on yet. Are you only seeing this in ALB mode, and not when using a EIP? I'm using EIP for day-to-day stuff, and I'm not seeing this error. I'm going to switch it to using a ALB and see if I can reproduce. |
Hmm. I am using the provided basic EIP example. |
Yeah, I think something weird is going on then. Do you have remote state? Are you able to blow away your local copy and pull from remote ( I tried to switch to the ALB config, but I hit a strange cycle error when trying to destroy the existing stack, and I haven't had enough caffeine yet to try and diagnose that one. |
Yes, I purged all untracked files in the cloned repository. I did not change anything inside the ➜ simple_eip git:(master) $ terraform init
Initializing modules...
Downloading [email protected]:jmhale/terraform-wireguard.git for wireguard...
- wireguard in .terraform/modules/wireguard
Initializing the backend...
Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "aws" (hashicorp/aws) 2.50.0...
- Downloading plugin for provider "template" (hashicorp/template) 2.1.2...
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
➜ simple_eip git:(master) $ terraform version
Terraform v0.12.21
+ provider.aws v2.50.0
+ provider.template v2.1.2
➜ simple_eip git:(master) $ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
module.wireguard.data.template_file.wg_client_data_json[1]: Refreshing state...
module.wireguard.data.template_file.wg_client_data_json[2]: Refreshing state...
module.wireguard.data.template_file.wg_client_data_json[0]: Refreshing state...
module.wireguard.data.aws_ssm_parameter.wg_server_private_key: Refreshing state...
module.wireguard.data.aws_iam_policy_document.ec2_assume_role: Refreshing state...
module.wireguard.data.aws_ami.ubuntu: Refreshing state...
module.wireguard.data.aws_iam_policy_document.wireguard_policy_doc: Refreshing state...
------------------------------------------------------------------------
Error: Invalid count argument
on .terraform/modules/wireguard/wireguard-iam.tf line 28, in resource "aws_iam_policy" "wireguard_policy":
28: count = (var.eip_id != "disabled" ? 1 : 0) # only used for EIP mode
The "count" value depends on resource attributes that cannot be determined
until apply, so Terraform cannot predict how many instances will be created.
To work around this, use the -target argument to first apply only the
resources that the count depends on.
Error: Invalid count argument
on .terraform/modules/wireguard/wireguard-iam.tf line 36, in resource "aws_iam_role" "wireguard_role":
36: count = (var.eip_id != "disabled" ? 1 : 0) # only used for EIP mode
The "count" value depends on resource attributes that cannot be determined
until apply, so Terraform cannot predict how many instances will be created.
To work around this, use the -target argument to first apply only the
resources that the count depends on.
➜ simple_eip git:(master) $ I will look further into this issue in my free time. Thanks for the initial pointers! |
@jmhale, what is the output of your |
@sheeeng I'm using Not sure of the various provider versions off the top of my head. I can grab the full output when I'm back home. |
@vtknightmare, sorry that I manage to further debug the issue. |
The error message here suggested a workaround:
Just break down
|
The problem here is that when you pass in an Elastic IP ID as a reference to a resource attribute (i.e. when you're creating the EIP in the same plan), Terraform doesn't know the value of Here is a proposed solution that splits out the configuration of whether to use an EIP and the EIP ID itself into separate variables ( |
I see the same & the fix is pretty easy, so why not add to master? |
The text was updated successfully, but these errors were encountered: