You need to enable JavaScript to run this app.
导航

查询IPsec连接

最近更新时间2023.07.05 15:21:25

首次发布时间2023.07.05 15:21:25

本文介绍如何查询IPsec连接。

示例代码

package vpnexample

import (
	"fmt"

	"github.com/volcengine/volcengine-go-sdk/service/vpn"
	"github.com/volcengine/volcengine-go-sdk/volcengine"
	"github.com/volcengine/volcengine-go-sdk/volcengine/credentials"
	"github.com/volcengine/volcengine-go-sdk/volcengine/session"
)

func DescribeVpnConnectionAttributes() {
	// 设置您的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 := vpn.New(sess)
	// 查询IPsec连接。
	describeVpnConnectionAttributesInput := &vpn.DescribeVpnConnectionAttributesInput{
		VpnConnectionId: volcengine.String("vgc-2bzvqi8kerd342dx0eg2f****"), // 待查询IPsec连接的ID。
	}

	// 发起请求并处理返回或异常。
	resp, err := svc.DescribeVpnConnectionAttributes(describeVpnConnectionAttributesInput)
	if err != nil {
		panic(err)
	}
	fmt.Println(resp)
}

相关文档