Skip to content

put_permission

put_permission(
    *,
    config_overrides: Optional[CloudWatchEventsClientConfig] = None,
    event_bus_name: Optional[NonPartnerEventBusName] = None,
    action: Optional[Action] = None,
    principal: Optional[Principal] = None,
    statement_id: Optional[StatementId] = None,
    condition: Optional[Condition] = None,
    policy: Optional[String] = None,
) -> None

Running PutPermission permits the specified Amazon Web Services account or Amazon Web Services organization to put events to the specified event bus. Amazon EventBridge (CloudWatch Events) rules in your account are triggered by these events arriving to an event bus in your account.

For another account to send events to your account, that external account must have an EventBridge rule with your account's event bus as a target.

To enable multiple Amazon Web Services accounts to put events to your event bus, run PutPermission once for each of these accounts. Or, if all the accounts are members of the same Amazon Web Services organization, you can run PutPermission once specifying Principal as "*" and specifying the Amazon Web Services organization ID in Condition, to grant permissions to all accounts in that organization.

If you grant permissions using an organization, then accounts in that organization must specify a RoleArn with proper permissions when they use PutTarget to add your account's event bus as a target. For more information, see Sending and Receiving Events Between Amazon Web Services Accounts in the Amazon EventBridge User Guide.

The permission policy on the event bus cannot exceed 10 KB in size.

Parameters:

  • event_bus_name (Optional[NonPartnerEventBusName], default: None ) –

    The name of the event bus associated with the rule. If you omit this, the default event bus is used.

  • action (Optional[Action], default: None ) –

    The action that you are enabling the other account to perform.

  • principal (Optional[Principal], default: None ) –

    The 12-digit Amazon Web Services account ID that you are permitting to put events to your default event bus. Specify "*" to permit any account to put events to your default event bus.

    If you specify "*" without specifying Condition, avoid creating rules that may match undesirable events. To create more secure rules, make sure that the event pattern for each rule contains an account field with a specific account ID from which to receive events. Rules with an account field do not match any events sent from other accounts.

  • statement_id (Optional[StatementId], default: None ) –

    An identifier string for the external account that you are granting permissions to. If you later want to revoke the permission for this external account, specify this StatementId when you run RemovePermission.

  • condition (Optional[Condition], default: None ) –

    This parameter enables you to limit the permission to accounts that fulfill a certain condition, such as being a member of a certain Amazon Web Services organization. For more information about Amazon Web Services Organizations, see What Is Amazon Web Services Organizations in the Amazon Web Services Organizations User Guide.

    If you specify Condition with an Amazon Web Services organization ID, and specify "*" as the value for Principal, you grant permission to all the accounts in the named organization.

    The Condition is a JSON string which must contain Type, Key, and Value fields.

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

    A JSON string that describes the permission policy statement. You can include a Policy parameter in the request instead of using the StatementId, Action, Principal, or Condition parameters.

Raises:

