diff --git a/terraform-modules/aws/cloudposse/aws-cloudtrail-cloudwatch-alarms/README.md b/terraform-modules/aws/cloudposse/aws-cloudtrail-cloudwatch-alarms/README.md index 8062b551b..e93c96de4 100644 --- a/terraform-modules/aws/cloudposse/aws-cloudtrail-cloudwatch-alarms/README.md +++ b/terraform-modules/aws/cloudposse/aws-cloudtrail-cloudwatch-alarms/README.md @@ -14,7 +14,7 @@ No requirements. |------|--------|---------| | [cis\_alarms](#module\_cis\_alarms) | cloudposse/cloudtrail-cloudwatch-alarms/aws | 0.14.3 | | [cloudtrail](#module\_cloudtrail) | cloudposse/cloudtrail/aws | 0.17.0 | -| [cloudtrail\_s3\_bucket](#module\_cloudtrail\_s3\_bucket) | cloudposse/cloudtrail-s3-bucket/aws | 0.15.0 | +| [cloudtrail\_s3\_bucket](#module\_cloudtrail\_s3\_bucket) | github.com/ManagedKube/terraform-aws-cloudtrail-s3-bucket.git// | 0.24.0 | | [metric\_configs](#module\_metric\_configs) | cloudposse/config/yaml | 0.7.0 | | [this](#module\_this) | cloudposse/label/null | 0.25.0 | @@ -33,7 +33,10 @@ No requirements. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [access\_log\_bucket\_name](#input\_access\_log\_bucket\_name) | Name of the S3 bucket where s3 access log will be sent to | `string` | `""` | no | +| [acl](#input\_acl) | The canned ACL to apply. We recommend log-delivery-write for compatibility with AWS services | `string` | `"log-delivery-write"` | no | | [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no | +| [allow\_ssl\_requests\_only](#input\_allow\_ssl\_requests\_only) | Set to `true` to require requests to use Secure Socket Layer (HTTPS/SSL). This will explicitly deny access to HTTP requests | `bool` | `true` | no | | [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the `delimiter`
and treated as a single ID element. | `list(string)` | `[]` | no | | [cloudtrail\_event\_selector](#input\_cloudtrail\_event\_selector) | This enables the cloudtrail even selector to track all S3 API calls by default: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudtrail. | `list(object({include_management_events = bool, read_write_type = string, data_resource = list(object({type = string, values = list(string)}))}))` |
[
{
"data_resource": [
{
"type": "AWS::S3::Object",
"values": [
"arn:aws:s3"
]
}
],
"include_management_events": true,
"read_write_type": "All"
}
]
| no | | [context](#input\_context) | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional\_tag\_map, which are merged. | `any` |
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
| no | @@ -41,7 +44,9 @@ No requirements. | [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
`{
format = string
labels = list(string)
}`
(Type is `any` so the map values can later be enhanced to provide additional options.)
`format` is a Terraform format string to be passed to the `format()` function.
`labels` is a list of labels, in order, to pass to `format()` function.
Label values will be normalized before being passed to `format()` so they will be
identical to how they appear in `id`.
Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no | | [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no | | [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no | +| [force\_destroy](#input\_force\_destroy) | (Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable | `bool` | `false` | no | | [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for keep the existing setting, which defaults to `0`.
Does not affect `id_full`. | `number` | `null` | no | +| [is\_multi\_region\_trail](#input\_is\_multi\_region\_trail) | Specifies whether the trail is created in the current region or in all regions | `bool` | `true` | no | | [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no | | [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no | | [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.
Default value: `lower`. | `string` | `null` | no | @@ -51,9 +56,12 @@ No requirements. | [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | | [region](#input\_region) | n/a | `string` | n/a | yes | +| [restrict\_public\_buckets](#input\_restrict\_public\_buckets) | Set to `false` to disable the restricting of making the bucket public | `bool` | `true` | no | +| [s3\_object\_ownership](#input\_s3\_object\_ownership) | Specifies the S3 object ownership control. Valid values are `ObjectWriter`, `BucketOwnerPreferred`, and 'BucketOwnerEnforced'. | `string` | `"BucketOwnerPreferred"` | no | | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no | | [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no | +| [versioning\_enabled](#input\_versioning\_enabled) | A state of versioning. Versioning is a means of keeping multiple variants of an object in the same bucket | `bool` | `false` | no | ## Outputs diff --git a/terraform-modules/aws/cloudposse/aws-cloudtrail-cloudwatch-alarms/main.tf b/terraform-modules/aws/cloudposse/aws-cloudtrail-cloudwatch-alarms/main.tf index 170c73ae6..34a7ff26a 100644 --- a/terraform-modules/aws/cloudposse/aws-cloudtrail-cloudwatch-alarms/main.tf +++ b/terraform-modules/aws/cloudposse/aws-cloudtrail-cloudwatch-alarms/main.tf @@ -1,27 +1,38 @@ ## Everything after this is standard cloudtrail setup data "aws_caller_identity" "current" {} +/*ToDo: We are collaborating with cloudposse to bring this solution to your project, we have the task of following up this pr to integrate it + and return to the direct version of cloudposse. + + Cloudposse' issue: New input variable s3_object_ownership cloudposse/terraform-aws-cloudtrail-s3-bucket#62 + Cloudposse' pr: add input var s3_object_ownership cloudposse/terraform-aws-cloudtrail-s3-bucket#63 +*/ module "cloudtrail_s3_bucket" { - source = "cloudposse/cloudtrail-s3-bucket/aws" - version = "0.15.0" - - force_destroy = true - + source = "github.com/ManagedKube/terraform-aws-cloudtrail-s3-bucket.git//?ref=0.24.0" + #version = "master" + force_destroy = var.force_destroy + versioning_enabled = var.versioning_enabled + access_log_bucket_name = var.access_log_bucket_name + allow_ssl_requests_only= var.allow_ssl_requests_only + acl = var.acl + s3_object_ownership = var.s3_object_ownership + sse_algorithm = "aws:kms" context = module.this.context } resource "aws_cloudwatch_log_group" "default" { name = module.this.id tags = module.this.tags - retention_in_days = 90 + retention_in_days = 365 + #prowler issue: https://github.com/prowler-cloud/prowler/issues/1229 } data "aws_iam_policy_document" "log_policy" { statement { effect = "Allow" - actions = ["logs:CreateLogStream", "logs:PutLogEvents"] + actions = ["logs:CreateLogStream","logs:PutLogEvents"] resources = [ - "arn:aws:logs:${var.region}:${data.aws_caller_identity.current.account_id}:log-group:${aws_cloudwatch_log_group.default.name}:log-stream:*" + "arn:aws:logs:${var.region}:${data.aws_caller_identity.current.account_id}:log-group:${aws_cloudwatch_log_group.default.name}:*:*" ] } } @@ -65,7 +76,7 @@ module "cloudtrail" { version = "0.17.0" enable_log_file_validation = true include_global_service_events = true - is_multi_region_trail = true + is_multi_region_trail = var.is_multi_region_trail enable_logging = true s3_bucket_name = module.cloudtrail_s3_bucket.bucket_id # https://github.com/terraform-providers/terraform-provider-aws/issues/14557#issuecomment-671975672 diff --git a/terraform-modules/aws/cloudposse/aws-cloudtrail-cloudwatch-alarms/variables.tf b/terraform-modules/aws/cloudposse/aws-cloudtrail-cloudwatch-alarms/variables.tf index d0bf64ce9..bec3030fd 100644 --- a/terraform-modules/aws/cloudposse/aws-cloudtrail-cloudwatch-alarms/variables.tf +++ b/terraform-modules/aws/cloudposse/aws-cloudtrail-cloudwatch-alarms/variables.tf @@ -22,5 +22,51 @@ variable "cloudtrail_event_selector" { } ] } +variable "force_destroy" { + type = bool + default = false + description = "(Optional, Default:false ) A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable" +} +#Buckets input vars + +variable "versioning_enabled" { + type = bool + description = "A state of versioning. Versioning is a means of keeping multiple variants of an object in the same bucket" + default = false +} + +variable "access_log_bucket_name" { + type = string + default = "" + description = "Name of the S3 bucket where s3 access log will be sent to" +} + +variable "allow_ssl_requests_only" { + type = bool + default = true + description = "Set to `true` to require requests to use Secure Socket Layer (HTTPS/SSL). This will explicitly deny access to HTTP requests" +} + +variable "s3_object_ownership" { + type = string + default = "BucketOwnerPreferred" + description = "Specifies the S3 object ownership control. Valid values are `ObjectWriter`, `BucketOwnerPreferred`, and 'BucketOwnerEnforced'." +} +variable "acl" { + type = string + description = "The canned ACL to apply. We recommend log-delivery-write for compatibility with AWS services" + default = "log-delivery-write" +} + +variable "is_multi_region_trail" { + type = bool + default = true + description = "Specifies whether the trail is created in the current region or in all regions" +} +variable "restrict_public_buckets" { + type = bool + default = true + description = "Set to `false` to disable the restricting of making the bucket public" +} \ No newline at end of file