-
Notifications
You must be signed in to change notification settings - Fork 3
/
outputs.tf
138 lines (114 loc) · 6.09 KB
/
outputs.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
locals {
ips_type = local.assign_public_ip ? "PublicIpAddress" : "PrivateIpAddress"
asg_name = aws_autoscaling_group.autoscaling_group.name
weka_admin_password_secret_id = aws_secretsmanager_secret.weka_password.id
smb_pre_terraform_destroy_command = var.smb_protocol_gateways_number == 0 ? "" : <<EOT
echo ${join(" ", module.smb_protocol_gateways[0].instance_ids)} | xargs -n 1 aws ec2 modify-instance-attribute --region ${local.region} --no-disable-api-stop --instance-id
EOT
s3_pre_terraform_destroy_command = var.s3_protocol_gateways_number == 0 ? "" : <<EOT
echo ${join(" ", module.s3_protocol_gateways[0].instance_ids)} | xargs -n 1 aws ec2 modify-instance-attribute --region ${local.region} --no-disable-api-stop --instance-id
EOT
}
output "local_ssh_private_key" {
value = var.enable_key_pair ? var.ssh_public_key == null && var.key_pair_name == null ? "${local.ssh_path}-private-key.pem" : null : null
description = "If 'ssh_public_key' is set to null and no key_pair_name provided, it will output the private ssh key location."
}
output "cluster_name" {
value = var.cluster_name
description = "The cluster name"
}
output "ips_type" {
value = local.ips_type
description = "If 'assign_public_ip' is set to true, it will output the public ips, If no it will output the private ips"
}
output "lambda_status_name" {
value = aws_lambda_function.status_lambda.function_name
description = "Name of lambda status"
}
output "weka_cluster_admin_password_secret_id" {
value = local.weka_admin_password_secret_id
description = "Secret id of weka admin password"
}
output "alb_dns_name" {
value = var.create_alb ? aws_lb.alb[0].dns_name : null
description = "If 'create_alb` set to true, it will output dns name of the ALB"
}
output "alb_alias_record" {
value = var.alb_alias_name != "" ? aws_route53_record.lb_record[0].fqdn : null
description = "If 'alb_alias_name` not null, it will output fqdn of the ALB"
}
output "asg_name" {
value = aws_autoscaling_group.autoscaling_group.name
description = "Name of ASG"
}
output "placement_group_name" {
value = local.backends_placement_group_name
description = "Name of placement group"
}
output "vpc_id" {
value = local.vpc_id
description = "VPC id"
}
output "subnet_ids" {
value = local.subnet_ids
description = "Subnet ids of backends"
}
output "sg_ids" {
value = local.sg_ids
description = "Security group ids of backends"
}
output "cluster_helper_commands" {
value = <<EOT
aws ec2 describe-instances --instance-ids $(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-name ${local.asg_name} --region ${local.region} --query "AutoScalingGroups[].Instances[].InstanceId" --output text) --region ${local.region} --query 'Reservations[].Instances[].${local.ips_type}' --output json
# for nfs use: --payload '{"type": "progress", "protocl": "nfs"}'
aws lambda invoke --function-name ${aws_lambda_function.status_lambda.function_name} --payload '{"type": "progress"}' --region ${local.region} --cli-binary-format raw-in-base64-out /dev/stdout
aws secretsmanager get-secret-value --secret-id ${local.weka_admin_password_secret_id} --region ${local.region} --query SecretString --output text
EOT
}
output "client_helper_commands" {
value = var.clients_number == 0 ? null : module.clients[0].client_helper_commands
}
output "client_asg_name" {
value = var.clients_number == 0 ? null : var.clients_use_autoscaling_group ? module.clients[0].asg_name : null
}
output "client_ips" {
value = var.clients_number == 0 ? null : module.clients[0].client_ips
description = "Ips of clients"
}
output "smb_protocol_gateways_ips" {
value = var.smb_protocol_gateways_number == 0 ? null : <<EOT
echo $(aws ec2 describe-instances --region ${local.region} --filters "Name=tag:Name,Values=${module.smb_protocol_gateways[0].gateways_name}" "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[*].{Instance:InstanceId,PrivateIpAddress:PrivateIpAddress,PublicIpAddress:PublicIpAddress}')
EOT
description = "Ips of SMB protocol gateways"
}
output "smb_protocol_gateways_name" {
value = var.smb_protocol_gateways_number == 0 ? null : module.smb_protocol_gateways[0].gateways_name
description = "Name of SMB protocol gateway instances"
}
output "s3_protocol_gateways_ips" {
value = var.s3_protocol_gateways_number == 0 ? null : <<EOT
echo $(aws ec2 describe-instances --region ${local.region} --filters "Name=tag:Name,Values=${module.s3_protocol_gateways[0].gateways_name}" "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[*].{Instance:InstanceId,PrivateIpAddress:PrivateIpAddress,PublicIpAddress:PublicIpAddress}')
EOT
description = "Ips of S3 protocol gateways"
}
output "s3_protocol_gateways_name" {
value = var.s3_protocol_gateways_number == 0 ? null : module.s3_protocol_gateways[0].gateways_name
description = "Name of S3 protocol gateway instances"
}
output "nfs_protocol_gateways_ips" {
value = var.nfs_protocol_gateways_number == 0 ? null : <<EOT
echo $(aws ec2 describe-instances --region ${local.region} --filters "Name=tag:Name,Values=${module.nfs_protocol_gateways[0].gateways_name}" "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[*].{Instance:InstanceId,PrivateIpAddress:PrivateIpAddress,PublicIpAddress:PublicIpAddress}')
EOT
description = "Ips of NFS protocol gateways"
}
output "nfs_protocol_gateways_name" {
value = var.nfs_protocol_gateways_number == 0 ? null : module.nfs_protocol_gateways[0].gateways_name
description = "Name of NFS protocol gateway instances"
}
output "deploy_lambda_name" {
value = aws_lambda_function.deploy_lambda.function_name
}
output "pre_terraform_destroy_command" {
value = var.smb_protocol_gateways_number == 0 && var.s3_protocol_gateways_number == 0 ? "" : "${local.smb_pre_terraform_destroy_command}${local.s3_pre_terraform_destroy_command}"
description = "Mandatory pre-destroy steps only when S3/SMB protocol gateways are crated. Terraform doesn't handle protection removal."
}