Source code in docs_src/capo_cloudwatch_events/_services/cloud_watch_events.py
def put_permission(
    self,
    *,
    config_overrides: Optional[CloudWatchEventsClientConfig] = None,
    event_bus_name: Optional[
        "capo_cloudwatch_events.types.non_partner_event_bus_name.NonPartnerEventBusName"
    ] = None,
    action: Optional["capo_cloudwatch_events.types.action.Action"] = None,
    principal: Optional["capo_cloudwatch_events.types.principal.Principal"] = None,
    statement_id: Optional[
        "capo_cloudwatch_events.types.statement_id.StatementId"
    ] = None,
    condition: Optional["capo_cloudwatch_events.types.condition.Condition"] = None,
    policy: Optional["capo_cloudwatch_events.types.string.String"] = None,
) -> None:
    """<p>Running <code>PutPermission</code> permits the specified Amazon Web Services account or Amazon Web Services organization to put events to the specified <i>event bus</i>. Amazon EventBridge (CloudWatch Events) rules in your account are triggered by these events arriving to an event bus in your account. </p> <p>For another account to send events to your account, that external account must have an EventBridge rule with your account's event bus as a target.</p> <p>To enable multiple Amazon Web Services accounts to put events to your event bus, run <code>PutPermission</code> once for each of these accounts. Or, if all the accounts are members of the same Amazon Web Services organization, you can run <code>PutPermission</code> once specifying <code>Principal</code> as "*" and specifying the Amazon Web Services organization ID in <code>Condition</code>, to grant permissions to all accounts in that organization.</p> <p>If you grant permissions using an organization, then accounts in that organization must specify a <code>RoleArn</code> with proper permissions when they use <code>PutTarget</code> to add your account's event bus as a target. For more information, see <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-cross-account-event-delivery.html">Sending and Receiving Events Between Amazon Web Services Accounts</a> in the <i>Amazon EventBridge User Guide</i>.</p> <p>The permission policy on the event bus cannot exceed 10 KB in size.</p>

    Args:
        event_bus_name: <p>The name of the event bus associated with the rule. If you omit this, the default event bus is used.</p>
        action: <p>The action that you are enabling the other account to perform.</p>
        principal: <p>The 12-digit Amazon Web Services account ID that you are permitting to put events to your default event bus. Specify "*" to permit any account to put events to your default event bus.</p> <p>If you specify "*" without specifying <code>Condition</code>, avoid creating rules that may match undesirable events. To create more secure rules, make sure that the event pattern for each rule contains an <code>account</code> field with a specific account ID from which to receive events. Rules with an account field do not match any events sent from other accounts.</p>
        statement_id: <p>An identifier string for the external account that you are granting permissions to. If you later want to revoke the permission for this external account, specify this <code>StatementId</code> when you run <a href="https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_RemovePermission.html">RemovePermission</a>.</p>
        condition: <p>This parameter enables you to limit the permission to accounts that fulfill a certain condition, such as being a member of a certain Amazon Web Services organization. For more information about Amazon Web Services Organizations, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html">What Is Amazon Web Services Organizations</a> in the <i>Amazon Web Services Organizations User Guide</i>.</p> <p>If you specify <code>Condition</code> with an Amazon Web Services organization ID, and specify "*" as the value for <code>Principal</code>, you grant permission to all the accounts in the named organization.</p> <p>The <code>Condition</code> is a JSON string which must contain <code>Type</code>, <code>Key</code>, and <code>Value</code> fields.</p>
        policy: <p>A JSON string that describes the permission policy statement. You can include a <code>Policy</code> parameter in the request instead of using the <code>StatementId</code>, <code>Action</code>, <code>Principal</code>, or <code>Condition</code> parameters.</p>

    Raises:
        capo_cloudwatch_events.errors.concurrent_modification_exception.ConcurrentModificationException: <p>There is concurrent modification on a rule, target, archive, or replay.</p>
        capo_cloudwatch_events.errors.internal_exception.InternalException: <p>This exception occurs due to unexpected causes.</p>
        capo_cloudwatch_events.errors.operation_disabled_exception.OperationDisabledException: <p>The operation you are attempting is not available in this region.</p>
        capo_cloudwatch_events.errors.policy_length_exceeded_exception.PolicyLengthExceededException: <p>The event bus policy is too long. For more information, see the limits.</p>
        capo_cloudwatch_events.errors.resource_not_found_exception.ResourceNotFoundException: <p>An entity that you specified does not exist.</p>
        capo_cloudwatch_events.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudwatch_events.types.put_permission_request.PutPermissionRequest]",
    ) -> OperationResponse[None]:
        import capo_cloudwatch_events._operations.aws_events.put_permission

        output, http_response = (
            capo_cloudwatch_events._operations.aws_events.put_permission.put_permission(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutPermission")
    )
    input_: capo_cloudwatch_events.types.put_permission_request.PutPermissionRequest = {}
    if event_bus_name is not None:
        input_["event_bus_name"] = event_bus_name
    if action is not None:
        input_["action"] = action
    if principal is not None:
        input_["principal"] = principal
    if statement_id is not None:
        input_["statement_id"] = statement_id
    if condition is not None:
        input_["condition"] = condition
    if policy is not None:
        input_["policy"] = policy

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