【问题标题】:How to attach Real-time log to a Distribution in CloudFormation如何将实时日志附加到 CloudFormation 中的分发
【发布时间】:2021-07-14 09:18:27
【问题描述】:

我创建了一个实时日志记录配置。 但是,我找不到如何将它附加到 CloudFront 分配。 用于创建实时日志记录的 CloudFront 模板是:

KinesisDataStream:
Type: AWS::Kinesis::Stream
Properties:
  Name: my-stream
  RetentionPeriodHours: 24
  ShardCount: 1
RealTimeLogggingRole:
Type: AWS::IAM::Role
Properties:
  Tags:
    - Key: Name
      Value: my-role
  Path: "/"
  AssumeRolePolicyDocument:
    Version: 2012-10-17
    Statement:
      - Effect: Allow
        Action: sts:AssumeRole
        Principal:
          Service: cloudfront.amazonaws.com
  Policies:
    - PolicyName: po-real-time-logging-policy
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Action:
              - kinesis:DescribeStreamSummary
              - kinesis:DescribeStream
              - kinesis:PutRecord
              - kinesis:PutRecords
            Resource:
              - !GetAtt KinesisDataStream.Arn
RealTimeLoggging:
Type: AWS::CloudFront::RealtimeLogConfig
Properties:
  Name: my-logging
  SamplingRate: 100
  Fields:
    - timestamp
    - c-ip
    - cs-host
    - cs-uri-stem
    - cs-headers
  EndPoints:
    - StreamType: Kinesis
      KinesisStreamConfig:
        RoleArn: !GetAtt RealTimeLogggingRole.Arn
        StreamArn: !GetAtt KinesisDataStream.Arn
CloudFrontDistribution:
Type: AWS::CloudFront::Distribution
...

我可以将它附加到 GUI 上的发行版:

但我找不到如何使用 CloudFormation 执行此操作?

【问题讨论】:

  • 您提供的模板有什么问题?有什么错误吗?
  • 我提供的模板没有将实时日志附加到分发中。我需要使用 AWS 控制台手动附加它。
  • 进展如何?您是否设法设置日志记录?
  • 是的,它成功了!谢谢!

标签: amazon-cloudformation amazon-cloudfront


【解决方案1】:

您必须更新您的AWS::CloudFront::Distribution DefaultCacheBehavior 并设置RealtimeLogConfigArn

RealtimeLogConfigArn: !Ref RealTimeLoggging

【讨论】:

    猜你喜欢
    • 2019-11-20
    • 2020-10-30
    • 2019-03-09
    • 1970-01-01
    • 2017-12-05
    • 2021-04-04
    • 1970-01-01
    • 1970-01-01
    • 2017-04-25
    相关资源
    最近更新 更多