本文介绍如何创建一台NAT网关。
// 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 CreateNatGateway() { // 设置您的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) // 创建NAT网关 createNatGatewayInput := &natgateway.CreateNatGatewayInput{ Spec: volcengine.String("Small"), // NAT网关的规格 SubnetId: volcengine.String("subnet-2feypga30rgg059gp67ag****"), // NAT网关所属子网的ID VpcId: volcengine.String("vpc-2feypfmenesqo59gp67yz****"), // NAT网关所属VPC的ID } // 发起请求并处理返回或异常 resp, err := svc.CreateNatGateway(createNatGatewayInput) if err != nil { panic(err) } fmt.Println(resp) }