
resource "aws_security_group" "billing_service_failover" {

  provider = aws.failover_region

  name = local.workspace["service_name"]
  description = "Allow access from the VPC"
  vpc_id = data.terraform_remote_state.mop_core_failover.outputs.vpc_id
  tags = {
    Name = local.workspace["service_name"]
  }

  # allowing all traffic from itself
  ingress {
    from_port = 0
    to_port   = 65535
    protocol  = "tcp"
    self      = true
  }

  ingress {
    from_port = local.workspace["container_port"]
    to_port   = local.workspace["container_port"]
    protocol  = "tcp"
    cidr_blocks = local.cidr_blocks
  }

  egress {
    from_port       = 0
    to_port         = 0
    protocol        = "-1"
    cidr_blocks     = ["0.0.0.0/0"]
  }

}