Skip to content

create_transit_gateway_metering_policy_entry

create_transit_gateway_metering_policy_entry(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    transit_gateway_metering_policy_id: Optional[TransitGatewayMeteringPolicyId] = None,
    policy_rule_number: Optional[Integer] = None,
    source_transit_gateway_attachment_id: Optional[TransitGatewayAttachmentId] = None,
    source_transit_gateway_attachment_type: Optional[
        TransitGatewayAttachmentResourceType
    ] = None,
    source_cidr_block: Optional[String] = None,
    source_port_range: Optional[String] = None,
    destination_transit_gateway_attachment_id: Optional[
        TransitGatewayAttachmentId
    ] = None,
    destination_transit_gateway_attachment_type: Optional[
        TransitGatewayAttachmentResourceType
    ] = None,
    destination_cidr_block: Optional[String] = None,
    destination_port_range: Optional[String] = None,
    protocol: Optional[String] = None,
    metered_account: Optional[TransitGatewayMeteringPayerType] = None,
    dry_run: Optional[Boolean] = None,
) -> CreateTransitGatewayMeteringPolicyEntryResult

Creates an entry in a transit gateway metering policy to define traffic measurement rules.

Parameters:

  • transit_gateway_metering_policy_id (Optional[TransitGatewayMeteringPolicyId], default: None ) –

    The ID of the transit gateway metering policy to add the entry to.

  • policy_rule_number (Optional[Integer], default: None ) –

    The rule number for the metering policy entry. Rules are processed in order from lowest to highest number.

  • source_transit_gateway_attachment_id (Optional[TransitGatewayAttachmentId], default: None ) –

    The ID of the source transit gateway attachment for traffic matching.

  • source_transit_gateway_attachment_type (Optional[TransitGatewayAttachmentResourceType], default: None ) –

    The type of the source transit gateway attachment for traffic matching. Note that the tgw-peering resource type has been deprecated. To configure metering policies for Connect, use the transport attachment type.

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

    The source CIDR block for traffic matching.

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

    The source port range for traffic matching.

  • destination_transit_gateway_attachment_id (Optional[TransitGatewayAttachmentId], default: None ) –

    The ID of the destination transit gateway attachment for traffic matching.

  • destination_transit_gateway_attachment_type (Optional[TransitGatewayAttachmentResourceType], default: None ) –

    The type of the destination transit gateway attachment for traffic matching. Note that the tgw-peering resource type has been deprecated. To configure metering policies for Connect, use the transport attachment type.

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

    The destination CIDR block for traffic matching.

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

    The destination port range for traffic matching.

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

    The protocol for traffic matching (1, 6, 17, etc.).

  • metered_account (Optional[TransitGatewayMeteringPayerType], default: None ) –

    The Amazon Web Services account ID to which the metered traffic should be attributed.

  • 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 create_transit_gateway_metering_policy_entry(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    transit_gateway_metering_policy_id: Optional[
        "capo_ec2.types.transit_gateway_metering_policy_id.TransitGatewayMeteringPolicyId"
    ] = None,
    policy_rule_number: Optional["capo_ec2.types.integer.Integer"] = None,
    source_transit_gateway_attachment_id: Optional[
        "capo_ec2.types.transit_gateway_attachment_id.TransitGatewayAttachmentId"
    ] = None,
    source_transit_gateway_attachment_type: Optional[
        "capo_ec2.types.transit_gateway_attachment_resource_type.TransitGatewayAttachmentResourceType"
    ] = None,
    source_cidr_block: Optional["capo_ec2.types.string.String"] = None,
    source_port_range: Optional["capo_ec2.types.string.String"] = None,
    destination_transit_gateway_attachment_id: Optional[
        "capo_ec2.types.transit_gateway_attachment_id.TransitGatewayAttachmentId"
    ] = None,
    destination_transit_gateway_attachment_type: Optional[
        "capo_ec2.types.transit_gateway_attachment_resource_type.TransitGatewayAttachmentResourceType"
    ] = None,
    destination_cidr_block: Optional["capo_ec2.types.string.String"] = None,
    destination_port_range: Optional["capo_ec2.types.string.String"] = None,
    protocol: Optional["capo_ec2.types.string.String"] = None,
    metered_account: Optional[
        "capo_ec2.types.transit_gateway_metering_payer_type.TransitGatewayMeteringPayerType"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.create_transit_gateway_metering_policy_entry_result.CreateTransitGatewayMeteringPolicyEntryResult":
    """<p>Creates an entry in a transit gateway metering policy to define traffic measurement rules.</p>

    Args:
        transit_gateway_metering_policy_id: <p>The ID of the transit gateway metering policy to add the entry to.</p>
        policy_rule_number: <p>The rule number for the metering policy entry. Rules are processed in order from lowest to highest number.</p>
        source_transit_gateway_attachment_id: <p>The ID of the source transit gateway attachment for traffic matching.</p>
        source_transit_gateway_attachment_type: <p>The type of the source transit gateway attachment for traffic matching. Note that the <code>tgw-peering</code> resource type has been deprecated. To configure metering policies for Connect, use the transport attachment type.</p>
        source_cidr_block: <p>The source CIDR block for traffic matching.</p>
        source_port_range: <p>The source port range for traffic matching.</p>
        destination_transit_gateway_attachment_id: <p>The ID of the destination transit gateway attachment for traffic matching.</p>
        destination_transit_gateway_attachment_type: <p>The type of the destination transit gateway attachment for traffic matching. Note that the <code>tgw-peering</code> resource type has been deprecated. To configure metering policies for Connect, use the transport attachment type.</p>
        destination_cidr_block: <p>The destination CIDR block for traffic matching.</p>
        destination_port_range: <p>The destination port range for traffic matching.</p>
        protocol: <p>The protocol for traffic matching (1, 6, 17, etc.).</p>
        metered_account: <p>The Amazon Web Services account ID to which the metered traffic should be attributed.</p>
        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.create_transit_gateway_metering_policy_entry_request.CreateTransitGatewayMeteringPolicyEntryRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.create_transit_gateway_metering_policy_entry_result.CreateTransitGatewayMeteringPolicyEntryResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_transit_gateway_metering_policy_entry

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

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateTransitGatewayMeteringPolicyEntry"),
    )
    input_: capo_ec2.types.create_transit_gateway_metering_policy_entry_request.CreateTransitGatewayMeteringPolicyEntryRequest = {}
    if transit_gateway_metering_policy_id is not None:
        input_["transit_gateway_metering_policy_id"] = (
            transit_gateway_metering_policy_id
        )
    if policy_rule_number is not None:
        input_["policy_rule_number"] = policy_rule_number
    if source_transit_gateway_attachment_id is not None:
        input_["source_transit_gateway_attachment_id"] = (
            source_transit_gateway_attachment_id
        )
    if source_transit_gateway_attachment_type is not None:
        input_["source_transit_gateway_attachment_type"] = (
            source_transit_gateway_attachment_type
        )
    if source_cidr_block is not None:
        input_["source_cidr_block"] = source_cidr_block
    if source_port_range is not None:
        input_["source_port_range"] = source_port_range
    if destination_transit_gateway_attachment_id is not None:
        input_["destination_transit_gateway_attachment_id"] = (
            destination_transit_gateway_attachment_id
        )
    if destination_transit_gateway_attachment_type is not None:
        input_["destination_transit_gateway_attachment_type"] = (
            destination_transit_gateway_attachment_type
        )
    if destination_cidr_block is not None:
        input_["destination_cidr_block"] = destination_cidr_block
    if destination_port_range is not None:
        input_["destination_port_range"] = destination_port_range
    if protocol is not None:
        input_["protocol"] = protocol
    if metered_account is not None:
        input_["metered_account"] = metered_account
    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