r0b2g1t/k3s-cluster-on-oracle-cloud-infrastructure

Error: 404;NotAuthorizedOrNotFound - caused by hard-coded compute image IDs in the wrong region

raffraffraff opened this issue · 1 comments

A terraform apply throws this error:

│ Error: 404-NotAuthorizedOrNotFound, Authorization failed or requested resource not found.
│ Suggestion: Either the resource has been deleted or service Core Instance need policy to access this resource. Policy reference: https://docs.oracle.com/en-us/iaas/Content/Identity/Reference/policyreference.htm
│ Documentation: https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_instance 
│ API Reference: https://docs.oracle.com/iaas/api/#/en/iaas/20160918/Instance/LaunchInstance 
│ Request Target: POST https://iaas.eu-amsterdam-1.oraclecloud.com/20160918/instances 
│ Provider version: 4.119.0, released on 2023-05-03.  
│ Service: Core Instance 
│ Operation Name: LaunchInstance 
│ OPC request ID: 74975954df7e642d81de039b4c702ba1/380DB4D8255D882C2E7CABB029A00BAF/93E0CE782AD76D87AF42585D88D0D369 
│ 
│ 
│   with module.compute.oci_core_instance.server_0,
│   on compute/main.tf line 1, in resource "oci_core_instance" "server_0":
│    1: resource "oci_core_instance" "server_0" {

Suggestion: instead of hard-coded into a locals section in the variables.tf file, use a data lookup using the correct region / shape.

Workaround: If anyone else is using the eu-amsterdam-1 region you can use these:

    // Canonical-Ubuntu-22.04-Minimal-aarch64-2023.04.18-0 eu-amsterdam-1
    source_id   = "ocid1.image.oc1.eu-amsterdam-1.aaaaaaaa4yojwha4rdsnagwul4ncgy45lx7q2g3pd5ru2io6rsx6pog35mfq"
    // Canonical-Ubuntu-20.04-Minimal-2023.04.19-0 eu-amsterdam-1
    source_id   = "ocid1.image.oc1.eu-amsterdam-1.aaaaaaaaml7w5cdrj2fzoa7yaaa4ynymkolvshyz3cc4rbxymk52kcwxt6ma"

If you're in another region, use the oci command to look them. You'll need your compartment ID.

oci compute image list --shape "VM.Standard.E2.1.Micro" --compartment-id ${YOUR_COMPARTMENT_ID}

Interesting idea do you like to create PR with the changes?