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

Azure App configuration FF creation with "Provider produced inconsistent result after apply" #26025

Closed
1 task done
dsczltch opened this issue May 20, 2024 · 4 comments · Fixed by #26037
Closed
1 task done

Comments

@dsczltch
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.8.3

AzureRM Provider Version

3.43.0

Affected Resource(s)/Data Source(s)

azurerm_app_configuration_feature

Terraform Configuration Files

locals {
feature_flags = jsondecode(data.local_file.feature-flags-file.content)

features = [
for feature in local.feature_flags.FeatureFlags : {
Key = feature.Key
Description = feature.Description
}
]

child_features = flatten([
for feature in local.feature_flags.FeatureFlags : [
for child in contains(keys(feature), "Children") ? feature.Children : [] : {
Key = "${feature.Key}|${child}"
Description = "[${child}] ${feature.Description}"
}
]
])
}

resource "azurerm_app_configuration_feature" "appcs-features" {
for_each = { for feature in local.features : feature.Key => feature }

configuration_store_id = data.azurerm_app_configuration.env-shared-appcs.id
name = each.value.Key
description = each.value.Description
enabled = false
lifecycle {
ignore_changes = [
enabled
]
}
}

resource "azurerm_app_configuration_feature" "appcs-child-features" {
for_each = { for feature in local.child_features : feature.Key => feature }

configuration_store_id = data.azurerm_app_configuration.env-shared-appcs.id
name = each.value.Key
description = each.value.Description
enabled = false
lifecycle {
ignore_changes = [
enabled
]
}
}

Debug Output/Panic Output

│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to
│ azurerm_app_configuration_feature.appcs-child-features["AndroidInstallBanner|fo"],
│ provider "provider["registry.terraform.io/hashicorp/azurerm"]" produced
│ an unexpected new value: Root object was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.


│ Error: Provider produced inconsistent result after apply

│ When applying changes to
│ azurerm_app_configuration_feature.appcs-features["MSClarity"], provider
│ "provider["registry.terraform.io/hashicorp/azurerm"]" produced an
│ unexpected new value: Root object was present, but now absent.

│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵

Expected Behaviour

Feature flags in Azure App Configuration should be created.

Actual Behaviour

Feature flags are created but it looks like there is a bug in the provider where terraform does not process completely the creation and cannot add the created resource into the state file ; which cause a new apply to failed due to Feature flags already existing.

Steps to Reproduce

terraform init
terraform plan
terraform apply

Important Factoids

No response

References

No response

@teowa
Copy link
Contributor

teowa commented May 21, 2024

Hi @dsczltch, thanks for submitting this. This should be caused by distributed API Azure/AppConfiguration#763, in azurerm provider we have added wait logic to wait for 2 continues 2xx status code returned by API

metadata.Logger.Infof("[DEBUG] Waiting for App Configuration Feature %q to be provisioned", model.Key)
stateConf = &pluginsdk.StateChangeConf{
Pending: []string{"NotFound", "Forbidden"},
Target: []string{"Exists"},
Refresh: appConfigurationGetKeyRefreshFunc(ctx, client, featureKey, model.Label),
PollInterval: 10 * time.Second,
ContinuousTargetOccurence: 2,
Timeout: time.Until(deadline),
}
, seems we may need to enhance this.
As a ad-hoc fix for the error, you may also use terraform import to import these created app conf features.

@dsczltch
Copy link
Author

Hi @teowa, thank you for your answer.
The issue you mentioned is closed. However, it looks like the terraform provider does not handle properly the Azure App Config API since it does not return the actual result.
Could you guys please update the terraform to be able to work with App Config properly?
The workaround is definitely not usable when we have multiple environments.

@github-actions github-actions bot added this to the v3.106.0 milestone May 27, 2024
@dsczltch
Copy link
Author

Thank you @teowa, I am not sure the change will fix this bug but we will try this new version of the provider once it's available.

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants