terraform-provider-bitbucketserver
terraform-provider-bitbucketserver copied to clipboard
terraform plan fails for bitbucketserver_plugin_config & bitbucketserver_plugin when plugin is uninstalled using bitbucket UI
Steps to reproduce the bug :
- Install any plugin using
bitbucketserver_pluginand configuration for the plugin usingbitbucketserver_plugin_config - From the Bitbucket UI , under admin options> managed apps , uninstall the plugin
Issue :
-
Running terraform plan tries to refresh the state for
bitbucketserver_pluginand fails withfailed to get plugin com.my.oauth.bitbucket-oauth from bitbucket: API Error: 404 /rest/plugins/1.0/com.my.oauth.bitbucket-oauth-key. The expectation was the resource should be marked to be created again and address the drift. -
If we manually delete the module
module.bitbucket.bitbucketserver_plugin.my_auth_pluginfrom the terraform state and try terraform plan we get a different error now frombitbucketserver_plugin_configieError: API Error: 405 /plugins/servlet/oauth/configure. This might be becausebitbucketserver_plugin_configis trying to refresh the state of the config even if the plugin is uninstalled. The expectation was it should try to GET the resource if plugin doesnt exist (is this by design ? )
Following are the resource config :
resource "bitbucketserver_plugin" "my_auth_plugin" {
count = local.my_resource_count
key = "com.my.oauth.bitbucket-oauth"
version = var.my_auth_plugin_version
license = replace(var.my_auth_plugin_license, "\n", "\r\n")
depends_on = [
null_resource.bitbucket_validate, # validate if the bitbucket server is running
]
}
resource "bitbucketserver_plugin_config" "my_pluginconfig" {
config_endpoint = "/plugins/servlet/oauth/configure"
values = local.my_sso_config
depends_on = [
bitbucketserver_plugin.my_auth_plugin,
null_resource.wait_for_mo_auth_plugin_endpoint # wait for the plugin to be installed
]
}