# A copy of the License is located at # # # # http://www.apache.org/licenses/LICENSE-2.0 # # # # or in the "license" file accompanying this file. This file is distributed # # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express # # or implied. See the License for the specific language governing permissions# # and limitations under the License. # ############################################################################### from cfct.aws.utils.get_partition import get_partition from cfct.utils.logger import Logger from os import environ import pytest logger = Logger('info') aws_regions_partition = 'aws' aws_china_regions_partition = 'aws-cn' aws_us_gov_cloud_regions_partition = 'aws-us-gov' @pytest.mark.unit def test_get_partition_for_us_region(): environ['AWS_REGION'] = 'us-east-1' assert aws_regions_partition == get_partition() @pytest.mark.unit def test_get_partition_for_eu_region(): environ['AWS_REGION'] = 'eu-west-1'
# or in the "license" file accompanying this file. This file is distributed # # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express # # or implied. See the License for the specific language governing permissions# # and limitations under the License. # ############################################################################### import os import pytest import mock from cfct.utils.logger import Logger import cfct.manifest.manifest_parser as parse import pytest TESTS_DIR = './source/tests/' logger = Logger(loglevel='info') os.environ['ACCOUNT_LIST'] = '' @pytest.fixture def bucket_name(): return os.getenv('STAGING_BUCKET') @pytest.fixture def s3_setup(s3_client, bucket_name): s3_client.create_bucket(Bucket=bucket_name) yield
flag = True logger.info("Setting flag value to {}".format(flag)) if flag and item not in m_list: # avoid appending same parameter in the parameter list m_list.append(item) logger.info("Printing updated parameter file.") logger.info(m_list) return m_list if __name__ == '__main__': if len(sys.argv) > 3: log_level = sys.argv[1] master_baseline_file = sys.argv[2] add_on_baseline_file = sys.argv[3] json_extension = ".json" updated_flag = ".update" logger = Logger(loglevel=log_level) master_list = _read_file(master_baseline_file) add_on_list = _read_file(add_on_baseline_file) file_matcher(master_list, add_on_list) else: print('No arguments provided. Please provide the existing and ' 'new manifest files names.') print('Example: merge_baseline_template_parameter.py <LOG-LEVEL>' ' <MASTER_FILE_NAME> <ADD_ON_FILE_NAME>') sys.exit(2)
from cfct.manifest.stage_to_s3 import StageFile from cfct.manifest.sm_input_builder import InputBuilder, SCPResourceProperties, \ StackSetResourceProperties from cfct.utils.parameter_manipulation import transform_params from cfct.utils.string_manipulation import convert_list_values_to_string, \ empty_separator_handler, list_sanitizer from cfct.aws.services.s3 import S3 from cfct.aws.services.organizations import Organizations from cfct.manifest.cfn_params_handler import CFNParamsHandler from cfct.metrics.solution_metrics import SolutionMetrics from cfct.aws.services.cloudformation import StackSet VERSION_1 = '2020-01-01' VERSION_2 = '2021-03-15' logger = Logger(loglevel=os.environ['LOG_LEVEL']) def scp_manifest(): # determine manifest version manifest = Manifest(os.environ.get('MANIFEST_FILE_PATH')) if manifest.version == VERSION_1: get_scp_input = SCPParser() return get_scp_input.parse_scp_manifest_v1() elif manifest.version == VERSION_2: get_scp_input = SCPParser() return get_scp_input.parse_scp_manifest_v2() def stack_set_manifest(): # determine manifest version manifest = Manifest(os.environ.get('MANIFEST_FILE_PATH'))