Scalr\Service\Aws\Ec2\V20150415\Ec2Api::deleteSecurityGroup PHP 메소드

deleteSecurityGroup() 공개 메소드

Deletes a security group. This action applies to both EC2 security groups and VPC security groups. For information about VPC security groups and how they differ from EC2 security groups, see Security Groups in the Amazon Virtual Private Cloud User Guide. Note! If you attempt to delete a security group that contains instances, or attempt to delete a security group that is referenced by another security group, an error is returned. For example, if security group B has a rule that allows access from security group A, security group A cannot be deleted until the rule is removed. The fault returned is InvalidGroup.InUse for EC2 security groups, or DependencyViolation for VPC security groups.
public deleteSecurityGroup ( string $groupId = null, string $groupName = null ) : boolean
$groupId string optional The ID of the security group to remove.
$groupName string optional The name of security group to remove.
리턴 boolean Returns true on success or throws an exception.
    public function deleteSecurityGroup($groupId = null, $groupName = null)
    {
        $result = false;
        $options = [];
        if ($groupName === null && $groupId === null || $groupName !== null && $groupId !== null) {
            throw new \InvalidArgumentException(sprintf('Either groupName or groupId is required for the %s. ' . 'Also you cannot specify both in the same call.', __METHOD__));
        }
        if ($groupId !== null) {
            $options['GroupId'] = (string) $groupId;
        } else {
            if ($groupName !== null) {
                $options['GroupName'] = (string) $groupName;
            }
        }
        $response = $this->client->call(ucfirst(__FUNCTION__), $options);
        if ($response->getError() === false) {
            $result = true;
            $entity = null;
            if (!empty($options['GroupId'])) {
                $entity = $this->ec2->getEntityManagerEnabled() ? $this->ec2->securityGroup->get($options['GroupId']) : null;
            }
            if (isset($entity)) {
                $this->getEntityManager()->detach($entity);
            }
        }
        return $result;
    }
Ec2Api