Skip to content

get_security_groups_for_vpc

get_security_groups_for_vpc(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    vpc_id: Optional[VpcId] = None,
    next_token: Optional[String] = None,
    max_results: Optional[GetSecurityGroupsForVpcRequestMaxResults] = None,
    filters: Optional[FilterList] = None,
    dry_run: Optional[Boolean] = None,
) -> GetSecurityGroupsForVpcResult

Gets security groups that can be associated by the Amazon Web Services account making the request with network interfaces in the specified VPC.

Parameters:

  • vpc_id (Optional[VpcId], default: None ) –

    The VPC ID where the security group can be used.

  • next_token (Optional[String], default: None ) –

    The token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.

  • max_results (Optional[GetSecurityGroupsForVpcRequestMaxResults], default: None ) –

    The maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see Pagination.

  • filters (Optional[FilterList], default: None ) –

    The filters. If using multiple filters, the results include security groups which match all filters.

    • group-id: The security group ID.

    • description: The security group's description.

    • group-name: The security group name.

    • owner-id: The security group owner ID.

    • primary-vpc-id: The VPC ID in which the security group was created.

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def get_security_groups_for_vpc(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    vpc_id: Optional["capo_ec2.types.vpc_id.VpcId"] = None,
    next_token: Optional["capo_ec2.types.string.String"] = None,
    max_results: Optional[
        "capo_ec2.types.get_security_groups_for_vpc_request_max_results.GetSecurityGroupsForVpcRequestMaxResults"
    ] = None,
    filters: Optional["capo_ec2.types.filter_list.FilterList"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.get_security_groups_for_vpc_result.GetSecurityGroupsForVpcResult":
    """<p>Gets security groups that can be associated by the Amazon Web Services account making the request with network interfaces in the specified VPC.</p>

    Args:
        vpc_id: <p>The VPC ID where the security group can be used.</p>
        next_token: <p>The token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.</p>
        max_results: <p>The maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Query-Requests.html#api-pagination">Pagination</a>.</p>
        filters: <p>The filters. If using multiple filters, the results include security groups which match all filters.</p> <ul> <li> <p> <code>group-id</code>: The security group ID.</p> </li> <li> <p> <code>description</code>: The security group's description.</p> </li> <li> <p> <code>group-name</code>: The security group name.</p> </li> <li> <p> <code>owner-id</code>: The security group owner ID.</p> </li> <li> <p> <code>primary-vpc-id</code>: The VPC ID in which the security group was created.</p> </li> </ul>
        dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.get_security_groups_for_vpc_request.GetSecurityGroupsForVpcRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.get_security_groups_for_vpc_result.GetSecurityGroupsForVpcResult"
    ]:
        import capo_ec2._operations.amazon_ec2.get_security_groups_for_vpc

        output, http_response = (
            capo_ec2._operations.amazon_ec2.get_security_groups_for_vpc.get_security_groups_for_vpc(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetSecurityGroupsForVpc")
    )
    input_: capo_ec2.types.get_security_groups_for_vpc_request.GetSecurityGroupsForVpcRequest = {}
    if vpc_id is not None:
        input_["vpc_id"] = vpc_id
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results
    if filters is not None:
        input_["filters"] = filters
    if dry_run is not None:
        input_["dry_run"] = dry_run

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output