You need to enable JavaScript to run this app.
导航
修改SNAT规则
最近更新时间:2023.09.04 20:14:33首次发布时间:2023.06.09 11:16:55

本文介绍如何修改SNAT规则。

示例代码

// Example Code generated by Beijing Volcanoengine Technology.

package natgatewayexample

import (
	"fmt"

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

func ModifySnatEntryAttributes() {
	// 设置您的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 := natgateway.New(sess)

	// 修改SNAT规则
	modifySnatEntryAttributesInput := &natgateway.ModifySnatEntryAttributesInput{
		EipId:       volcengine.String("eip-2feaac9wtccn459gp67qe****"),  // 修改后公网IP的ID
		SnatEntryId: volcengine.String("snat-2fedi096gdiww59gp680r****"), // SNAT规则的ID
	}

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

相关文档