Skip to content

Invalid Count Argument #38

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

Closed
NeroAngra opened this issue Jun 27, 2021 · 4 comments
Closed

Invalid Count Argument #38

NeroAngra opened this issue Jun 27, 2021 · 4 comments

Comments

@NeroAngra
Copy link

Hi there! Very new to Terraform. Any advice is appreciated.

Error message:
Error1

Main.tf 1 - Account ID Hidden
MainTF1

Main.tf 2
MainTF2

VPC:
VPC

Subnets:
subnets

Provider.tf:
provider

Thank you! Really enjoying working on this.

@petewilcock
Copy link
Contributor

The VPC module is just included as an example for VPC creation if you don't have one already - if you do (and it looks like you do as you've inserted your values there), you can just remove the module_vpc block and it'll work as expected :)

@NeroAngra
Copy link
Author

NeroAngra commented Jun 27, 2021

Thank you Pete, that did work. I don't think I setup the subnets correctly, though (I didn't put them in different availability zones, for example) so I ran into other issues.

I want to start from scratch, so I deleted the manually created VPC, deleted all cached Terraform files and re-ran Terraform with just the *_VPC module with the intent of letting Terraform create the VPC for me, but I get the same count argument errors that I noted above.

I do have a default VPC in the us-west-1 region, could that be causing a conflict?

@petewilcock
Copy link
Contributor

No I think I've actually just written that VPC module quite poorly, The errors are because I'm creating a specific number of resources based on a value that Terraform can't work out in advance. It seems that older versions used to be a bit more tolerant of this but now it just throws a hard error.

It comes from the fact that easy region has a variable number of availability zones, at least two but sometimes five. What I tried to do there was query the number of zones and then create as many as needed, hence the count resource. Basically I just need to rewrite that with a better method.

TL;DR though, I'd just create your fresh VPC and availability zones manually and plug the values back in until I fix that up. You only really need one AZ for this but two is good practice if you ever plan to deploy anything else in future :)

@NeroAngra
Copy link
Author

Okay, thank you for your input! I will get this closed out.

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

2 participants