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

[Postgres] Changing storage_mb from 524288 to 1048576 fails with storage_tier error #25938

Closed
1 task done
anoopjb opened this issue May 12, 2024 · 3 comments · Fixed by #25947
Closed
1 task done

[Postgres] Changing storage_mb from 524288 to 1048576 fails with storage_tier error #25938

anoopjb opened this issue May 12, 2024 · 3 comments · Fixed by #25947

Comments

@anoopjb
Copy link

anoopjb commented May 12, 2024

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

0.15.5

AzureRM Provider Version

3.103.1

Affected Resource(s)/Data Source(s)

azurerm_postgresql_flexible_server

Terraform Configuration Files

# terraform.tfstate
{
  "mode": "managed",
  "type": "azurerm_postgresql_flexible_server",
  "provider": "provider[\"registry.terraform.io/hashicorp/azurerm\"]",
  "instances": [
    {
      "sku_name": "GP_Standard_D2s_v3",
      "storage_mb": 524288,
      "storage_tier": "P20"
    }
  ]
}

# postgres.tf.json
{
  "resource": {
    "azurerm_postgresql_flexible_server": {
      "postgres_server": {
        "sku_name": "GP_Standard_D2s_v3",
        "storage_mb": 1048576,
        "version": "14"
      }
    }
  }
}

Debug Output/Panic Output

[ERROR] provider.terraform-provider-azurerm_v3.103.1_x5: Response contains error diagnostic: @caller=github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto diagnostic_detail= tf_resource_type=azurerm_postgresql_flexible_server tf_rpc=PlanResourceChange diagnostic_severity=ERROR diagnostic_summary="1 error occurred:
        * invalid 'storage_tier' "P20" for defined 'storage_mb' size '1048576', expected one of ["P30", "P40" or "P50"]

Expected Behaviour

The storage_tier is not explicitly mentioned in postgres.tf.json. The provider picks the default storage_tier (i.e P30 as per the documentation here) for the storage_mb of 1048576.

Actual Behaviour

Changing storage_mb from 524288 to 1048576 fails due to invalid storage_tier "P20".

Steps to Reproduce

  1. Setup a new Azure PostgreSQL Flexible Server with storage_mb as 524288.
  2. Change the storage_mb to 1048576.

Important Factoids

No response

References

No response

@WodansSon
Copy link
Collaborator

WodansSon commented May 14, 2024

Hi @anoopjb, thank you for opening this issue. Just so I understand the ask here, what you are saying is that you expect the storage_tier, if not defined in the configuration file, to follow the default storage_tier assignment semantics of the create function during an update operation? Basically, given your above example, if you change the configuration files storage_mb value from 524288 to 1048576 you expect the terraform provider to automatically update the storage_tier value that will be passed to the API to be the default value for the newly defined storage_mb value (e.g., P30) instead of passing/keeping the original default storage_tier value of P20 from the initial create of the resource?

@anoopjb
Copy link
Author

anoopjb commented May 14, 2024

Indeed, @WodansSon. It's precisely what I had in mind. Thank you.

@rcskosir rcskosir added the bug label May 15, 2024
WodansSon pushed a commit that referenced this issue May 16, 2024
* azurerm_postgresql_flexible_server: fix storage_tier calculation

* Add feedback

* Add storage tier test

* Add feedback and more tests
@github-actions github-actions bot added this to the v3.104.0 milestone May 16, 2024
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 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants