代码之家  ›  专栏  ›  技术社区  ›  Andremoniy

我可以从另一个帐户将CloudWatch日志组流式传输到lambda吗?

  •  3
  • Andremoniy  · 技术社区  · 7 年前

    我可以从另一个帐户将CloudWatch日志组流式传输到lambda吗?我试图从AWS控制台进行配置,但它只显示了当前帐户中的lambda。

    提示: 我不感兴趣 在亚马逊运动解决方案中。我知道如何通过订阅实现这一点,如下所述: http://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CrossAccountSubscriptions.html

    我从另一个账户确切地询问了lambda的情况。

    P、 如前所述,我试图从另一个帐户将日志组上的订阅添加到lambda here ,但我收到以下错误:

    调用时出错(AccessDeniedException) PutSubscriptionFilter
    操作:不允许跨帐户lambda调用传递。你 必须使用DestinationPolicys 创建跨帐户lambda触发器。

    2 回复  |  直到 5 年前
        1
  •  1
  •   Erik    4 年前

    目前没有。这包括使用CloudWatch日志目标

    的限制 PutSubscriptionFilter 此处有更详细的记录: https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutSubscriptionFilter.html

    CloudWatch日志仅支持将日志数据流式传输到同一帐户中的Lambda函数,尽管错误消息不明确,似乎表明它 可以 是可能的。

    我怀疑错误消息:

    您必须使用DestinationPolicys来创建跨帐户lambda触发器。

    或者,您可能会尝试使用CloudWatch日志目标发送到Lambda函数,但是,目标仅支持动态。

    AWS最接近记录这一点的地方是: https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDestination.html

    关于目标ARN,如下所示:

    Amazon Kinesis流的ARN,用于向其交付匹配的日志事件。

    尽管如此,我还是有可能遵循这些原则 instructions ,用Lambda函数代替运动流,在最后一步遇到了这个错误,我无法解决。

    $ aws logs put-destination --destination-name "testDestination" --target-arn "arn:aws:lambda:us-east-1:<YOUR ACCOUNT ID HERE>:function:destinationtest" --role-arn "arn:aws:iam::<YOUR ACCOUNT ID HERE>:role/CWLtoLambdaRole"
    
    An error occurred (InvalidParameterException) when calling the PutDestination operation: Could not deliver test message to specified destination. Check if the destination is valid.
    

    综上所述,我不得不得出结论,对于跨帐户直接将Lambda函数连接到CloudWatch日志,答案仍然是否定的。然而,您可以使用单独帐户中的运动流作为目的地,然后可以非常轻松地向其订阅Lambda函数。

        2
  •  -1
  •   zeus1234    4 年前

    现在似乎有可能?

    从文档中:

    destinationArn
    The ARN of the destination to deliver matching log events to. Currently, the supported destinations are:
    
    A logical destination (specified using an ARN) belonging to a different account, for cross-account delivery.