在AWS中创建安全组时出错

时间:2015-10-04 04:06:24

标签: amazon-web-services amazon-ec2 aws-sdk

我正在创建安全组,并允许使用以下代码为所有ips打开TCP和HTTP的入站协议:

IpPermission ipPermission = new IpPermission();

        ipPermission.withIpRanges("0.0.0.0/0")
                        .withIpProtocol("tcp")
                        .withFromPort(22)
                        .withToPort(22);
        ipPermission.withIpRanges("0.0.0.0/0")
        .withIpProtocol("http")
        .withFromPort(80)
        .withToPort(80);
            AuthorizeSecurityGroupIngressRequest authorizeSecurityGroupIngressRequest =
                    new AuthorizeSecurityGroupIngressRequest();

                authorizeSecurityGroupIngressRequest.withGroupName("JavaSecurityGroup")
                                                    .withIpPermissions(ipPermission);
                amazonEC2Client.authorizeSecurityGroupIngress(authorizeSecurityGroupIngressRequest);

然而,它给了我以下错误: 无效的值' http'用于IP协议。未知协议

1 个答案:

答案 0 :(得分:3)