Skip to content

Commit 2f1cc22

Browse files
authored
make UI optional (#8)
1 parent 7699033 commit 2f1cc22

File tree

5 files changed

+127
-4
lines changed

5 files changed

+127
-4
lines changed

README.md

+62-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,67 @@ This module consists of submodules that can be used separately as well:
1616

1717
You can either use this high-level module, or submodules individually. See each module's corresponding `README.md` for more details.
1818

19-
You can find a complete example that uses this module but also includes setting up VPC and other non-Metaflow-specific parts of infra [in this repo](https://github.com/outerbounds/metaflow-tools/tree/master/aws/terraform).
19+
Here's a minimal end-to-end example of using this module with VPC:
20+
```terraform
21+
# Random suffix for this deployment
22+
resource "random_string" "suffix" {
23+
length = 8
24+
special = false
25+
upper = false
26+
}
27+
28+
locals {
29+
resource_prefix = "metaflow"
30+
resource_suffix = random_string.suffix.result
31+
}
32+
33+
data "aws_availability_zones" "available" {
34+
}
35+
36+
# VPC infra using https://github.com/terraform-aws-modules/terraform-aws-vpc
37+
module "vpc" {
38+
source = "terraform-aws-modules/vpc/aws"
39+
version = "3.13.0"
40+
41+
name = "${local.resource_prefix}-${local.resource_suffix}"
42+
cidr = "10.10.0.0/16"
43+
44+
azs = data.aws_availability_zones.available.names
45+
private_subnets = ["10.10.8.0/21", "10.10.16.0/21", "10.10.24.0/21"]
46+
public_subnets = ["10.10.128.0/21", "10.10.136.0/21", "10.10.144.0/21"]
47+
48+
enable_nat_gateway = true
49+
single_nat_gateway = true
50+
enable_dns_hostnames = true
51+
}
52+
53+
54+
module "metaflow" {
55+
source = "outerbounds/metaflow/aws"
56+
version = "0.3.0"
57+
58+
resource_prefix = local.resource_prefix
59+
resource_suffix = local.resource_suffix
60+
61+
enable_step_functions = false
62+
subnet1_id = module.vpc.public_subnets[0]
63+
subnet2_id = module.vpc.public_subnets[1]
64+
vpc_cidr_block = module.vpc.vpc_cidr_block
65+
vpc_id = module.vpc.vpc_id
66+
67+
tags = {
68+
"managedBy" = "terraform"
69+
}
70+
}
71+
72+
# The module will generate a Metaflow config in JSON format, write it to a file
73+
resource "local_file" "metaflow_config" {
74+
content = module.metaflow.metaflow_profile_json
75+
filename = "./metaflow_profile.json"
76+
}
77+
```
78+
79+
You can find a more complete example that uses this module but also includes setting up sagemaker notebooks and other non-Metaflow-specific parts of infra [in this repo](https://github.com/outerbounds/metaflow-tools/tree/master/aws/terraform).
2080

2181
<!-- BEGIN_TF_DOCS -->
2282
## Modules
@@ -52,7 +112,7 @@ You can find a complete example that uses this module but also includes setting
52112
| <a name="input_subnet1_id"></a> [subnet1\_id](#input\_subnet1\_id) | First subnet used for availability zone redundancy | `string` | n/a | yes |
53113
| <a name="input_subnet2_id"></a> [subnet2\_id](#input\_subnet2\_id) | Second subnet used for availability zone redundancy | `string` | n/a | yes |
54114
| <a name="input_tags"></a> [tags](#input\_tags) | aws tags | `map(string)` | n/a | yes |
55-
| <a name="input_ui_certificate_arn"></a> [ui\_certificate\_arn](#input\_ui\_certificate\_arn) | SSL certificate for UI | `string` | n/a | yes |
115+
| <a name="input_ui_certificate_arn"></a> [ui\_certificate\_arn](#input\_ui\_certificate\_arn) | SSL certificate for UI. If set to empty string, UI is disabled. | `string` | `""` | no |
56116
| <a name="input_vpc_cidr_block"></a> [vpc\_cidr\_block](#input\_vpc\_cidr\_block) | The VPC CIDR block that we'll access list on our Metadata Service API to allow all internal communications | `string` | n/a | yes |
57117
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The id of the single VPC we stood up for all Metaflow resources to exist in. | `string` | n/a | yes |
58118

examples/minimal_example.tf

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
###############################################################################
2+
# An example using this module to set up a minimal deployment Metaflow
3+
# with AWS Batch support, without the UI.
4+
###############################################################################
5+
6+
# Random suffix for this deployment
7+
resource "random_string" "suffix" {
8+
length = 8
9+
special = false
10+
upper = false
11+
}
12+
13+
locals {
14+
resource_prefix = "metaflow"
15+
resource_suffix = random_string.suffix.result
16+
}
17+
18+
data "aws_availability_zones" "available" {
19+
}
20+
21+
# VPC infra using https://github.com/terraform-aws-modules/terraform-aws-vpc
22+
module "vpc" {
23+
source = "terraform-aws-modules/vpc/aws"
24+
version = "3.13.0"
25+
26+
name = "${local.resource_prefix}-${local.resource_suffix}"
27+
cidr = "10.10.0.0/16"
28+
29+
azs = data.aws_availability_zones.available.names
30+
private_subnets = ["10.10.8.0/21", "10.10.16.0/21", "10.10.24.0/21"]
31+
public_subnets = ["10.10.128.0/21", "10.10.136.0/21", "10.10.144.0/21"]
32+
33+
enable_nat_gateway = true
34+
single_nat_gateway = true
35+
enable_dns_hostnames = true
36+
}
37+
38+
39+
module "metaflow" {
40+
source = "outerbounds/metaflow/aws"
41+
version = "0.3.0"
42+
43+
resource_prefix = local.resource_prefix
44+
resource_suffix = local.resource_suffix
45+
46+
enable_step_functions = false
47+
subnet1_id = module.vpc.public_subnets[0]
48+
subnet2_id = module.vpc.public_subnets[1]
49+
vpc_cidr_block = module.vpc.vpc_cidr_block
50+
vpc_id = module.vpc.vpc_id
51+
52+
tags = {
53+
"managedBy" = "terraform"
54+
}
55+
}
56+
57+
# The module will generate a Metaflow config in JSON format, write it to a file
58+
resource "local_file" "metaflow_config" {
59+
content = module.metaflow.metaflow_profile_json
60+
filename = "./metaflow_profile.json"
61+
}

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ module "metaflow-metadata-service" {
4040

4141
module "metaflow-ui" {
4242
source = "./modules/ui"
43+
count = var.ui_certificate_arn == "" ? 0 : 1
4344

4445
resource_prefix = local.resource_prefix
4546
resource_suffix = local.resource_suffix

outputs.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@ output "migration_function_arn" {
115115
}
116116

117117
output "ui_alb_dns_name" {
118-
value = module.metaflow-ui.alb_dns_name
118+
value = (length(module.metaflow-ui) > 0) ? module.metaflow-ui[0].alb_dns_name : ""
119119
description = "UI ALB DNS name"
120120
}

variables.tf

+2-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ variable "vpc_id" {
102102

103103
variable "ui_certificate_arn" {
104104
type = string
105-
description = "SSL certificate for UI"
105+
default = ""
106+
description = "SSL certificate for UI. If set to empty string, UI is disabled. "
106107
}
107108

108109
variable "extra_ui_backend_env_vars" {

0 commit comments

Comments
 (0)