-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
66 lines (58 loc) · 2.27 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
module "rg-infra" {
source = "./RG"
var_resource_group_name = var.var_resource_group_name
location = var.location
}
module "rg-aks-infra" {
source = "./RG"
depends_on = [ module.rg-infra ]
var_resource_group_name = var.var_aks_resource_group_name
location = var.location
}
module "acr-infra" {
source = "./ACR"
depends_on = [ module.rg-infra ]
var_acr_rg_name = module.rg-infra.out_rg_name
var_acr_location = module.rg-infra.out_rg_location
var_acr_name = var.var_acr_name
var_sku = var.var_sku
}
module "aks_infra" {
depends_on = [ module.acr-infra ]
source = "./AKS"
var_dns_prefix = var.var_dns_prefix
var_aks_name_space = var.var_aks_name_space
var_aks_name = var.var_aks_name
var_vm_size = var.var_vm_size
var_client_id = var.var_client_id
var_client_secret = var.var_client_secret
var_aks_resource_group_name = module.rg-aks-infra.out_rg_name
location = module.rg-aks-infra.out_rg_location
}
resource "null_resource" "execute_dokerbuild_script_1" {
depends_on = [module.acr-infra,module.aks_infra]
provisioner "local-exec" {
command = <<-EOT
az login --service-principal -u ${var.var_client_id} --tenant ${var.var_tenant_id} -p ${var.var_client_secret}
docker login -u ${module.acr-infra.admin_username} -p ${module.acr-infra.admin_password} ${module.acr-infra.login_server}
cd //home//bharath//CGI-Demo
mvn clean install
docker build -f //home//bharath//CGI-Demo//Dockerfile -t cgi-demo:latest .
docker tag cgi-demo:latest ${module.acr-infra.login_server}/cgi-demo:latest
docker push ${module.acr-infra.login_server}/cgi-demo:latest
EOT
}
}
resource "null_resource" "execute_aks_script_1" {
depends_on = [null_resource.execute_dokerbuild_script_1]
provisioner "local-exec" {
command = <<-EOT
az aks get-credentials --resource-group ${var.var_resource_group_name} --name ${var.var_aks_name}
kubectl create var_aks_name_space ${var.var_aks_name_space}
kubectl get ns
kubectl apply -f deployment.yml -n ${var.var_aks_name_space}
kubectl apply -f service.yml -n ${var.var_aks_name_space}
kubectl get service -n ${var.var_aks_name_space}
EOT
}
}