# -*- coding: utf-8 -*-
#  ECS ComposeX <https://github.com/lambda-my-aws/ecs_composex>
#  Copyright (C) 2020  John Mille <john@lambda-my-aws.io>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""Conditions related to the VPC construction."""

from troposphere import Condition, Equals, Ref, Or, Not

from ecs_composex.vpc import vpc_params
from ecs_composex.common import cfn_conditions

USE_SUB_ZONE_CON_T = "UseDnsSubZoneCondition"
USE_SUB_ZONE_CON = Or(
    Equals(Ref(vpc_params.USE_SUB_ZONE), "True"),
    Condition(cfn_conditions.NOT_USE_CLOUDMAP_CON_T),
)

NOT_USE_VPC_MAP_ID_CON_T = "NotUseVpcMapId"
NOT_USE_VPC_MAP_ID_CON = Equals(
    Ref(vpc_params.VPC_MAP_ID), vpc_params.VPC_MAP_ID.Default
)

USE_VPC_MAP_ID_CON_T = "UseVpcMapId"
USE_VPC_MAP_ID_CON = Not(Condition(NOT_USE_VPC_MAP_ID_CON_T))
