Skip to content

Commit e534b65

Browse files
committed
* get rid of tfvars.example
* add more kubectl to outputs
1 parent 60b9572 commit e534b65

14 files changed

Lines changed: 87 additions & 88 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ unseal_key*
66
vault_token
77
.vscode
88
.direnv
9-
terraform.tfvars
109
terraform.tfstate*
1110
nimbus-secrets.json
1211
secrets.env

ec2/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ If you use [Nix](https://nixos.org), there is a nix flake definition that instal
4242

4343
### terraform.tfvars
4444

45-
You must create a `terraform.tfvars` file containing variables specific to your cluster. [variables.tf](variables.tf) contains all the variables you can set to customize the deployment. Many of these variables have defaults for a basic deployment that are optional in `terraform.tfvars`—some don't have defaults and must be set.
46-
47-
There is a [terraform.tfvars.example](terraform.tfvars.example) file that contains all of the possible variables, you can use as a reference when creating your `terraform.tfvars`.
45+
[variables.tf](variables.tf) is where all of the variables for the deployment are defined. The values are set in [terraform.tfvars](terraform.tfvars). *You must* edit this file to set the `cluster_name` before deploying.
4846

4947
#### Required variables:
5048

ec2/cluster.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,3 @@ data "http" "set_cluster_uri" {
3737
depends_on = [terraform_data.cluster_uri]
3838
}
3939

40-
output "cluster_id" {
41-
value = data.http.cluster_id.response_body
42-
}
43-
44-
output "cluster_token" {
45-
value = data.http.cluster_token.response_body
46-
sensitive = true
47-
}
48-
49-
output "set_cluster_uri_response" {
50-
value = data.http.set_cluster_uri.response_body
51-
}

ec2/outputs.tf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11

2+
output "update-kubeconfig-command" {
3+
value = "aws eks update-kubeconfig --region ${var.aws_region} --name ${module.eks.cluster_name}"
4+
description = "Command to update your kubeconfig to connect to the new EKS cluster"
5+
}
6+
7+
output "list-eks-nodes-command" {
8+
value = <<EOF
9+
aws --region ${var.aws_region} ec2 describe-instances \
10+
--filters "Name=tag:eks:cluster-name,Values=${var.cluster_name}" \
11+
--query "Reservations[].Instances[].{Hostname:PrivateDnsName, Type:InstanceType, Health:State.Name}" \
12+
--output table
13+
EOF
14+
description = "command to get the health of the EKS nodes"
15+
}
16+
217
output "unison_public_endpoint_https" {
318
value = "https://${aws_lb.main.dns_name}"
419
description = "Public HTTPS endpoint for Unison Cloud API (with self-signed cert)"
@@ -38,4 +53,4 @@ output "cluster_setup_u" {
3853
sensitive = false
3954
description = "Unison script to connect to your cluster"
4055
value = local_file.cluster_setup_script.content
41-
}
56+
}

ec2/terraform.tfvars

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
aws_region = "us-west-2"
2+
aws_availability_zones = ["us-west-2a", "us-west-2b"]
3+
4+
# You must change the cluster_name before deploying.
5+
# The new name must consistsolely of letters, numbers, and hyphens.
6+
7+
cluster_name = "CHANGE_ME"
8+
9+
# Optional variables with default values that can be overridden.
10+
# See varaibles.tf for descriptions:
11+
12+
# vpc_cidr = "10.0.0.0/16"
13+
# public_subnets = ["10.0.20.0/25", "10.0.20.128/25"]
14+
# private_subnets = ["10.0.30.0/25", "10.0.30.128/25"]
15+
16+
# Unison Cloud Configuration
17+
# unison_cloud_image_tag = "latest"
18+
# unison_instance_type = "t3.medium"
19+
# unison_min_instances = 1
20+
# unison_max_instances = 8
21+
# unison_desired_instances = 2

ec2/terraform.tfvars.example

Lines changed: 0 additions & 22 deletions
This file was deleted.

ec2/variables.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ variable "aws_availability_zones" {
1111
variable "cluster_name" {
1212
type = string
1313
description = "Name of the cluster"
14+
15+
validation {
16+
condition = var.cluster_name != "CHANGE_ME"
17+
error_message = "You must edit the project_name variable from its default value before deploying."
18+
}
1419
}
1520

1621
variable "vpc_cidr" {
@@ -58,13 +63,13 @@ variable "unison_instance_type" {
5863
variable "unison_min_instances" {
5964
description = "Minimum number of Unison Cloud instances"
6065
type = number
61-
default = 2
66+
default = 1
6267
}
6368

6469
variable "unison_max_instances" {
6570
description = "Maximum number of Unison Cloud instances"
6671
type = number
67-
default = 3
72+
default = 8
6873
}
6974

7075
variable "unison_desired_instances" {

eks/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ If you use [Nix](https://nixos.org), there is a nix flake definition that instal
4545

4646
### terraform.tfvars
4747

48-
You must create a `terraform.tfvars` file containing variables specific to your cluster. [variables.tf](variables.tf) contains all the variables you can set to customize the deployment. Many of these variables have defaults for a basic deployment that are optional in `terraform.tfvars`—some don't have defaults and must be set.
49-
50-
There is a [terraform.tfvars.example](terraform.tfvars.example) file that contains all of the possible variables, you can use as a reference when creating your `terraform.tfvars`.
48+
[variables.tf](variables.tf) is where all of the variables for the deployment are defined. The values are set in [terraform.tfvars](terraform.tfvars). *You must* edit this file to set the `cluster_name` before deploying.
5149

5250
#### Required variables:
5351

@@ -57,14 +55,12 @@ The AWS region to deploy the cluster in. Examples include `us-west-2`, `us-east-
5755

5856
You can find a complete list of zones and regions in the [AWS documentation](https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-availability-zones.html).
5957

60-
6158
##### `aws_availability_zones`
6259

63-
A list of availability zones to use for the VPC. This should be a list of two or more availability zones in the region you are deploying to. For example, `["us-west-2a", "us-west-2b"]`. You must include at least two availability zones for the EKS cluster to be created successfully.
60+
A list of availability zones to use for the VPC. This should be a list of two or more availability zones in the region you are deploying to. For example, `["us-west-2a", "us-west-2b"]`. You must include at least two availability zones for the load balancer to work across multiple AZs.
6461

6562
You can find a complete list of zones and regions in the [AWS documentation](https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-availability-zones.html).
6663

67-
6864
##### `cluster_name`
6965

7066
The name of the cluster, which should match the name you used to create a `Cluster.Id`. This will be used to create the EKS cluster and the DynamoDB table. It must be a valid DNS subdomain, meaning it must consist of only lowercase letters, numbers, and hyphens, and must start and end with a letter or number.

eks/cluster.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,3 @@ data "http" "set_cluster_uri" {
3939
depends_on = [kubernetes_service_v1.caddy_service, terraform_data.cluster_uri]
4040
}
4141

42-
output "cluster_id" {
43-
value = data.http.cluster_id.response_body
44-
}
45-
46-
output "cluster_token" {
47-
value = data.http.cluster_token.response_body
48-
sensitive = true
49-
}
50-
51-
output "set_cluster_uri_response" {
52-
value = data.http.set_cluster_uri.response_body
53-
}

eks/outputs.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ output "update-kubeconfig-command" {
44
description = "Command to update your kubeconfig to connect to the new EKS cluster"
55
}
66

7+
output "list-eks-nodes-command" {
8+
value = <<EOF
9+
aws --region ${var.aws_region} ec2 describe-instances \
10+
--filters "Name=tag:eks:cluster-name,Values=${var.cluster_name}" \
11+
--query "Reservations[].Instances[].{Hostname:PrivateDnsName, Type:InstanceType, Health:State.Name}" \
12+
--output table
13+
EOF
14+
description = "command to get the health of the EKS nodes"
15+
}
16+
717
resource "local_file" "cluster_setup_script" {
818
filename = "${path.module}/outputs/cluster-setup.u"
919
content = <<EOF

0 commit comments

Comments
 (0)