-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3-logging.tf
74 lines (62 loc) · 2 KB
/
s3-logging.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# DataDog steaming logging is now supported directly by a block in terraform
# // Logging bucket and IAM user to submit
provider "aws" {
alias = "us_east_1"
region = "us-east-1"
profile = "maisonette"
}
# resource "aws_s3_bucket" "fastly_logs" {
# provider = aws.us_east_1 // co-locate with the datadog ingestion lambda
# bucket = "maisonette-fastly-logs-${var.environment}"
# acl = "private"
# tags = {
# Environment = var.environment
# }
# }
# locals {
# path = "/service-accounts/"
# }
# resource "aws_iam_user" "log_ingestion_sa" {
# name = "fastly-logs-ingestion-${var.environment}"
# path = local.path
# tags = {
# "automation" = "terraform"
# "Environment" = var.environment
# }
# }
# resource "aws_iam_access_key" "log_ingestion_sa" {
# user = aws_iam_user.log_ingestion_sa.name
# }
# // Allow user to write to bucket
# data "aws_iam_policy_document" "logs" {
# statement {
# actions = ["s3:PutObject"]
# resources = ["${aws_s3_bucket.fastly_logs.arn}/*"]
# }
# }
# resource "aws_iam_policy" "log_ingestion" {
# name = "fastly-logs-ingestion-s3-policy-${var.environment}"
# description = "Allow Fastly to write to the logs S3 bucket for ${var.environment}"
# path = local.path
# policy = data.aws_iam_policy_document.logs.json
# }
# resource "aws_iam_user_policy_attachment" "logs" {
# user = aws_iam_user.log_ingestion_sa.name
# policy_arn = aws_iam_policy.log_ingestion.arn
# }
# // Bucket to allow user to write to it
# resource "aws_s3_bucket_policy" "logs_bucket_side" {
# provider = aws.us_east_1 // co-locate with the datadog ingestion lambda
# bucket = aws_s3_bucket.fastly_logs.id
# policy = data.aws_iam_policy_document.logs_bucket_side.json
# }
# data "aws_iam_policy_document" "logs_bucket_side" {
# statement {
# actions = ["s3:PutObject"]
# resources = ["${aws_s3_bucket.fastly_logs.arn}/*"]
# principals {
# type = "AWS"
# identifiers = [aws_iam_user.log_ingestion_sa.arn]
# }
# }
# }