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

Optional parameters are ignored and not applied #460

Open
jeannich opened this issue Feb 17, 2023 · 1 comment
Open

Optional parameters are ignored and not applied #460

jeannich opened this issue Feb 17, 2023 · 1 comment

Comments

@jeannich
Copy link

Hello,

I faced issues with optional parameters not being detected, I tried below to summarize the different problematics:

  • Issue1: adding optional parameters is NOT detected:

Problem reproduction:
Config:

    resource "cloudfoundry_app" "foo" {
        name = "foo"
        path = "foo.zip"
    }

actions:
"TF apply" result: App is deployed with default amount of memory (1024Mb)
Then we edit the config to add the 'memory' parameter:

    resource "cloudfoundry_app" "foo" {
        name = "foo"
        path = "foo.zip"
        memory = 256
    }
"TF apply" result: TF will report NO change and request to change memory amount is ignored
  • Issue 2: removing an optional parameter is NOT detected neither:

Problem reproduction:
Scenario 1:
Config:

    resource "cloudfoundry_app" "foo" {
        name = "foo"
        path = "foo.zip"
        memory = 256
    }

actions:
"TF apply" result: App is deployed with 256Mb
Then we edit the config to remove the 'memory' parameter:

    resource "cloudfoundry_app" "foo" {
        name = "foo"
        path = "foo.zip"
    }
"TF apply" result: TF will report no change, app will stay with 256Mb

Scenario 2:
Config:

    resource "cloudfoundry_app" "foo" {
        name = "foo"
        path = "foo.zip"
    }

actions:
"TF apply" result: App is deployed with default CF memory amount, which is 1024Mb

Conclusion of issue 2: With the same configuration, we get 2 different results.

Expected result:
In Issue1: added memory value should be applied
In Issue 2/scenario 1, "memory" parameter removal should be detected, and app should be restaged/restarted so that default amount of memory is applied

@Thanhphan1147
Copy link
Contributor

I also run into the same issue, removing an existing optional attribute from .tf files should trigger a restage (for memory and disk_quota for example). One way we can do this is to remove the Computed modifier from these attributes and add nil as the Default value. The problem with this is that go converts nil to something else depends on the type of the attribute ( 0 for intergers and "" for string attributes). So we'll see something like :

{
memory = 0
}

in our TF state. @loafoe do you have any comments on this?

Thanks,
Thanh

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