Go 创建ec2安全组时不支持的协议方案
我正在尝试使用goamz创建安全组。 下面是我的代码Go 创建ec2安全组时不支持的协议方案,go,goamz,Go,Goamz,我正在尝试使用goamz创建安全组。 下面是我的代码 package main import ( "fmt" "os" "github.com/mitchellh/goamz/aws" "github.com/mitchellh/goamz/ec2" ) type SecurityGroup struct { Id string `xml:"groupId"` Name string `xml:"groupName"` Descri
package main
import (
"fmt"
"os"
"github.com/mitchellh/goamz/aws"
"github.com/mitchellh/goamz/ec2"
)
type SecurityGroup struct {
Id string `xml:"groupId"`
Name string `xml:"groupName"`
Description string `xml:"groupDescription"`
VpcId string `xml:"vpcId"`
}
func main() {
auth := aws.Auth{
AccessKey: os.Getenv("key"),
SecretKey: os.Getenv("secret"),
}
region := aws.Region{
Name : "us-east-1",
}
ec2conn := ec2.New(auth, region)
fmt.Printf("%+v\n", ec2conn)
resp, err := ec2conn.CreateSecurityGroup(ec2.SecurityGroup{Name: "testing12",
Description: "testing123", VpcId: "vpc-123456"})
fmt.Printf("%+v\n", resp)
if err != nil {
fmt.Printf("%s\n", err.Error())
}
}
我在执行时得到以下响应。
得到/?XXXXXXXXX
不支持的协议方案
我不确定我们是否明确使用任何协议来创建。
请帮助我理解这一点。我不使用goamz,因此无法确定是否正确,但从中,我认为您需要使用aws.Regions[us-east-1]。您在初始化区域结构时没有设置任何端点URL,因此出现了错误。@twotwotwo让我试试。@twotwotwo是正确的,您必须在s3.Region结构上分配不仅仅是Name属性。i、 e.地区:=aws.地区[us-east-1]或地区:=aws.USEAST。aws包已经预定义了这些区域结构。