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

provider version >= 5.44.0 does not read ~/.oci/config #2141

Open
xkoomy opened this issue Jun 18, 2024 · 2 comments
Open

provider version >= 5.44.0 does not read ~/.oci/config #2141

xkoomy opened this issue Jun 18, 2024 · 2 comments
Labels
awaiting-affected-resources Please Provide the affected resource name in description. ex. Affected resource - oci_core_instance bug

Comments

@xkoomy
Copy link

xkoomy commented Jun 18, 2024

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 linux_amd64
+ provider registry.terraform.io/oracle/oci v5.46.0

Affected Resource(s)

affected_resources = terraform

Terraform Configuration Files

provider "oci" {
  tenancy_ocid         = var.tenancy_ocid
  user_ocid            = var.user_ocid
  fingerprint          = var.fingerprint
  private_key_path     = var.private_key_path
  region               = var.region
}

terraform {
  required_providers {
    oci = {
      source = "oracle/oci"
      version = "5.46.0" # version >= 5.44.0 does not read ~/.oci/config properly
    }
  }
}

variable "fingerprint" {
  type = string
  default = ""
}

variable "private_key_path" {
  type = string
  default = ""
}

variable "region" {
  type = string
  default = "eu-frankfurt-1"
}

variable "tenancy_ocid" {
  type = string
  default = ""
}

variable "user_ocid" {
  type = string
  default = ""
}

locals {
    compartment_id = "ocid1.compartment.oc1..XXXXXXXXXXX"
    vcn_id = "ocid1.vcn.oc1.eu-frankfurt-1.YYYYYYYY"
}
resource "oci_core_subnet" "test_subnet1" {
    #Required
    cidr_block = "192.168.1.0/24"
    compartment_id = local.compartment_id
    vcn_id = local.vcn_id
    #Optional
    display_name = "testsubnet1"
    dns_label = "testsubnet1"
}

Debug Output

https://gist.github.com/xkoomy/03ede09cb90beafdad426319fa285cff

Panic Output

Expected Behavior

In version 5.43.0 and lower the provider reads the config from ~/.oci/config properly:

$ terraform -v
Terraform v1.5.7
on linux_amd64
+ provider registry.terraform.io/oracle/oci v5.43.0

Your version of Terraform is out of date! The latest version
is 1.8.5. You can update by downloading from https://www.terraform.io/downloads.html


$ terraform plan -input=false
oci_core_subnet.test_subnet1: Refreshing state... [id=ocid1.subnet.oc1.eu-frankfurt-1.aaaaaaaaox2hnp7cdh22ujrgkxphk3yp4qrusixsdkvzsj3shis4tz5xqn6q]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Actual Behavior

provider version >= 5.44.0 does not read config from DEFAULT profile in ~/.oci/config

$ TF_LOG=DEBUG OCI_GO_SDK_DEBUG=v TF_LOG_PATH=tf_debug.log terraform plan -input=false
oci_core_subnet.test_subnet1: Refreshing state... [id=ocid1.subnet.oc1.eu-frankfurt-1.aaaaaaaaox2hnp7cdh22ujrgkxphk3yp4qrusixsdkvzsj3shis4tz5xqn6q]

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: 401-NotAuthenticated, The required information to complete authentication was not provided or was incorrect.
│ Suggestion: Please retry or contact support for help with service: Core Subnet
│ Documentation: https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_subnet
│ API Reference: https://docs.oracle.com/iaas/api/#/en/iaas/20160918/Subnet/GetSubnet
│ Request Target: GET https://iaas.eu-frankfurt-1.oraclecloud.com/20160918/subnets/ocid1.subnet.oc1.eu-frankfurt-1.aaaaaaaaox2hnp7cdh22ujrgkxphk3yp4qrusixsdkvzsj3shis4tz5xqn6q
│ Provider version: 5.46.0, released on 2024-06-12.
│ Service: Core Subnet
│ Operation Name: GetSubnet
│ OPC request ID: 5583dd94ae311060cae6c9fcadcff405/B608A5CDC9DDBBF1C775E2C9D5C3A9AB/DBE4A21DD859A1CBA8BADB18EBD66E45
│
│
│   with oci_core_subnet.test_subnet1,
│   on main.tf line 47, in resource "oci_core_subnet" "test_subnet1":
│   47: resource "oci_core_subnet" "test_subnet1" {
│
╵

Steps to Reproduce

  1. set user, fingerprint, tenancy, key_file as DEFAULT profile in ~/.oci/config
  2. do not provide these values in tfvars, they should be read from the DEFAULT profile
  3. terraform plan -input=false

Important Factoids

no, this is a general error for provider version >= 5.44.0 in lower version (the last one working fine is 5.43.0) provider reads credentials from DEFAULT profile

References

@xkoomy xkoomy added the bug label Jun 18, 2024
@tf-oci-pub
Copy link
Member

Thank you for reporting the issue. We observed the affected resources are not provided in the description or it's incorrect. We request you to add it in issue description as mentioned in below format.
Example: affected_resources = oci_core_instance , oci_core_instances

If it's not related to any particular resource then mention affected resource as terraform.
Example: affected_resources = terraform

As this works through automation, request you to follow exact syntax.

@tf-oci-pub tf-oci-pub added the awaiting-affected-resources Please Provide the affected resource name in description. ex. Affected resource - oci_core_instance label Jun 19, 2024
@xkoomy
Copy link
Author

xkoomy commented Jun 19, 2024

Affected Resource(s)
affected_resources = terraform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-affected-resources Please Provide the affected resource name in description. ex. Affected resource - oci_core_instance bug
Projects
None yet
Development

No branches or pull requests

2 participants