Skip to content

Commit 3daef35

Browse files
committed
Tag ECS services, pull in subset of upstream changes
1 parent 5833e84 commit 3daef35

File tree

11 files changed

+62
-26
lines changed

11 files changed

+62
-26
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pre-commit run --all-files
7373
| <a name="input_ui_allow_list"></a> [ui\_allow\_list](#input\_ui\_allow\_list) | List of CIDRs we want to grant access to our Metaflow UI Service. Usually this is our VPN's CIDR blocks. | `list(string)` | `[]` | no |
7474
| <a name="input_ui_certificate_arn"></a> [ui\_certificate\_arn](#input\_ui\_certificate\_arn) | SSL certificate for UI. If no certificate arn is provided, HTTP will be used. | `string` | `null` | no |
7575
| <a name="input_ui_static_container_image"></a> [ui\_static\_container\_image](#input\_ui\_static\_container\_image) | Container image for the UI frontend app | `string` | `""` | no |
76-
| <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 |
76+
| <a name="input_vpc_cidr_blocks"></a> [vpc\_cidr\_blocks](#input\_vpc\_cidr\_blocks) | The VPC CIDR blocks that we'll access list on our Metadata Service API to allow all internal communications | `list(string)` | n/a | yes |
7777
| <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 |
7878

7979
## Outputs

examples/eks/metaflow.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module "metaflow-metadata-service" {
5959
s3_bucket_arn = module.metaflow-datastore.s3_bucket_arn
6060
subnet1_id = module.vpc.private_subnets[0]
6161
subnet2_id = module.vpc.private_subnets[1]
62-
vpc_cidr_block = module.vpc.vpc_cidr_block
62+
vpc_cidr_blocks = module.vpc.vpc_cidr_blocks
6363

6464
standard_tags = local.tags
6565
}

examples/minimal/minimal_example.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ module "vpc" {
3838

3939
module "metaflow" {
4040
source = "outerbounds/metaflow/aws"
41-
version = "0.3.0"
41+
version = "0.7.0"
4242

4343
resource_prefix = local.resource_prefix
4444
resource_suffix = local.resource_suffix
4545

4646
enable_step_functions = false
4747
subnet1_id = module.vpc.public_subnets[0]
4848
subnet2_id = module.vpc.public_subnets[1]
49-
vpc_cidr_block = module.vpc.vpc_cidr_block
49+
vpc_cidr_blocks = module.vpc.vpc_cidr_blocks
5050
vpc_id = module.vpc.vpc_id
5151

5252
tags = {

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module "metaflow-metadata-service" {
3434
s3_bucket_arn = module.metaflow-datastore.s3_bucket_arn
3535
subnet1_id = var.subnet1_id
3636
subnet2_id = var.subnet2_id
37-
vpc_cidr_block = var.vpc_cidr_block
37+
vpc_cidr_blocks = var.vpc_cidr_blocks
3838

3939
standard_tags = var.tags
4040
}

modules/metadata-service/README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ If the `access_list_cidr_blocks` variable is set, only traffic originating from
1717
|------|-------------|------|---------|:--------:|
1818
| <a name="input_access_list_cidr_blocks"></a> [access\_list\_cidr\_blocks](#input\_access\_list\_cidr\_blocks) | List of CIDRs we want to grant access to our Metaflow Metadata Service. Usually this is our VPN's CIDR blocks. | `list(string)` | n/a | yes |
1919
| <a name="input_api_basic_auth"></a> [api\_basic\_auth](#input\_api\_basic\_auth) | Enable basic auth for API Gateway? (requires key export) | `bool` | `true` | no |
20+
| <a name="input_database_name"></a> [database\_name](#input\_database\_name) | The database name | `string` | `"metaflow"` | no |
2021
| <a name="input_database_password_secret_manager_arn"></a> [database\_password\_secret\_manager\_arn](#input\_database\_password\_secret\_manager\_arn) | The arn of the database password stored in AWS secrets manager | `string` | n/a | yes |
2122
| <a name="input_database_username"></a> [database\_username](#input\_database\_username) | The database username | `string` | n/a | yes |
2223
| <a name="input_datastore_s3_bucket_kms_key_arn"></a> [datastore\_s3\_bucket\_kms\_key\_arn](#input\_datastore\_s3\_bucket\_kms\_key\_arn) | The ARN of the KMS key used to encrypt the Metaflow datastore S3 bucket | `string` | n/a | yes |
2324
| <a name="input_ecs_cluster_id"></a> [ecs\_cluster\_id](#input\_ecs\_cluster\_id) | The ID of an existing ECS cluster to run services on. If no cluster ID is specfied, a new cluster will be created. | `string` | `null` | no |
2425
| <a name="input_fargate_execution_role_arn"></a> [fargate\_execution\_role\_arn](#input\_fargate\_execution\_role\_arn) | The IAM role that grants access to ECS and Batch services which we'll use as our Metadata Service API's execution\_role for our Fargate instance | `string` | n/a | yes |
2526
| <a name="input_iam_partition"></a> [iam\_partition](#input\_iam\_partition) | IAM Partition (Select aws-us-gov for AWS GovCloud, otherwise leave as is) | `string` | `"aws"` | no |
2627
| <a name="input_is_gov"></a> [is\_gov](#input\_is\_gov) | Set to true if IAM partition is 'aws-us-gov' | `bool` | `false` | no |
27-
| <a name="input_metadata_service_container_image"></a> [metadata\_service\_container\_image](#input\_metadata\_service\_container\_image) | Container image for metadata service | `string` | `""` | no |
28+
| <a name="input_metadata_service_container_image"></a> [metadata\_service\_container\_image](#input\_metadata\_service\_container\_image) | Container image for metadata service | `string` | n/a | yes |
29+
| <a name="input_metadata_service_cpu"></a> [metadata\_service\_cpu](#input\_metadata\_service\_cpu) | ECS task CPU unit for metadata service | `number` | `512` | no |
30+
| <a name="input_metadata_service_memory"></a> [metadata\_service\_memory](#input\_metadata\_service\_memory) | ECS task memory in MiB for metadata service | `number` | `1024` | no |
2831
| <a name="input_metaflow_vpc_id"></a> [metaflow\_vpc\_id](#input\_metaflow\_vpc\_id) | ID of the Metaflow VPC this SageMaker notebook instance is to be deployed in | `string` | n/a | yes |
2932
| <a name="input_rds_master_instance_endpoint"></a> [rds\_master\_instance\_endpoint](#input\_rds\_master\_instance\_endpoint) | The database connection endpoint in address:port format | `string` | n/a | yes |
3033
| <a name="input_resource_prefix"></a> [resource\_prefix](#input\_resource\_prefix) | Prefix given to all AWS resources to differentiate between applications | `string` | n/a | yes |
@@ -33,7 +36,8 @@ If the `access_list_cidr_blocks` variable is set, only traffic originating from
3336
| <a name="input_standard_tags"></a> [standard\_tags](#input\_standard\_tags) | The standard tags to apply to every AWS resource. | `map(string)` | n/a | yes |
3437
| <a name="input_subnet1_id"></a> [subnet1\_id](#input\_subnet1\_id) | First private subnet used for availability zone redundancy | `string` | n/a | yes |
3538
| <a name="input_subnet2_id"></a> [subnet2\_id](#input\_subnet2\_id) | Second private subnet used for availability zone redundancy | `string` | n/a | yes |
36-
| <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 |
39+
| <a name="input_vpc_cidr_blocks"></a> [vpc\_cidr\_blocks](#input\_vpc\_cidr\_blocks) | The VPC CIDR blocks that we'll access list on our Metadata Service API to allow all internal communications | `list(string)` | n/a | yes |
40+
| <a name="input_with_public_ip"></a> [with\_public\_ip](#input\_with\_public\_ip) | Enable private IP by default | `bool` | `false` | no |
3741

3842
## Outputs
3943

modules/metadata-service/ec2.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ resource "aws_security_group" "metadata_service_security_group" {
77
from_port = 8080
88
to_port = 8080
99
protocol = "tcp"
10-
cidr_blocks = [var.vpc_cidr_block]
10+
cidr_blocks = var.vpc_cidr_blocks
1111
description = "Allow API calls internally"
1212
}
1313

1414
ingress {
1515
from_port = 8082
1616
to_port = 8082
1717
protocol = "tcp"
18-
cidr_blocks = [var.vpc_cidr_block]
18+
cidr_blocks = var.vpc_cidr_blocks
1919
description = "Allow API calls internally"
2020
}
2121

modules/metadata-service/ecs.tf

+10-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ resource "aws_ecs_task_definition" "this" {
1919
"name" = "${var.resource_prefix}service${var.resource_suffix}",
2020
"image" = "${var.metadata_service_container_image}",
2121
"essential" = true,
22-
"cpu" = 512,
23-
"memory" = 1024,
22+
"cpu" : var.metadata_service_cpu,
23+
"memory" : var.metadata_service_memory,
2424
"portMappings" = [
2525
{
2626
"containerPort" = 8080,
@@ -33,7 +33,7 @@ resource "aws_ecs_task_definition" "this" {
3333
],
3434
"environment" = [
3535
{ "name" = "MF_METADATA_DB_HOST", "value" = "${replace(var.rds_master_instance_endpoint, ":5432", "")}" },
36-
{ "name" = "MF_METADATA_DB_NAME", "value" = "metaflow" },
36+
{ "name" = "MF_METADATA_DB_NAME", "value" = "${var.database_name}" },
3737
{ "name" = "MF_METADATA_DB_PORT", "value" = "5432" },
3838
{ "name" = "MF_METADATA_DB_USER", "value" = "${var.database_username}" },
3939
],
@@ -57,8 +57,8 @@ resource "aws_ecs_task_definition" "this" {
5757
requires_compatibilities = ["FARGATE"]
5858
task_role_arn = aws_iam_role.metadata_svc_ecs_task_role.arn
5959
execution_role_arn = var.fargate_execution_role_arn
60-
cpu = 512
61-
memory = 1024
60+
cpu = var.metadata_service_cpu
61+
memory = var.metadata_service_memory
6262

6363
tags = merge(
6464
var.standard_tags,
@@ -93,9 +93,13 @@ resource "aws_ecs_service" "this" {
9393
container_port = 8082
9494
}
9595

96+
enable_ecs_managed_tags = true
97+
propagate_tags = "TASK_DEFINITION"
98+
99+
tags = var.standard_tags
100+
96101
lifecycle {
97102
ignore_changes = [desired_count]
98103
}
99104

100-
tags = var.standard_tags
101105
}

modules/metadata-service/variables.tf

+27-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ variable "api_basic_auth" {
99
description = "Enable basic auth for API Gateway? (requires key export)"
1010
}
1111

12+
variable "database_name" {
13+
type = string
14+
default = "metaflow"
15+
description = "The database name"
16+
}
17+
1218
variable "ecs_cluster_id" {
1319
type = string
1420
default = null
@@ -50,10 +56,21 @@ variable "is_gov" {
5056

5157
variable "metadata_service_container_image" {
5258
type = string
53-
default = ""
5459
description = "Container image for metadata service"
5560
}
5661

62+
variable "metadata_service_cpu" {
63+
type = number
64+
default = 512
65+
description = "ECS task CPU unit for metadata service"
66+
}
67+
68+
variable "metadata_service_memory" {
69+
type = number
70+
default = 1024
71+
description = "ECS task memory in MiB for metadata service"
72+
}
73+
5774
variable "metaflow_vpc_id" {
5875
type = string
5976
description = "ID of the Metaflow VPC this SageMaker notebook instance is to be deployed in"
@@ -94,7 +111,13 @@ variable "subnet2_id" {
94111
description = "Second private subnet used for availability zone redundancy"
95112
}
96113

97-
variable "vpc_cidr_block" {
98-
type = string
99-
description = "The VPC CIDR block that we'll access list on our Metadata Service API to allow all internal communications"
114+
variable "vpc_cidr_blocks" {
115+
type = list(string)
116+
description = "The VPC CIDR blocks that we'll access list on our Metadata Service API to allow all internal communications"
117+
}
118+
119+
variable "with_public_ip" {
120+
type = bool
121+
default = false
122+
description = "Enable private IP by default"
100123
}

modules/ui/ecs_ui_backend.tf

+4-2
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ resource "aws_ecs_service" "ui_backend" {
7676
container_port = 8083
7777
}
7878

79+
enable_ecs_managed_tags = true
80+
propagate_tags = "TASK_DEFINITION"
81+
82+
tags = var.standard_tags
7983
lifecycle {
8084
ignore_changes = [desired_count]
8185
}
82-
83-
tags = var.standard_tags
8486
}

modules/ui/ecs_ui_static.tf

+5-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ resource "aws_ecs_service" "ui_static" {
6262
container_port = 3000
6363
}
6464

65+
enable_ecs_managed_tags = true
66+
propagate_tags = "TASK_DEFINITION"
67+
68+
tags = var.standard_tags
69+
6570
lifecycle {
6671
ignore_changes = [desired_count]
6772
}
68-
69-
tags = var.standard_tags
7073
}

variables.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ variable "subnet2_id" {
149149
description = "Second subnet used for availability zone redundancy"
150150
}
151151

152-
variable "vpc_cidr_block" {
153-
type = string
154-
description = "The VPC CIDR block that we'll access list on our Metadata Service API to allow all internal communications"
152+
variable "vpc_cidr_blocks" {
153+
type = list(string)
154+
description = "The VPC CIDR blocks that we'll access list on our Metadata Service API to allow all internal communications"
155155
}
156156

157157
variable "vpc_id" {

0 commit comments

Comments
 (0)