diff --git a/d3b_cli_igor/deploy_ops/config/account_info.json b/d3b_cli_igor/deploy_ops/config/account_info.json new file mode 100644 index 0000000..5f36f07 --- /dev/null +++ b/d3b_cli_igor/deploy_ops/config/account_info.json @@ -0,0 +1,84 @@ +{ + "chopd3b": { + "state_files_bucket": "chopawsd3b-remote-state-files", + "institution_naming_convention": "chopd3b", + "account_id" : "538745987955", + "organization" : "kf", + "dev_cidr" : "[ \"10.10.0.0/16\"]", + "qa_cidr" : "[\"10.11.0.0/16\"]", + "prd_cidr" : "[\"0.0.0.0/0\"]", + "service_cidr" : "[\"10.0.0.0/8\"]", + "instance_type" : "db.t2.small", + "domain_external" : "kidsfirstdrc.org", + "domain_internal" : "kids-first.io", + "vpc_prefix" : "apps", + "subnet_prefix" : "apps", + "azs" : "[\"a\",\"b\",\"c\",\"e\"]" + }, + "chopd3bPrdHippa": + { + "state_files_bucket" : "chopd3bprdhippa-remote-state-files", + "institution_naming_convention": "research-27200-7225140000", + "account_id" : "515011955314", + "organization" : "d3b", + "dev_cidr" : "[\"10.10.0.0/16\"]", + "qa_cidr" : "[\"10.11.0.0/16\"]", + "prd_cidr" : "[\"10.12.0.0/16\"]", + "service_cidr" : "[\"10.0.0.0/16\"]", + "instance_type" : "db.t2.small", + "domain_external" : "research-27200-7225140000.aws.cloud.chop.edu", + "domain_internal" : "research-27200-7225140000.aws.cloud.chop.edu", + "vpc_prefix" : "apps", + "subnet_prefix" : "apps", + "azs" : "[\"a\",\"b\"]" + }, + "sandbox": + { + "state_files_bucket" : "sandbox-remote-state-files", + "institution_naming_convention": "aws-research-7225140000-d3b-sandbox01-dev", + "account_id" : "452734729332", + "organization" : "d3b", + "dev_cidr" : "[\"172.22.30.128/26\"]", + "instance_type" : "db.t2.small", + "domain_external" : "aws-research-7225140000-d3b-sandbox01-dev.aws.cloud.chop.edu", + "domain_internal" : "aws-research-7225140000-d3b-sandbox01-dev.aws.cloud.chop.edu", + "vpc_prefix" : "baseline-primary-vpc", + "subnet_prefix" : "baseline-primary-subnet", + "azs" : "[\"a\",\"b\"]" + }, + "chopd3bPrd": + { + "state_files_bucket": "chopd3bprd-remote-state-files", + "institution_naming_convention": "chop-d3b-prod", + "account_id" : "684194535433", + "organization" : "d3b", + "dev_cidr" : "[\"10.39.0.0/16\"]", + "qa_cidr" : "[\"10.39.0.0/16\"]", + "prd_cidr" : "[\"0.0.0.0/0\"]", + "service_cidr" : "[\"10.0.0.0/8\"]", + "instance_type" : "db.t2.small", + "domain_external" : "d3b.io", + "domain_internal" : "d3b.io", + "vpc_prefix" : "dc", + "subnet_prefix" : "dc", + "azs" : "[\"a\",\"b\"]" + }, + "kf-strides": + { + "state_files_bucket": "kf-strides-remote-state-files", + "institution_naming_convention": "chop-d3b-center", + "account_id" : "232196027141", + "organization" : "kf-strides", + "dev_cidr" : "[ \"10.10.0.0/16\"]", + "qa_cidr" : "[\"10.11.0.0/16\"]", + "prd_cidr" : "[\"0.0.0.0/0\"]", + "service_cidr" : "[\"10.0.0.0/8\"]", + "instance_type" : "db.t2.small", + "domain_external" : "kf-strides.org", + "domain_internal" : "kf-strides.org", + "vpc_prefix" : "apps", + "subnet_prefix" : "apps", + "azs" : "[\"a\",\"b\",\"c\",\"e\"]" + } + } + diff --git a/d3b_cli_igor/deploy_ops/generate_config.py b/d3b_cli_igor/deploy_ops/generate_config.py index 09ecb78..091b856 100644 --- a/d3b_cli_igor/deploy_ops/generate_config.py +++ b/d3b_cli_igor/deploy_ops/generate_config.py @@ -9,6 +9,8 @@ __name__, testing_mode=False, log_format="detailed" ) +path = os.path.dirname(__file__) +config_file = "config/account_info.json" def generate(account_name, organization, region, environment, config_file, mode): templateEnv = jinja2.Environment( @@ -96,6 +98,9 @@ def generate(account_name, organization, region, environment, config_file, mode) if "aws_infra_lambda_module" in line: f.write('export architecture_type="aws-infra-lambda"') f.write("\n") + if "aws-alb" in line: + f.write('export architecture_type="aws-alb"') + f.write("\n") template = templateEnv.get_template("templates/deploy.tmpl") st = os.stat("./tmp_" + mode + "_application") os.chmod("./tmp_" + mode + "_application", st.st_mode | stat.S_IEXEC) @@ -108,7 +113,7 @@ def generate_tf_module_files(project, region, account_name, environment, module) account_information = {} state_files_bucket = "" - with open(os.getcwd() + "/account_info.json") as json_file: + with open(path + "/" + config_file ) as json_file: account_information = json.load(json_file) backend_file = jinja2.FileSystemLoader(searchpath="./") templateEnv = jinja2.Environment(loader=FileSystemLoader("templates/")) diff --git a/d3b_cli_igor/deploy_ops/templates/deploy.tmpl b/d3b_cli_igor/deploy_ops/templates/deploy.tmpl index a6e98f8..915f07e 100644 --- a/d3b_cli_igor/deploy_ops/templates/deploy.tmpl +++ b/d3b_cli_igor/deploy_ops/templates/deploy.tmpl @@ -4,8 +4,29 @@ rm -rf .config mkdir .tmp rsync -avr --exclude='.tmp' ./ .tmp/ +#To support legacy way to set env vars in Jenkinsfile itself +if [ ! -z $TF_VAR_architecture_type ]; then + export architecture_type=$TF_VAR_architecture_type +fi + +#To Support ecs-service-type-1 +if [ ! -z $TF_VAR_project ]; then + TF_VAR_projectName=$TF_VAR_project +fi + +if [ ! -z $TF_VAR_application ]; then + TF_VAR_projectName=$TF_VAR_application +fi + export BRANCH_NAME=`git rev-parse --abbrev-ref HEAD` +if [ $TF_VAR_branch != "../" ]; then git clone --depth=1 -b $TF_VAR_branch git@github.com:kids-first/$architecture_type-module.git .tmp_deployment/.standard +else +pwd +mkdir -p .tmp_deployment/.standard +rsync -av --progress $TF_VAR_branch/* .tmp_deployment/.standard/ --exclude tests +rsync -av --progress $TF_VAR_branch/.config .tmp_deployment/.standard/ --exclude tests +fi git clone --depth=1 -b master git@github.com:d3b-center/aws-infra-deployment.git .tmp_deployment/.deployment cd .tmp_deployment #Remove unnecessary files diff --git a/setup.py b/setup.py index 82710b3..45b631e 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ package_data={ 'd3b_cli_igor.deploy_ops': ['templates/*.tmpl'], 'd3b_cli_igor.utils': ['config/*.yaml'], + 'd3b_cli_igor.deploy_ops': ['config/*.json'], }, include_package_data=True, install_requires=[