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.
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.
No requirements.
Name | Version |
---|---|
aws | n/a |
No modules.
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 |
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 |
Name | Description |
---|---|
cwlrolearn | n/a |
firehosearn | n/a |
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": "*"
}
]
})
}
Check out these related projects.
- terraform-aws-codebuild - Making a Build pipeline
Got a question?
File a GitHub issue.
Please use the issue tracker to report any bugs or file feature requests.
Copyright © 2019-2022 James Woolfenden
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.