Last active
October 5, 2020 08:11
-
-
Save tschf/eccf56acb75731ea0b57e7ece440318f to your computer and use it in GitHub Desktop.
OCI instance principal request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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