找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 171|回复: 0

[AWS]配置Cloudwatch导出日志到S3 bucket上

[复制链接]

13

主题

0

回帖

58

积分

版主

积分
58
发表于 2023-5-5 12:04:39 | 显示全部楼层 |阅读模式
需要在要导出到的S3 bucket上面修改存储桶策略。将下面的这段代码配置到存储桶策略上,并做相应的修改,其中region跟bucket的名字都需要修改,并且cloudwatch导出日志的时候,只能往同一个区域的AWS s3 bucket上面导出日志,跨区域是无法导出日志的。
  1. {
  2.     "Version": "2012-10-17",
  3.     "Statement": [
  4.         {
  5.             "Sid": "1",
  6.             "Effect": "Allow",
  7.             "Principal": {
  8.                 "Service": "logs.eu-west-2.amazonaws.com"
  9.             },
  10.             "Action": "s3:GetBucketAcl",
  11.             "Resource": "arn:aws:s3:::newone-log"
  12.         },
  13.         {
  14.             "Sid": "2",
  15.             "Effect": "Allow",
  16.             "Principal": {
  17.                 "Service": "logs.eu-west-2.amazonaws.com"
  18.             },
  19.             "Action": "s3:PutObject",
  20.             "Resource": "arn:aws:s3:::newone-log/*",
  21.             "Condition": {
  22.                 "StringEquals": {
  23.                     "s3:x-amz-acl": "bucket-owner-full-control"
  24.                 }
  25.             }
  26.         },
  27.         {
  28.             "Sid": "AWSLogDeliveryWrite",
  29.             "Effect": "Allow",
  30.             "Principal": {
  31.                 "Service": "delivery.logs.amazonaws.com"
  32.             },
  33.             "Action": "s3:PutObject",
  34.             "Resource": "arn:aws:s3:::newone-log/AWSLogs/579228855639/*",
  35.             "Condition": {
  36.                 "StringEquals": {
  37.                     "s3:x-amz-acl": "bucket-owner-full-control"
  38.                 }
  39.             }
  40.         },
  41.         {
  42.             "Sid": "AWSLogDeliveryAclCheck",
  43.             "Effect": "Allow",
  44.             "Principal": {
  45.                 "Service": "delivery.logs.amazonaws.com"
  46.             },
  47.             "Action": "s3:GetBucketAcl",
  48.             "Resource": "arn:aws:s3:::newone-log"
  49.         }
  50.     ]
  51. }
复制代码


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Sobey-IBG-BBS

GMT+8, 2025-12-6 14:29 , Processed in 0.017698 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表