dspace-group / simphera-reference-architecture-aws

In order to deploy SIMPHERA to AWS, various cloud resources, such as a Kubernetes cluster, PostgreSQL database server, etc., need to be created. This repository contains a reference architecture for these AWS resources. You can use this Terraform configuration as a starting point to create these resources in your own AWS account.
MIT License
11 stars 4 forks source link

[feat] allow communication between CPU and GPU node pools #117

Open schwichti opened 11 months ago

schwichti commented 11 months ago
resource "aws_security_group_rule" "securitygroups_rules" {
  for_each                 = local.security_groups
  description              = "Access between node groups."
  type                     = "ingress"
  from_port                = 0
  to_port                  = 65535
  protocol                 = "all"
  source_security_group_id = split(",", each.key)[0]
  security_group_id        = split(",", each.key)[1]
}

data "aws_security_groups" "securitygroups" {
  tags = {
    "${local.cluster_tag}" = "owned"
  }
}

locals {

  cluster_tag        = var.existing_k8s_cluster_name != null ? "kubernetes.io/cluster/${var.existing_k8s_cluster_name}" : "kubernetes.io/cluster/${local.cluster_name}"

  security_groups = toset(flatten([
    for source in data.aws_security_groups.securitygroups.ids : [
      for target in data.aws_security_groups.securitygroups.ids : "${source},${target}" if source != target
    ]
  ]))
}