Skip to content

Commit

Permalink
style: update modules to follow our style guide
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenMakandra committed Aug 28, 2024
1 parent b2cc3cd commit f3c9b4f
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 81 deletions.
43 changes: 0 additions & 43 deletions modules/RDSOSMetrics_loggroup/data.tf

This file was deleted.

44 changes: 44 additions & 0 deletions modules/RDSOSMetrics_loggroup/kms.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
data "aws_caller_identity" "current" {}

data "aws_region" "current" {}

data "aws_iam_policy_document" "RDSOS_KMS" {
#checkov:skip=CKV_AWS_109:This is required for a working KMS key policy
#checkov:skip=CKV_AWS_111:This is required for a working KMS key policy
#checkov:skip=CKV_AWS_356:Does not apply here because KMS key policies only apply to the key itself.
count = var.create_kms_key ? 1 : 0
policy_id = "key-policy-cloudwatch"
statement {
sid = "Enable IAM User Permissions"
actions = [
"kms:*",
]
effect = "Allow"
principals {
type = "AWS"
identifiers = [
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:root",
]
}
resources = ["*"]
}
statement {
sid = "AllowCloudWatchLogs"
actions = [
"kms:Encrypt*",
"kms:Decrypt*",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:Describe*"
]
effect = "Allow"
principals {
type = "Service"
identifiers = [
"logs.${data.aws_region.current.name}.amazonaws.com",
]
}
resources = ["*"]
}
}

resource "aws_kms_key" "RDSOS_KMS" {
count = var.create_kms_key ? 1 : 0
description = "KMS key to encrypt Cloudwatch loggroup for RDSOSMetrics (enhanced monitoring)."
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions modules/alternate_contacts/data.tf

This file was deleted.

9 changes: 0 additions & 9 deletions modules/alternate_contacts/locals.tf

This file was deleted.

14 changes: 14 additions & 0 deletions modules/alternate_contacts/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
data "aws_organizations_organization" "this" {
count = var.assign_contacts_to_all_accounts ? 1 : 0
}

locals {
operations_contact = merge(var.default_alternate_contact, var.operations_contact)
billing_contact = merge(var.default_alternate_contact, var.billing_contact)
security_contact = merge(var.default_alternate_contact, var.security_contact)

list_of_active_account_ids = var.assign_contacts_to_all_accounts ? [for account in data.aws_organizations_organization.this[0].non_master_accounts : account.id if account.status == "ACTIVE"] : null

account_list = var.assign_contacts_to_all_accounts ? setsubtract(local.list_of_active_account_ids, var.filter_accounts) : []
}

resource "aws_account_alternate_contact" "operations" {
alternate_contact_type = "OPERATIONS"

Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion modules/eks/data.tf

This file was deleted.

25 changes: 0 additions & 25 deletions modules/eks/locals.tf

This file was deleted.

28 changes: 28 additions & 0 deletions modules/eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,34 @@ resource "null_resource" "ensure_role_exists" {
}
}

data "aws_caller_identity" "current" {}

locals {
role_mappings = [
for role, groups in var.iam_role_rbac_mappings : {
rolearn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${role}"
username = role
groups = groups
}
]

user_mappings = [
for user, groups in var.iam_user_rbac_mappings : {
rolearn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:user/${user}"
username = user
groups = groups
}
]

node_group_iam_roles = [for ng in module.eks_managed_node_group : ng.iam_role_name]
asg_tags = [
for ng, values in var.node_groups : {
asg_name = module.eks_managed_node_group[ng].node_group_resources[0].autoscaling_groups[0].name
tag_value = ng
}
]
}

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "19.10.0"
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit f3c9b4f

Please sign in to comment.