-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
88 lines (71 loc) · 2.39 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
data "terraform_remote_state" "env_remote_state" {
backend = "s3"
workspace = terraform.workspace
config = {
bucket = var.alm_state_bucket_name
key = "operating-system"
region = "us-east-2"
role_arn = var.alm_role_arn
}
}
resource "local_file" "kubeconfig" {
filename = "${path.module}/outputs/kubeconfig"
content = data.terraform_remote_state.env_remote_state.outputs.eks_cluster_kubeconfig
}
resource "local_file" "helm_vars" {
filename = "${path.module}/outputs/${terraform.workspace}.yaml"
content = <<EOF
CONSUMER_URI: wss://streams.${data.terraform_remote_state.env_remote_state.outputs.dns_zone_name}/socket/websocket
image:
repository: ${var.image_repository}
tag: ${var.tag}
EOF
}
resource "null_resource" "helm_deploy" {
provisioner "local-exec" {
command = <<EOF
export KUBECONFIG=${local_file.kubeconfig.filename}
export AWS_DEFAULT_REGION=us-east-2
helm repo add scdp https://urbanos-public.github.io/charts/
helm repo update
helm upgrade --install ${var.watchinator_deploy_name} scdp/micro-service-watchinator --namespace=watchinator \
--version ${var.chartVersion} \
--values ${local_file.helm_vars.filename} \
--values micro-service-watchinator.yaml \
${var.extraHelmCommandArgs}
EOF
}
triggers = {
# Triggers a list of values that, when changed, will cause the resource to be recreated
# ${uuid()} will always be different thus always executing above local-exec
hack_that_always_forces_null_resources_to_execute = uuid()
}
}
variable "alm_role_arn" {
description = "The ARN for the assume role for ALM access"
default = "arn:aws:iam::199837183662:role/jenkins_role"
}
variable "alm_state_bucket_name" {
description = "The name of the S3 state bucket for ALM"
default = "scos-alm-terraform-state"
}
variable "watchinator_deploy_name" {
description = "The helm deploy name to give to the watchinator"
default = "watchinator"
}
variable "image_repository" {
description = "The image repository"
default = "smartcitiesdata/micro-service-watchinator"
}
variable "tag" {
description = "The tag/version of the image to deploy"
default = "latest"
}
variable "extraHelmCommandArgs" {
description = "Extra command arguments that will be passed to helm upgrade command"
default = ""
}
variable "chartVersion" {
description = "Version of the chart to deploy"
default = "1.1.0"
}