本文介绍如何创建虚拟接口。
// Example Code generated by Beijing Volcanoengine Technology. package directconnectemample import ( "fmt" "github.com/volcengine/volcengine-go-sdk/service/directconnect" "github.com/volcengine/volcengine-go-sdk/volcengine" "github.com/volcengine/volcengine-go-sdk/volcengine/credentials" "github.com/volcengine/volcengine-go-sdk/volcengine/session" ) func CreateDirectConnectVirtualInterface() { // 设置您的AK、SK和要访问的地域。 ak, sk, region := "Your AK", "Your SK", "Region" config := volcengine.NewConfig(). WithRegion(region). WithCredentials(credentials.NewStaticCredentials(ak, sk, "")) sess, err := session.NewSession(config) if err != nil { panic(err) } svc := directconnect.New(sess) // 创建虚拟接口。 createDirectConnectVirtualInterfaceInput := &directconnect.CreateDirectConnectVirtualInterfaceInput{ Description: volcengine.String("test"), // 设置虚拟接口的描述。 DirectConnectConnectionId: volcengine.String("dcc-2fe3zsmkshs59g****"), // 设置虚拟接口关联的物理专线的ID。 DirectConnectGatewayId: volcengine.String("dcg-7qthudw0ll6jmc****"), // 设置虚拟接口关联的专线网关的ID。 LocalIp: volcengine.String("192.XX.XX.10/24"), // 设置虚拟接口的本端网关互联IP地址。 PeerIp: volcengine.String("192.XX.XX.20/24"), // 设置虚拟接口的对端网关互联IP地址。 VirtualInterfaceName: volcengine.String("test"), // 设置虚拟接口的名称。 VlanId: volcengine.Int64(2000), // 设置用于连接本地IDC的VLAN ID,请确保此VLAN ID未被占用。 } // 发起请求并处理返回或异常。 resp, err := svc.CreateDirectConnectVirtualInterface(createDirectConnectVirtualInterfaceInput) if err != nil { panic(err) } fmt.Println(resp) }