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

删除安全组

最近更新时间2023.08.29 17:05:35

首次发布时间2023.06.09 11:20:33

本文介绍如何删除安全组。

示例代码

// Example Code generated by Beijing Volcanoengine Technology.

package vpcexample

import (
	"fmt"

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

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

	// 删除安全组规则
	deleteSecurityGroupInput := &vpc.DeleteSecurityGroupInput{
		SecurityGroupId: volcengine.String("sg-bp1fg655nh68xyz9****"), // 安全组的ID
	}

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

相关文档