Skip to content

Commit c27813f

Browse files
authored
readme updated, BridgeCrew compliance checks fixed (#25)
* readme updated, BridgeCrew compliance checks fixed * tags added for resources
1 parent 7892318 commit c27813f

File tree

11 files changed

+647
-2
lines changed

11 files changed

+647
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# .tfstate files
55
*.tfstate
66
*.tfstate.*
7+
**/.terraform.lock.hcl
8+
9+
test.log
710

811
**/node_modules/*
912
**/package-lock.json

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ Available targets:
184184

185185
| Name | Description | Type | Default | Required |
186186
|------|-------------|------|---------|:--------:|
187+
| access\_log\_bucket\_name | Name of the S3 bucket where s3 access log will be sent to | `string` | `""` | no |
187188
| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no |
188189
| artifact\_filename | Artifact filename | `string` | `"lambda.zip"` | no |
189190
| artifact\_url | URL template for the remote artifact | `string` | `"https://artifacts.cloudposse.com/$${module_name}/$${git_ref}/$${filename}"` | no |
@@ -197,14 +198,18 @@ Available targets:
197198
| id\_length\_limit | Limit `id` to this many characters.<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
198199
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
199200
| lambda\_runtime | Lambda runtime | `string` | `"nodejs12.x"` | no |
201+
| mfa\_delete | A boolean that indicates that versions of S3 objects can only be deleted with MFA. ( Terraform cannot apply changes of this value; https://github.com/terraform-providers/terraform-provider-aws/issues/629 ) | `bool` | `true` | no |
200202
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
201203
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
202204
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
203205
| region | AWS Region the SES should reside in | `string` | n/a | yes |
204206
| relay\_email | Email that used to relay from | `string` | n/a | yes |
207+
| s3\_bucket\_encryption\_enabled | When set to 'true' the 'aws\_s3\_bucket' resource will have AES256 encryption enabled by default | `bool` | `true` | no |
205208
| spf | DNS SPF record value | `string` | `"v=spf1 include:amazonses.com -all"` | no |
206209
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
207210
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
211+
| tracing\_config\_mode | Can be either PassThrough or Active. If PassThrough, Lambda will only trace the request from an upstream service if it contains a tracing header with 'sampled=1'. If Active, Lambda will respect any tracing header it receives from an upstream service. | `string` | `"PassThrough"` | no |
212+
| versioning\_enabled | A state of versioning. Versioning is a means of keeping multiple variants of an object in the same bucket | `bool` | `true` | no |
208213

209214
## Outputs
210215

@@ -311,7 +316,7 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
311316

312317
## Copyright
313318

314-
Copyright © 2017-2020 [Cloud Posse, LLC](https://cpco.io/copyright)
319+
Copyright © 2017-2021 [Cloud Posse, LLC](https://cpco.io/copyright)
315320

316321

317322

docs/terraform.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
| Name | Description | Type | Default | Required |
2121
|------|-------------|------|---------|:--------:|
22+
| access\_log\_bucket\_name | Name of the S3 bucket where s3 access log will be sent to | `string` | `""` | no |
2223
| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no |
2324
| artifact\_filename | Artifact filename | `string` | `"lambda.zip"` | no |
2425
| artifact\_url | URL template for the remote artifact | `string` | `"https://artifacts.cloudposse.com/$${module_name}/$${git_ref}/$${filename}"` | no |
@@ -32,14 +33,18 @@
3233
| id\_length\_limit | Limit `id` to this many characters.<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
3334
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
3435
| lambda\_runtime | Lambda runtime | `string` | `"nodejs12.x"` | no |
36+
| mfa\_delete | A boolean that indicates that versions of S3 objects can only be deleted with MFA. ( Terraform cannot apply changes of this value; https://github.com/terraform-providers/terraform-provider-aws/issues/629 ) | `bool` | `true` | no |
3537
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
3638
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
3739
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
3840
| region | AWS Region the SES should reside in | `string` | n/a | yes |
3941
| relay\_email | Email that used to relay from | `string` | n/a | yes |
42+
| s3\_bucket\_encryption\_enabled | When set to 'true' the 'aws\_s3\_bucket' resource will have AES256 encryption enabled by default | `bool` | `true` | no |
4043
| spf | DNS SPF record value | `string` | `"v=spf1 include:amazonses.com -all"` | no |
4144
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
4245
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
46+
| tracing\_config\_mode | Can be either PassThrough or Active. If PassThrough, Lambda will only trace the request from an upstream service if it contains a tracing header with 'sampled=1'. If Active, Lambda will respect any tracing header it receives from an upstream service. | `string` | `"PassThrough"` | no |
47+
| versioning\_enabled | A state of versioning. Versioning is a means of keeping multiple variants of an object in the same bucket | `bool` | `true` | no |
4348

4449
## Outputs
4550

examples/complete/fixtures.us-east-1.tfvars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ lambda_runtime = "nodejs12.x"
2323
artifact_url = "https://artifacts.cloudposse.com/terraform-external-module-artifact/example/test.zip"
2424

2525
artifact_filename = "lambda.zip"
26+
27+
mfa_delete = false

examples/complete/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module "ses_lambda_forwarder" {
1616

1717
artifact_url = var.artifact_url
1818
artifact_filename = var.artifact_filename
19+
mfa_delete = var.mfa_delete
1920

2021
context = module.this.context
2122
}

examples/complete/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,8 @@ variable "artifact_filename" {
3737
type = string
3838
description = "Artifact filename"
3939
}
40+
41+
variable "mfa_delete" {
42+
type = bool
43+
description = "A boolean that indicates that versions of S3 objects can only be deleted with MFA. ( Terraform cannot apply changes of this value; https://github.com/terraform-providers/terraform-provider-aws/issues/629 )"
44+
}

lambda.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ data "aws_iam_policy_document" "assume" {
1616
resource "aws_iam_role" "lambda" {
1717
name = module.this.id
1818
assume_role_policy = data.aws_iam_policy_document.assume.json
19+
tags = module.this.tags
1920
}
2021

2122
data "aws_iam_policy_document" "lambda" {
@@ -81,6 +82,7 @@ resource "aws_lambda_function" "default" {
8182
handler = "index.handler"
8283
source_code_hash = module.artifact.base64sha256
8384
runtime = var.lambda_runtime
85+
tags = module.this.tags
8486

8587
environment {
8688
variables = {
@@ -90,6 +92,10 @@ resource "aws_lambda_function" "default" {
9092
EMAIL_MAPPING = jsonencode(var.forward_emails)
9193
}
9294
}
95+
96+
tracing_config {
97+
mode = var.tracing_config_mode
98+
}
9399
}
94100

95101
resource "aws_lambda_alias" "default" {

s3.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,35 @@
11
resource "aws_s3_bucket" "default" {
2+
#bridgecrew:skip=BC_AWS_S3_13:Skipping `Enable S3 Bucket Logging` check until bridgecrew will support dynamic blocks (https://github.com/bridgecrewio/checkov/issues/776).
3+
#bridgecrew:skip=BC_AWS_S3_14:Skipping `Ensure all data stored in the S3 bucket is securely encrypted at rest` check until bridgecrew will support dynamic blocks (https://github.com/bridgecrewio/checkov/issues/776).
24
bucket = module.this.id
35
region = var.region
46
force_destroy = true
57

8+
versioning {
9+
enabled = var.versioning_enabled
10+
mfa_delete = var.mfa_delete
11+
}
12+
13+
dynamic "logging" {
14+
for_each = var.access_log_bucket_name != "" ? [1] : []
15+
content {
16+
target_bucket = var.access_log_bucket_name
17+
target_prefix = "logs/${module.this.id}/"
18+
}
19+
}
20+
21+
dynamic "server_side_encryption_configuration" {
22+
for_each = var.s3_bucket_encryption_enabled ? [1] : []
23+
24+
content {
25+
rule {
26+
apply_server_side_encryption_by_default {
27+
sse_algorithm = "AES256"
28+
}
29+
}
30+
}
31+
}
32+
633
tags = module.this.tags
734
}
835

test/src/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/cloudposse/terraform-aws-ses-lambda-forwarder
33
go 1.13
44

55
require (
6-
github.com/gruntwork-io/terratest v0.16.0
6+
github.com/gruntwork-io/terratest v0.31.4
77
github.com/stretchr/testify v1.5.1
88
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
99
golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect

0 commit comments

Comments
 (0)