terraform-provider-oci icon indicating copy to clipboard operation
terraform-provider-oci copied to clipboard

'400-InvalidParameter Unable to process JSON input' Error When Creating One-Time Budgets with start_date and end_date

Open janis-ax opened this issue 1 year ago • 8 comments

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

Terraform Version and Provider Version

terraform -v
Terraform v1.5.7
on darwin_arm64
+ provider registry.terraform.io/ansible/ansible v1.1.0
+ provider registry.terraform.io/hashicorp/local v2.4.1
+ provider registry.terraform.io/hashicorp/null v3.2.2
+ provider registry.terraform.io/hashicorp/random v3.6.0
+ provider registry.terraform.io/hashicorp/tls v4.0.5
+ provider registry.terraform.io/loafoe/htpasswd v1.0.4
+ provider registry.terraform.io/oracle/oci v5.23.0

Affected Resource(s)

  • oci_budget_budget

Terraform Configuration Files

resource "oci_budget_budget" "test_budget" {
  amount         = 100
  compartment_id = <TENANCY_ID>
  reset_period   = "MONTHLY"
  

  processing_period_type = "SINGLE_USE"
  target_type            = "COMPARTMENT"
  start_date             = "2024-01-01T00:00:00.001Z" # .001 is important
  end_date               = "2024-01-10T23:59:59.999Z" # .999 is important
  targets                = [<COMPARTMENT_IDs>]
}

Debug Output

Panic Output

Expected Behavior

Should create a budget with the start and end date because it's in the correct format.

Actual Behavior

Cannot create the budget

Steps to Reproduce

  1. terraform apply

Important Factoids

References

janis-ax avatar Jan 13 '24 12:01 janis-ax

Maybe it's worth taking a look into this https://support.oracle.com/knowledge/Oracle%20Cloud/2854208_1.html There was the same problem, but with certificates

janis-ax avatar Jan 13 '24 15:01 janis-ax

Thank you for reporting the issue. We have raised an internal ticket to track this. Our service engineers will get back to you.

tf-oci-pub avatar Jan 14 '24 06:01 tf-oci-pub

Had this issue in a resource "oci_kms_vault". For me it was a wrong written value vault_type = "Default", which must be vault_type = "DEFAULT".

dmuiX avatar Apr 21 '24 15:04 dmuiX

Hi All, I am from OCI Budgets team.

This issue is generally due to date argument provided in incorrect RFC 3339 format. This format is enforced and validated by OCI Terraform Provider and is not by Budgets Service. So, we cannot change the format from Budgets Service side.

We have recently updated the Budgets Public Documentation with examples on how to provide date in correct format. Please refer to https://docs.oracle.com/en-us/iaas/api/#/en/budgets/20190111/Budget/. Also, we are aware of the wrong examples provided in https://registry.terraform.io/providers/oracle/oci/latest/docs/data-sources/budget_budgets. We are working with Terraform Provider team towards updating the examples here.

To unblock yourself, please try to match your date format with this example 2023-08-12T16:01:19.847222+05:30.

Udayaan-Nath avatar May 09 '24 08:05 Udayaan-Nath

Hm, something seems definitely wrong there. I tried your suggestion and provided the date in the format.

I can create the budget, but it seems on the OCI side it uses 23:59:59.999Z for the end date and 00:00:00Z for the start date.

  1. Apply works:
tofu apply tf.plan    
....

Apply complete! Resources: 1 added, 1 changed, 0 destroyed.
  1. Another plan shows changes:
tofu plan -out tf.plan
...

OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

OpenTofu will perform the following actions:

  # module.seminar_base.oci_budget_budget.seminar_budget will be updated in-place
  ~ resource "oci_budget_budget" "seminar_budget" {
      ~ end_date                              = "2024-05-11T23:59:59.999Z" -> "2024-05-11T16:01:19.847222+05:30"
      ~ start_date                            = "2024-05-09T00:00:00Z" -> "2024-05-09T16:01:19.847222+05:30"
        # (17 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Saved the plan to: tf.plan

To perform exactly these actions, run the following command to apply:
    tofu apply "tf.plan"....

Apply complete! Resources: 1 added, 1 changed, 0 destroyed.

So I added your time, but OCI does not recognize it correctly. So every time I do a plan it shows changes.

janis-ax avatar May 10 '24 10:05 janis-ax

I think that is expected. From Budgets service side, we always change time in start date to start of the day and time in end date to end of the day. So your state file saves the updated start and end date. Now whenever you plan again, it will show changes to the start and end date. But ultimately, the start and end dates will remain the same.

Udayaan-Nath avatar May 13 '24 07:05 Udayaan-Nath

Do you have any ideas how we can avoid this, or create a workaround?

janis-ax avatar May 16 '24 15:05 janis-ax

If you can change the time in start_date to start of the day and time in end_date to end of the day, then terraform plan will not show changes again. I am trying to find some examples on this. If I do, I will share them here.

Udayaan-Nath avatar May 22 '24 13:05 Udayaan-Nath