Skip to content

Instantly share code, notes, and snippets.

@tschf
Last active October 5, 2020 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tschf/eccf56acb75731ea0b57e7ece440318f to your computer and use it in GitHub Desktop.
Save tschf/eccf56acb75731ea0b57e7ece440318f to your computer and use it in GitHub Desktop.
OCI instance principal request
package main
import (
"context"
"fmt"
"github.com/oracle/oci-go-sdk/common"
"github.com/oracle/oci-go-sdk/common/auth"
"github.com/oracle/oci-go-sdk/identity"
)
// Simple example of an OCI API Call in Go, using the instance principal
// configuration so we don't need to store API keys on the server from which this
// runs. It becomes dynamically based on the server running the example.
// Very much based on the example from API docs by Oracle, found here:
// https://github.com/oracle/oci-go-sdk/blob/master/example/example_instance_principals_test.go
func main() {
tenancyID := common.String("TODO_TENANCY_ID")
provider, _ := auth.InstancePrincipalConfigurationProvider()
request := identity.ListAvailabilityDomainsRequest{
CompartmentId: tenancyID,
}
client, _ := identity.NewIdentityClientWithConfigurationProvider(provider)
ADs, _ := client.ListAvailabilityDomains(context.Background(), request)
fmt.Printf("list of availability domains: %v\n", ADs.Items)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment