No description
  • Go 99.7%
  • Shell 0.2%
  • Makefile 0.1%
Find a file
oss-core-libraries-dashboard[bot] f88b18d185
[COMPLIANCE] Update Copyright and License Headers (#191)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2026-02-20 15:27:39 +05:30
application add attributes of for accs on oci 2018-09-04 09:29:25 -04:00
client add check for empty body 2018-09-01 09:32:29 -04:00
compute Merge pull request #187 from hashicorp/scross_allow_instance_name_paths 2020-04-08 11:05:55 -07:00
database Merge branch 'master' into f-exadata 2018-09-16 21:16:00 +01:00
helper Linting helper 2018-04-13 18:18:31 -06:00
java Updating java service instance 2019-03-20 15:41:04 -06:00
lbaas Adding tests for load balancer support 2018-12-01 23:05:57 -07:00
mysql Move subnet attribut e to correct location 2019-09-05 08:11:13 -07:00
opc Linted opc package 2018-04-13 18:25:08 -06:00
scripts - Fixed issue where delete service instance fails when called immediately after delete access rule 2018-04-15 22:35:16 +08:00
storage fix username format to work with IDCS Cloud Accounts 2018-09-04 16:49:25 -04:00
vendor update lbaas tests 2018-06-28 15:40:03 -04:00
.gitignore Initial commit 2017-03-29 16:16:57 +00:00
.gometalinter.json Fixing most metalinter issues 2018-04-10 12:51:18 -06:00
CHANGELOG.md Update CHANGELOG.md 2020-04-08 11:07:07 -07:00
GNUmakefile Adding support for updating service instance shape 2018-05-04 09:52:54 -06:00
LICENSE [COMPLIANCE] Update Copyright and License Headers (#191) 2026-02-20 15:27:39 +05:30
README.md update README.md 2018-07-31 14:44:28 -04:00

Oracle SDK for Terraform

Note: This SDK is not meant to be a comprehensive SDK for Oracle Cloud. This is meant to be used solely with Terraform.

OPC Config

To create the Oracle clients, a populated configuration struct is required. The config struct holds the following fields:

  • Username - (*string) The Username used to authenticate to Oracle Public Cloud.
  • Password - (*string) The Password used to authenticate to Oracle Public Cloud.
  • IdentityDomain - (*string) The identity domain for Oracle Public Cloud.
  • APIEndpoint - (*url.URL) The API Endpoint provided by Oracle Public Cloud.
  • LogLevel - (LogLevelType) Defaults to opc.LogOff, can be either opc.LogOff or opc.LogDebug.
  • Logger - (Logger) Must satisfy the generic Logger interface. Defaults to ioutil.Discard for the LogOff loglevel, and os.Stderr for the LogDebug loglevel.
  • HTTPClient - (*http.Client) Defaults to generic HTTP Client if unspecified.

Oracle Compute Client

The Oracle Compute Client requires an OPC Config object to be populated in order to create the client.

Full example to create an OPC Compute instance:

package main

import (
  "fmt"
  "net/url"
  "github.com/hashicorp/go-oracle-terraform/opc"
  "github.com/hashicorp/go-oracle-terraform/compute"
)

func main() {
  apiEndpoint, err := url.Parse("myAPIEndpoint")
  if err != nil {
    fmt.Errorf("Error parsing API Endpoint: %s", err)
  }

  config := &opc.Config{
    Username: opc.String("myusername"),
    Password: opc.String("mypassword"),
    IdentityDomain: opc.String("myidentitydomain"),
    APIEndpoint: apiEndpoint,
    LogLevel: opc.LogDebug,
    // Logger: # Leave blank to use the default logger, or provide your own
    // HTTPClient: # Leave blank to use default HTTP Client, or provider your own
  }
  // Create the Compute Client
  client, err := compute.NewComputeClient(config)
  if err != nil {
    fmt.Errorf("Error creating OPC Compute Client: %s", err)
  }
  // Create instances client
  instanceClient := client.Instances()

  // Instances Input
  input := &compute.CreateInstanceInput{
    Name: "test-instance",
    Label: "test",
    Shape: "oc3",
    ImageList: "/oracle/public/OL_7.2_UEKR4_x86_64",
    Storage: nil,
    BootOrder: nil,
    SSHKeys: []string{},
    Attributes: map[string]interface{}{},
  }

  // Create the instance
  instance, err := instanceClient.CreateInstance(input)
  if err != nil {
    fmt.Errorf("Error creating instance: %s", err)
  }
  fmt.Printf("Instance Created: %#v", instance)
}

Please refer to inline documentation for each resource that the compute client provides.

Running the SDK Integration Tests

To authenticate with the Oracle Compute Cloud the following credentials must be set in the following environment variables:

The Integration tests can be ran with the following command:

$ make testacc

Isolating a single SDK package can be done via the TEST environment variable

$ make testacc TEST=./compute

Isolating a single test within a package can be done via the TESTARGS environment variable

$ make testacc TEST=./compute TESTARGS='-run=TestAccIPAssociationLifeCycle'

Tests are ran with logs being sent to ioutil.Discard by default. Display debug logs inside of tests by setting the ORACLE_LOG environment variable to any value.