脚本正在分配IP,但我没有在GUI中看到安全规则。没有错误被抛出。这是我正在使用的代码段:
$config = aws_setup();
$ec2Client = \Aws\Ec2\Ec2Client::factory($config);
$gmodel = $ec2Client->allocateAddress();
$args = array('GroupName' => 'www', 'IpPermissions' => array(array('IpProtocol' => 'tcp', 'FromPort' => 22, 'ToPort' => 22)), 'IpRanges' => array('CidrIp' => array($gmodel->get('PublicIp') . '/32')));
$ec2Client->authorizeSecurityGroupIngress($args);
答案 0 :(得分:3)
获得'args'变量的正确语法:
$args = array('GroupName' => 'www', 'IpPermissions' => array(array('IpProtocol' => 'tcp', 'FromPort' => 22, 'ToPort' => 22, 'IpRanges' => array(array('CidrIp' => $gmodel->get('PublicIp') . '/32')))));
该规则现已添加到安全组中。