-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
82 lines (73 loc) · 2.73 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
data "aws_ami" "exasol" {
most_recent = true
owners = [var.ami_image_owner]
filter {
name = "name"
values = ["*${var.ami_image_name}*"]
}
}
resource "aws_cloudformation_stack" "exasol_cluster" {
name = var.cluster_name
capabilities = ["CAPABILITY_IAM"]
on_failure = "DELETE"
template_url = "https://exasol-cf-templates.s3.eu-central-1.amazonaws.com/cloudformation_template_v2.0.0.yml"
parameters = {
DBSystemName = var.database_name
DBPassword = var.sys_user_password
ExasolPassword = var.admin_user_password
SubnetId = var.subnet_id
DBSecurityGroup = var.security_group_id
LicenseServerInstanceType = var.management_server_instance_type
DatabaseNodeInstanceType = var.datanode_instance_type
DBNodeCount = var.datanode_count
StandbyNode = var.standbynode_count
KeyName = var.key_pair_name
ImageId = var.ami_image_id == null ? data.aws_ami.exasol.id : var.ami_image_id
PublicIP = var.public_ip
CreateS3Bucket = var.create_s3_bucket
CreateS3Endpoint = var.create_s3_endpoint
CreateKMSEndpoint = var.create_kms_endpoint
CreateEC2Endpoint = var.create_ec2_endpoint
OpenPorts = var.open_ports
OwnerTag = var.owner
ProjectTag = var.project
}
tags = {
Name = "exasol-${var.cluster_name}-${var.environment}"
Project = var.project
"exa:project" = var.project
"exa:project.name" = var.project_name
Owner = var.owner
"exa:owner" = var.owner
Environment = var.environment
WaitedOn = var.waited_on == null ? "waited_on_null" : var.waited_on
}
}
data "aws_instance" "exasol_first_datanode" {
instance_id = element(split(",", aws_cloudformation_stack.exasol_cluster.outputs["Datanodes"]), 0)
}
data "aws_instance" "management_server" {
instance_id = aws_cloudformation_stack.exasol_cluster.outputs["ManagementServer"]
}
resource "null_resource" "exasol_cluster_wait" {
count = var.public_ip ? 1 : 0
depends_on = [aws_cloudformation_stack.exasol_cluster]
triggers = {
always = uuid()
}
provisioner "local-exec" {
command = <<EOF
python3 ${path.module}/scripts/exasol_xmlrpc.py \
--license-server-address "$IP"\
--username admin \
--password "$ADMIN_PASS"
EOF
environment = {
IP = data.aws_instance.management_server.public_ip
ADMIN_PASS = var.admin_user_password
}
}
}
resource "null_resource" "exasol_waited_on" {
depends_on = [null_resource.exasol_cluster_wait]
}