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

Setting ForcesProviderReplace on region mistakenly replaces resources in the same region #3826

Closed
t0yv0 opened this issue Apr 16, 2024 · 1 comment
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Milestone

Comments

@t0yv0
Copy link
Member

t0yv0 commented Apr 16, 2024

What happened?

Currently changing the region of AWS provider fails to move the resources to a new region and instead fails. While the
behavior is similarly unsatisfactory upstream, it would be nice if Pulumi could compute the correct plan (delete in
region A and create in region B).

Our first attempt to implement this tapped into a relevant feature here where DiffConfig call may indicate a replacement
of the provider, and this cascades to replace plans for all resources provisioned with that provider configuration,
which accomplishes the desired effect.

ForcesProviderReplace setting was introduced in the bridge, and DiffConfig reinstated, fixing
pulumi/pulumi-terraform-bridge#244 and #3497
demonstrated that this can make the AWS provider behave correctly on recent versions of Pulumi.

However, upgrade tests discovered a problem. While v3.111.1 of the CLI works, for resources provisioned on v3.86.0
version of the CLI (and possibly subsequent versions, we have not completed bisecting), Pulumi does not store region in
the state, causing the provider to erroneously conclude in DiffConfig that region is changing from empty to "us-west-2",
and replacing resources in the same region.

{
  "method": "/pulumirpc.ResourceProvider/DiffConfig",
  "request": {
    "urn": "urn:pulumi:test::test::pulumi:providers:aws::provider",
    "olds": {
      "version": "5.42.0"
    },
    "news": {
      "region": "us-west-2",
      "skipCredentialsValidation": "false",
      "skipMetadataApiCheck": "true",
      "skipRegionValidation": "true",
      "version": "5.42.0"
    },
    "oldInputs": {
      "version": "5.42.0"
    }
  },
  "response": {
    "replaces": [
      "region"
    ],
    "changes": "DIFF_SOME",
    "diffs": [
      "skipRegionValidation",
      "skipCredentialsValidation",
      "skipMetadataApiCheck"
    ],
    "detailedDiff": {
      "region": {
        "kind": "ADD_REPLACE",
        "inputDiff": true
      },
      "skipCredentialsValidation": {
        "inputDiff": true
      },
      "skipMetadataApiCheck": {
        "inputDiff": true
      },
      "skipRegionValidation": {
        "inputDiff": true
      }
    },
    "hasDetailedDiff": true
  }
}

Example

N/A

Output of pulumi about

N/A

Additional context

N/A

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@t0yv0 t0yv0 added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team and removed needs-triage Needs attention from the triage team labels Apr 16, 2024
@t0yv0 t0yv0 self-assigned this Apr 26, 2024
t0yv0 added a commit to pulumi/pulumi-terraform-bridge that referenced this issue May 10, 2024
The ForceProviderReplace setting introduces cascading replaces when a certain Provider-level configuration setting
changes. For example, changing the region in the AWS Provider is able to recreate all the affected resources in the new
desired region with this setting. There was however a practical problem fixed with this PR that caused accidental
re-creation of resources in the same region.

Specifically, some of the resources states provisioned by older versions of Pulumi CLI may not have oldInputs
sufficiently populated in the call to DetailedDiff. This caused ForceProviderReplace logic to assume that the region is
changing from "" to "us-east-1" where it did not, in fact, change. To compensate for this, the logic no longer initiates
cascading replace when the oldInputs map does not contain the value.

See also:

- pulumi/pulumi-aws#3826
- pulumi/pulumi-aws#3674
t0yv0 added a commit to pulumi/pulumi-terraform-bridge that referenced this issue May 13, 2024
The ForceProviderReplace setting introduces cascading replaces when a
certain Provider-level configuration setting changes. For example,
changing the region in the AWS Provider is able to recreate all the
affected resources in the new desired region with this setting. There
was however a practical problem fixed with this PR that caused
accidental re-creation of resources in the same region.

Specifically, some of the resources states provisioned by older versions
of Pulumi CLI may not have oldInputs sufficiently populated in the call
to DetailedDiff. This caused ForceProviderReplace logic to assume that
the region is changing from "" to "us-east-1" where it did not, in fact,
change. To compensate for this, the logic no longer initiates cascading
replace when the oldInputs map does not contain the value.

See also:

- pulumi/pulumi-aws#3826
- #244
- pulumi/pulumi-aws#3497
@t0yv0
Copy link
Member Author

t0yv0 commented May 13, 2024

This got fixed in the bridge with pulumi/pulumi-terraform-bridge#1958

@t0yv0 t0yv0 added the resolution/fixed This issue was fixed label May 13, 2024
@t0yv0 t0yv0 added this to the 0.104 milestone May 13, 2024
@t0yv0 t0yv0 closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

1 participant