-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
231 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Kinesis Firehose: Kinesis Data Source To S3 | ||
|
||
Basic Configuration in this directory creates kinesis firehose stream with Kinesis Data Stream as source and S3 bucket as destination with a basic configuration. | ||
|
||
## Usage | ||
|
||
To run this example you need to execute: | ||
|
||
```bash | ||
$ terraform init | ||
$ terraform plan | ||
$ terraform apply | ||
``` | ||
|
||
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources. | ||
|
||
Can use the following command to send records to Kinesis Data Stream. | ||
|
||
```shell | ||
aws kinesis put-record \ | ||
--stream-name $(terraform output -json | jq -r .kinesis_data_stream_name.value) \ | ||
--cli-binary-format raw-in-base64-out \ | ||
--data '{"user_id":"user1", "score": 100}' \ | ||
--partition-key 1 | ||
``` | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 | | ||
| <a name="requirement_random"></a> [random](#requirement\_random) | ~> 3.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.0 | | ||
| <a name="provider_random"></a> [random](#provider\_random) | ~> 3.0 | | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_firehose"></a> [firehose](#module\_firehose) | ../../../ | n/a | | ||
| <a name="module_waf"></a> [waf](#module\_waf) | cloudposse/waf/aws | 1.2.0 | | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [aws_s3_bucket.s3](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | | ||
| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | Name prefix to use in resources | `string` | `"waf-to-s3"` | no | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
resource "random_pet" "this" { | ||
length = 2 | ||
} | ||
|
||
resource "aws_s3_bucket" "s3" { | ||
bucket = "${var.name_prefix}-destination-bucket-${random_pet.this.id}" | ||
force_destroy = true | ||
} | ||
|
||
module "waf" { | ||
source = "cloudposse/waf/aws" | ||
version = "1.2.0" | ||
|
||
log_destination_configs = [module.firehose.kinesis_firehose_arn] | ||
|
||
visibility_config = { | ||
cloudwatch_metrics_enabled = false | ||
metric_name = "rules-example-metric" | ||
sampled_requests_enabled = false | ||
} | ||
|
||
managed_rule_group_statement_rules = [ | ||
{ | ||
name = "AWS-AWSManagedRulesAdminProtectionRuleSet" | ||
priority = 1 | ||
|
||
statement = { | ||
name = "AWSManagedRulesAdminProtectionRuleSet" | ||
vendor_name = "AWS" | ||
} | ||
|
||
visibility_config = { | ||
cloudwatch_metrics_enabled = true | ||
sampled_requests_enabled = true | ||
metric_name = "AWS-AWSManagedRulesAdminProtectionRuleSet" | ||
} | ||
} | ||
] | ||
|
||
context = { | ||
enabled = true | ||
namespace = "test" | ||
tenant = null | ||
environment = null | ||
stage = null | ||
name = null | ||
delimiter = null | ||
attributes = [] | ||
tags = {} | ||
additional_tag_map = {} | ||
regex_replace_chars = null | ||
label_order = [] | ||
id_length_limit = null | ||
label_key_case = null | ||
label_value_case = null | ||
descriptor_formats = {} | ||
labels_as_tags = ["unset"] | ||
} | ||
} | ||
|
||
module "firehose" { | ||
source = "../../../" | ||
name = "${var.name_prefix}-delivery-stream" | ||
input_source = "waf" | ||
destination = "s3" | ||
s3_bucket_arn = aws_s3_bucket.s3.arn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#output "kinesis_firehose_arn" { | ||
# description = "The ARN of the Kinesis Firehose Stream" | ||
# value = module.firehose.kinesis_firehose_arn | ||
#} | ||
# | ||
#output "kinesis_data_stream_name" { | ||
# description = "The name of the Kinesis Firehose Stream" | ||
# value = module.firehose.kinesis_firehose_name | ||
#} | ||
# | ||
#output "kinesis_firehose_destination_id" { | ||
# description = "The Destination id of the Kinesis Firehose Stream" | ||
# value = module.firehose.kinesis_firehose_destination_id | ||
#} | ||
# | ||
#output "kinesis_firehose_version_id" { | ||
# description = "The Version id of the Kinesis Firehose Stream" | ||
# value = module.firehose.kinesis_firehose_version_id | ||
#} | ||
# | ||
#output "kinesis_firehose_role_arn" { | ||
# description = "The ARN of the IAM role created for Kinesis Firehose Stream" | ||
# value = module.firehose.kinesis_firehose_role_arn | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
variable "name_prefix" { | ||
description = "Name prefix to use in resources" | ||
type = string | ||
default = "waf-to-s3" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
terraform { | ||
required_version = ">= 0.13.1" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 5.0" | ||
} | ||
random = { | ||
source = "hashicorp/random" | ||
version = "~> 3.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters