fpco / terraform-aws-foundation

Establish a solid Foundation on AWS with these modules for Terraform
MIT License
203 stars 99 forks source link

Module/single-port-sg: Support source_security_group #307

Closed Magicloud closed 4 years ago

Magicloud commented 4 years ago

name: Pull request template about: Make a PR to terraform-aws-foundation

Please include the following in your PR:

Please also note that these are not hard requirements, but merely serve to define what maintainers are looking for in PR's. Including these will more likely lead to your PR being reviewed and accepted.

mcgirr commented 4 years ago

Is there a way to use this without a targeted apply? I'm running into this situation that I think is stemming from the changes in the PR:

count                    = local.udp * local.by_src_sg

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.
Magicloud commented 4 years ago

Is there a way to use this without a targeted apply? I'm running into this situation that I think is stemming from the changes in the PR:

count                    = local.udp * local.by_src_sg

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.

I feel like this is a dep issue. I got this while destroying resources again. The source SG was gone (and this rule), but TF says it cannot calculate the count.

The reason I do it this way is that, source_security_group and cidr_blocks cannot be set at the same time, even one is an empty value.

@ketzacoatl Do you have any better idea? If not, I'd have to cancel this change.

ketzacoatl commented 4 years ago

@Magicloud please update the above, TY!

Magicloud commented 4 years ago

Updated new design. Tested in PR https://github.com/fpco/terraform-aws-foundation/pull/304.