2

该脚本正在分配 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);
4

1 回答 1

3

得到了 'args' 变量的正确语法:

$args = array('GroupName' => 'www', 'IpPermissions' => array(array('IpProtocol' => 'tcp', 'FromPort' => 22, 'ToPort' => 22, 'IpRanges' => array(array('CidrIp' => $gmodel->get('PublicIp') . '/32')))));

该规则现在被添加到安全组中。

于 2013-08-21T01:45:24.473 回答