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

[BUG] Savings plan creation and import does not work #798

Closed
karatekaneen opened this issue Jan 10, 2025 · 3 comments · Fixed by #799
Closed

[BUG] Savings plan creation and import does not work #798

karatekaneen opened this issue Jan 10, 2025 · 3 comments · Fixed by #799

Comments

@karatekaneen
Copy link

karatekaneen commented Jan 10, 2025

Describe the bug

I can't create savings plan via terraform or import it from the UI.

Terraform Version

1.10.4

OVH Terraform Provider Version

terraform {
  required_version = ">= 0.14.0"

  required_providers {
    openstack = {
      source                = "terraform-provider-openstack/openstack"
      version               = "~> 1.53.0"
      configuration_aliases = [openstack.target]
    }

    ovh = {
      source                = "ovh/ovh"
      version               = "1.4.0"
      configuration_aliases = [ovh.target]
    }
  }
}

Affected Resource(s)

  • ovh_savings_plan

Terraform Configuration Files

Note this works fine when running terraform plan, it fails when applying.

resource "ovh_savings_plan" "savings_plan" {
  service_name = var.ovh_project_id
  flavor       = "b3-8"
  period       = "P1M"
  auto_renewal = true
  display_name = "dtrack_savings_plan_1m"
  size         = 1
}

Debug Output

It gave the following error

│ Error: no savings plan available with the given parameters
│ 
│   with module.dtrack.ovh_savings_plan.savings_plan,
│   on ../../modules/dtrack/main.tf line 33, in resource "ovh_savings_plan" "savings_plan":
│   33: resource "ovh_savings_plan" "savings_plan" {

Expected Behavior

I want to create a savings plan via terraform, if that does not work i want to be able to import one.

Actual Behavior

I first tried to create a savings plan via Terraform with the file provided above and it gave the error. When that didn't work I tried to import it as it's explained in the documentation by running:

terraform import module.dtrack.ovh_savings_plan.savings_plan ${PROJECT_ID}/${SAVING_PLAN_ID}

NOTE: the ID was really hard to find in the UI, had to look at the network logs to figure it out

The import didn't give any errors but when I run terraform plan i get the following output:

  # module.dtrack.ovh_savings_plan.savings_plan must be replaced
-/+ resource "ovh_savings_plan" "savings_plan" {
      + display_name      = "dtrack_savings_plan_P1M"
      ~ end_date          = "2025-02-11" -> (known after apply)
      + flavor            = "b3-8" # forces replacement
      ~ id                = "my-redacted-uuid" -> (known after apply)
      + period            = "P1M" # forces replacement
      ~ period_end_action = "REACTIVATE" -> (known after apply)
      ~ period_end_date   = "2025-02-11" -> (known after apply)
      ~ period_start_date = "2025-01-11" -> (known after apply)
      ~ service_id        = *REDACTED* -> (known after apply)
      + service_name      = "my-project-id" # forces replacement
      + size              = 1
      ~ start_date        = "2025-01-11" -> (known after apply)
      ~ status            = "PENDING" -> (known after apply)
        # (1 unchanged attribute hidden)
    }

Additional context

When running terraform show this is the relevant output, anonymized.
Note that flavor, period and service_name is missing.

# module.dtrack.ovh_savings_plan.savings_plan:
resource "ovh_savings_plan" "savings_plan" {
    auto_renewal      = true
    end_date          = "2025-02-11"
    id                = "my-redacted-uuid"
    period_end_action = "REACTIVATE"
    period_end_date   = "2025-02-11"
    period_start_date = "2025-01-11"
    service_id        = *REDACTED*
    start_date        = "2025-01-11"
    status            = "PENDING"
}

So, am I missing something fundamental or is this a bug?

@amstuta
Copy link
Collaborator

amstuta commented Jan 10, 2025

Hello @karatekaneen, in fact the flavor needs to be uppercased, so this is the cause of the issue you're encountering.

I just ran the following plan that works:

resource "ovh_savings_plan" "savings_plan" {
  service_name = "redacted"
  flavor       = "B3-8"
  period       = "P1M"
  auto_renewal = true
  display_name = "dtrack_savings_plan_1m"
  size         = 1
}

I understand that it is not obvious, so I'll state this requirement in the documentation.

@karatekaneen
Copy link
Author

@amstuta Nice, thank you! I't will solve my problem next month when I'm able to create a new one.

However, the flavor is lowercase everywhere else in both price lists and when running openstack flavor list so I would argue that uppercase would be inconsistent.

@amstuta
Copy link
Collaborator

amstuta commented Jan 10, 2025

I agree, but the only thing we can do on provider side is to force uppercase when creating a savings plan. I'm adding this to the resource so your original plan with lowercased flavor will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants