diff --git a/README.md b/README.md index 0f5d07b..4d34398 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ No modules. | [aws_iam_policy.AmazonSSMManagedInstanceCore](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source | | [aws_iam_policy_document.kms_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | | [aws_iam_policy_document.ssm_s3_cwl_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | +| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source | | [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | | [aws_route_table.selected](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/route_table) | data source | | [aws_subnet_ids.selected](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids) | data source | @@ -98,14 +99,14 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [access\_log\_bucket\_name](#input\_access\_log\_bucket\_name) | Name of S3 bucket to store access logs from session logs bucket | `string` | n/a | yes | +| [access\_log\_bucket\_name](#input\_access\_log\_bucket\_name) | Name prefix of S3 bucket to store access logs from session logs bucket | `string` | n/a | yes | | [access\_log\_expire\_days](#input\_access\_log\_expire\_days) | Number of days to wait before deleting access logs | `number` | `30` | no | -| [bucket\_name](#input\_bucket\_name) | Name of S3 bucket to store session logs | `string` | n/a | yes | +| [bucket\_name](#input\_bucket\_name) | Name prefix of S3 bucket to store session logs | `string` | n/a | yes | | [cloudwatch\_log\_group\_name](#input\_cloudwatch\_log\_group\_name) | Name of the CloudWatch Log Group for storing SSM Session Logs | `string` | `"/ssm/session-logs"` | no | | [cloudwatch\_logs\_retention](#input\_cloudwatch\_logs\_retention) | Number of days to retain Session Logs in CloudWatch | `number` | `30` | no | | [enable\_log\_to\_cloudwatch](#input\_enable\_log\_to\_cloudwatch) | Enable Session Manager to Log to CloudWatch Logs | `bool` | `true` | no | | [enable\_log\_to\_s3](#input\_enable\_log\_to\_s3) | Enable Session Manager to Log to S3 | `bool` | `true` | no | -| [kms\_key\_alias](#input\_kms\_key\_alias) | Alias of the KMS key. Must start with alias/ followed by a name | `string` | `"alias/ssm-key"` | no | +| [kms\_key\_alias](#input\_kms\_key\_alias) | Alias prefix of the KMS key. Must start with alias/ followed by a name | `string` | `"alias/ssm-key"` | no | | [kms\_key\_deletion\_window](#input\_kms\_key\_deletion\_window) | Waiting period for scheduled KMS Key deletion. Can be 7-30 days. | `number` | `7` | no | | [log\_archive\_days](#input\_log\_archive\_days) | Number of days to wait before archiving to Glacier | `number` | `30` | no | | [log\_expire\_days](#input\_log\_expire\_days) | Number of days to wait before deleting | `number` | `365` | no | diff --git a/aws_s3_bucket.access_log_bucket.tf b/aws_s3_bucket.access_log_bucket.tf index 5c9ebfe..e01eb48 100644 --- a/aws_s3_bucket.access_log_bucket.tf +++ b/aws_s3_bucket.access_log_bucket.tf @@ -3,7 +3,7 @@ resource "aws_s3_bucket" "access_log_bucket" { # checkov:skip=CKV_AWS_144: Cross region replication is overkill # checkov:skip=CKV_AWS_18: # checkov:skip=CKV_AWS_52: - bucket = var.access_log_bucket_name + bucket_prefix = "${var.access_log_bucket_name}-" acl = "log-delivery-write" force_destroy = true diff --git a/aws_s3_bucket.session_logs_bucket.tf b/aws_s3_bucket.session_logs_bucket.tf index 28adf6a..1a28bd4 100644 --- a/aws_s3_bucket.session_logs_bucket.tf +++ b/aws_s3_bucket.session_logs_bucket.tf @@ -1,7 +1,7 @@ resource "aws_s3_bucket" "session_logs_bucket" { # checkov:skip=CKV_AWS_144: Cross region replication overkill # checkov:skip=CKV_AWS_52: - bucket = var.bucket_name + bucket_prefix = "${var.bucket_name}-" acl = "private" force_destroy = true tags = var.tags diff --git a/iam.tf b/iam.tf index 864343e..0afde2b 100644 --- a/iam.tf +++ b/iam.tf @@ -6,7 +6,7 @@ data "aws_iam_policy_document" "kms_access" { sid = "KMS Key Default" principals { type = "AWS" - identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"] + identifiers = ["arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:root"] } actions = [ "kms:*", @@ -41,9 +41,9 @@ data "aws_iam_policy_document" "kms_access" { # Create EC2 Instance Role resource "aws_iam_role" "ssm_role" { - name = "ssm_role" - path = "/" - tags = var.tags + name_prefix = "ssm_role-" + path = "/" + tags = var.tags assume_role_policy = <