# Data source to reference the shared Atlantis prefix list
data "aws_ec2_managed_prefix_list" "shared_orcd_atlantis_private" {
  name = "shared-orcd-atlantis-private-subnet-prefix-list"
}

# Allow the shared Atlantis prefix list to access EKS API server
resource "aws_security_group_rule" "eks_cluster_api_from_atlantis_prefix_list" {
  type              = "ingress"
  description       = "API Server access from shared-orcd-atlantis-private-subnet-prefix-list"
  from_port         = 443
  to_port           = 443
  protocol          = "tcp"
  prefix_list_ids   = [data.aws_ec2_managed_prefix_list.shared_orcd_atlantis_private.id]
  security_group_id = aws_security_group.AMPP-EKS-Cluster-SG.id
}
