我正在尝试创建简单的 vcn,但出现此错误:
Post https://iaas.us-ashburn-1.oraclecloud.com/20160918/vcns: x509: certificate signed by unknown authority
details of vcn creation: { RawResponse=<nil> Vcn={ CidrBlock=<nil> CompartmentId=<nil> Id=<nil> LifecycleState= DefaultDhcpOptionsId=<nil> DefaultRouteTableId=<nil> DefaultSecurityListId=<nil> DefinedTags=map[] DisplayName=<nil> DnsLabel=<nil> FreeformTags=map[] TimeCreated=<nil> VcnDomainName=<nil> } Etag=<nil> OpcRequestId=<nil> }
我过去能够创建一个 vcn,但在最近的版本中却没有,我收到了这个错误。我当前的 $HOME/.oci/config 应该没问题,因为我可以使用 oci cli 和 terraform。这是我试图执行的代码。
package main
import (
"context"
"fmt"
"github.com/oracle/oci-go-sdk/common"
"github.com/oracle/oci-go-sdk/core"
"github.com/oracle/oci-go-sdk/identity"
)
func main() {
configProvider := common.DefaultConfigProvider()
response, err := createNetworkVCN(configProvider)
if err != nil {
fmt.Println(err)
}
fmt.Printf("details of vcn creation: %v", response)
return
}
func createNetworkVCN(configProvier common.ConfigurationProvider) (response core.CreateVcnResponse, err error) {
client, err := core.NewVirtualNetworkClientWithConfigurationProvider(configProvier)
if err != nil {
return response, err
}
ctx := context.Background()
request := core.CreateVcnRequest{}
request.CidrBlock = common.String("10.0.0.0/16")
request.CompartmentId = common.String("<redacted for security reasons>")
request.DisplayName = common.String("TestVCN")
request.DnsLabel = common.String("testDNS")
response, err = client.CreateVcn(ctx, request)
if err != nil {
return response, err
}
return response, err
}
请注意,我使用 dep 来维护 oci-go-sdk 包的 2.1.0 版本