Skip to content

Commit

Permalink
Added accounts_info.json to igor (#19)
Browse files Browse the repository at this point in the history
* 🔧 Added account_info, modified deployment scripts, in order to allow use '../' for branch

* 🔧 Added cleanup

* 🔧 Added sandbox account

* 🔧 Removed ucsf

* 🔧 Added architecture_type

* 🔧 Added project environmental variable check
  • Loading branch information
alubneuski committed Nov 15, 2021
1 parent a64b034 commit c7b1340
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 1 deletion.
84 changes: 84 additions & 0 deletions d3b_cli_igor/deploy_ops/config/account_info.json
Original file line number Diff line number Diff line change
@@ -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\"]"
}
}

7 changes: 6 additions & 1 deletion d3b_cli_igor/deploy_ops/generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand All @@ -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/"))
Expand Down
21 changes: 21 additions & 0 deletions d3b_cli_igor/deploy_ops/templates/deploy.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down

0 comments on commit c7b1340

Please sign in to comment.