Skip to content

lum-ai/terraform-aws-cloudwatch-s3

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-aws-cloudwatch-s3

Build Status Latest Release GitHub tag (latest SemVer) Terraform Version Infrastructure Tests pre-commit checkov Infrastructure Tests

Terraform module to provision infra that collates cloudwatch data into an s3 data lake cloudwatch.


This project 100% Open Source and licensed under the APACHE2.

Usage

Include this repository as a module in your existing Terraform code:

module "cloudwatch-s3" {
  source                 = "jameswoolfenden/aws/cloudwatch-s3"
  version                = "v0.2.20"
  cloudwatch_stream_name = var.cloudwatch_stream_name
  log_bucket             = var.log_bucket
  region_desc            = var.region_desc
  filter_pattern         = var.filter_pattern
  log_group_name         = aws_cloudwatch_log_group.example.name
  kms_master_key_id      = aws_kms_key.example.arn
}

The see folder example/examplea for a worked example.

Requirements

No requirements.

Providers

Name Version
aws n/a

Modules

No modules.

Resources

Name Type
aws_cloudwatch_log_subscription_filter.filters resource
aws_iam_role.cwl resource
aws_iam_role.firehosetos3 resource
aws_iam_role_policy.permissionsforcwl resource
aws_iam_role_policy.permissionsforfirehose resource
aws_kinesis_firehose_delivery_stream.extended_s3_stream resource
aws_s3_bucket.log_bucket resource
aws_s3_bucket_acl.log_bucket resource
aws_s3_bucket_logging.name resource
aws_s3_bucket_policy.log_bucket_policy resource
aws_s3_bucket_public_access_block.bucket resource
aws_s3_bucket_server_side_encryption_configuration.log_bucket resource
aws_s3_bucket_versioning.log_bucket resource
aws_caller_identity.current data source
aws_iam_policy_document.cloudwatch data source
aws_iam_policy_document.firehose data source
aws_region.current data source

Inputs

Name Description Type Default Required
cloudwatch_stream_name n/a string n/a yes
filter_pattern description string n/a yes
kms_master_key_id The KMS key id to use for Encryption string n/a yes
log_bucket n/a string n/a yes
log_bucket_logging Access bucket logging. string n/a yes
log_bucket_mfa_delete If you set this as the default its going to make it hard to delete string "Disabled" no
log_group_name A log group to stream list(any) n/a yes
region_desc A string used to help name stuff doesnt have to be a region string n/a yes
server_side_encryption Encrypt at rest bool true no
sse_algorithm The Encryption algorithm to use string "aws:kms" no

Outputs

Name Description
cwlrolearn n/a
firehosearn n/a

Policy

This is the policy required to build this project:

The Terraform resource required is:

resource "aws_iam_policy" "terraform_pike" {
  name_prefix = "terraform_pike"
  path        = "/"
  description = "Pike Autogenerated policy from IAC"

  policy = jsonencode({
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "firehose:CreateDeliveryStream",
                "firehose:DeleteDeliveryStream",
                "firehose:DescribeDeliveryStream",
                "firehose:ListTagsForDeliveryStream"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "iam:CreateRole",
                "iam:DeleteRole",
                "iam:DeleteRolePolicy",
                "iam:GetRole",
                "iam:GetRolePolicy",
                "iam:ListAttachedRolePolicies",
                "iam:ListInstanceProfilesForRole",
                "iam:ListRolePolicies",
                "iam:PassRole",
                "iam:PutRolePolicy"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor2",
            "Effect": "Allow",
            "Action": [
                "logs:DeleteSubscriptionFilter",
                "logs:DescribeSubscriptionFilters",
                "logs:PutSubscriptionFilter"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor3",
            "Effect": "Allow",
            "Action": [
                "s3:CreateBucket",
                "s3:DeleteBucket",
                "s3:GetAccelerateConfiguration",
                "s3:GetBucketAcl",
                "s3:GetBucketCORS",
                "s3:GetBucketLogging",
                "s3:GetBucketObjectLockConfiguration",
                "s3:GetBucketPolicy",
                "s3:GetBucketPublicAccessBlock",
                "s3:GetBucketRequestPayment",
                "s3:GetBucketTagging",
                "s3:GetBucketVersioning",
                "s3:GetBucketWebsite",
                "s3:GetEncryptionConfiguration",
                "s3:GetLifecycleConfiguration",
                "s3:GetObject",
                "s3:GetObjectAcl",
                "s3:GetReplicationConfiguration",
                "s3:ListAllMyBuckets",
                "s3:ListBucket",
                "s3:PutBucketAcl",
                "s3:PutBucketLogging",
                "s3:PutBucketPolicy",
                "s3:PutBucketPublicAccessBlock",
                "s3:PutBucketVersioning",
                "s3:PutEncryptionConfiguration"
            ],
            "Resource": "*"
        }
    ]
})
}

Related Projects

Check out these related projects.

Help

Got a question?

File a GitHub issue.

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Copyrights

Copyright © 2019-2022 James Woolfenden

License

License

See LICENSE for full details.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contributors

James Woolfenden
James Woolfenden

Releases

No releases published

Packages

No packages published

Languages

  • HCL 66.9%
  • Makefile 16.2%
  • Python 12.5%
  • PowerShell 2.7%
  • Shell 1.7%