terraform-provider-cloudfoundry icon indicating copy to clipboard operation
terraform-provider-cloudfoundry copied to clipboard

`cloudfoundry_network_policy` not ordered correctly after app update to pickup new blue/green `id_bg`

Open dwaynebailey opened this issue 5 years ago • 4 comments

I have a deployment that is similar to the network_policy outlines here https://github.com/cloudfoundry-community/terraform-provider-cf/wiki/resource_app#update-resource-using-blue-green-app-id

I.e. two apps that are both deployed as blue/green.

If I taint my equivalent of cloudfoundry_app.test-app-bg2 (destination app)then plan will correctly show that the app is to be updated and also that the network policy will be impacted.

Edited to match the example

  # cloudfoundry_network_policy.my-policy will be updated in-place
  ~ resource "cloudfoundry_network_policy" "my-policy" {
        id = "27651512-dd8d-ea9d-fa5a-269116b35a92"

      - policy {
          - destination_app = "f5f54e62-c7b4-4398-8a1d-e26ed998bc1d" -> null
          - port            = "8080" -> null
          - protocol        = "tcp" -> null
          - source_app      = "7243272e-1390-4855-a5a2-9c12ddb7f9cd" -> null
        }
      + policy {
          + destination_app = (known after apply)
          + port            = "8080"
          + protocol        = "tcp"
          + source_app      = "7243272e-1390-4855-a5a2-9c12ddb7f9cd"
        }

But when doing the actual deploy the network policies are refreshed before the app deployment is started.

cloudfoundry_network_policy.my-policy: Refreshing state... [id=27651512-dd8d-ea9d-fa5a-269116b35a92***
...
cloudfoundry_app.test-app-bg2: Destroying... [id=f5f54e62-c7b4-4398-8a1d-e26ed998bc1d***
cloudfoundry_app.test-app-bg2: Destruction complete after 2s
cloudfoundry_app.test-app-bg2: Creating...
...
cloudfoundry_app.test-app-bg2: Creation complete after 1m10s [id=93d0314d-cbc1-48ee-8999-ce31edd9d09e***

The following error is reported:

Error: "policy.0.destination_app": required field is not set

  on xxxx.tf line 41, in resource "cloudfoundry_network_policy" "my-policy":
  41: resource "cloudfoundry_network_policy" "my-policy" {

dwaynebailey avatar Aug 27 '20 15:08 dwaynebailey

Ooops I think this is me repeating myself see #242

dwaynebailey avatar Aug 28 '20 08:08 dwaynebailey

Actually not sure it is, sorry for the noise

dwaynebailey avatar Aug 28 '20 08:08 dwaynebailey

what's your version of terraform ? can we see your tf files please ?

You can also use depends_on parameter: https://www.terraform.io/docs/configuration/resources.html#depends_on-explicit-resource-dependencies but here it should not do things in this order

ArthurHlt avatar Aug 28 '20 12:08 ArthurHlt

@ArthurHlt

$ terraform --version
Terraform v0.12.29
+ provider.cloudfoundry v0.12.2

I'll need some time to obfuscate the tf files, but should be able to do it. I did think about using depends_on to force this, I might still try.

dwaynebailey avatar Aug 28 '20 18:08 dwaynebailey