Skip to content

Commit d831909

Browse files
Merge pull request #2 from Essens/outerbounds-master
merge changes from outerbounds-master
2 parents 9cd8441 + ccf583a commit d831909

File tree

12 files changed

+68
-31
lines changed

12 files changed

+68
-31
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ resource "local_file" "metaflow_config" {
108108
| <a name="input_compute_environment_instance_types"></a> [compute\_environment\_instance\_types](#input\_compute\_environment\_instance\_types) | The instance types for the compute environment | `list(string)` | <pre>[<br> "c4.large",<br> "c4.xlarge",<br> "c4.2xlarge",<br> "c4.4xlarge",<br> "c4.8xlarge"<br>]</pre> | no |
109109
| <a name="input_compute_environment_max_vcpus"></a> [compute\_environment\_max\_vcpus](#input\_compute\_environment\_max\_vcpus) | Maximum VCPUs for Batch Compute Environment [16-96] | `number` | `64` | no |
110110
| <a name="input_compute_environment_min_vcpus"></a> [compute\_environment\_min\_vcpus](#input\_compute\_environment\_min\_vcpus) | Minimum VCPUs for Batch Compute Environment [0-16] for EC2 Batch Compute Environment (ignored for Fargate) | `number` | `8` | no |
111+
| <a name="input_db_engine_version"></a> [db\_engine\_version](#input\_db\_engine\_version) | n/a | `string` | `"11"` | no |
112+
| <a name="input_db_instance_type"></a> [db\_instance\_type](#input\_db\_instance\_type) | RDS instance type to launch for PostgresQL database. | `string` | `"db.t2.small"` | no |
113+
| <a name="input_db_migrate_lambda_zip_file"></a> [db\_migrate\_lambda\_zip\_file](#input\_db\_migrate\_lambda\_zip\_file) | Output path for the zip file containing the DB migrate lambda | `string` | `null` | no |
111114
| <a name="input_enable_custom_batch_container_registry"></a> [enable\_custom\_batch\_container\_registry](#input\_enable\_custom\_batch\_container\_registry) | Provisions infrastructure for custom Amazon ECR container registry if enabled | `bool` | `false` | no |
115+
| <a name="input_enable_key_rotation"></a> [enable\_key\_rotation](#input\_enable\_key\_rotation) | Enable key rotation for KMS keys | `bool` | `false` | no |
112116
| <a name="input_enable_step_functions"></a> [enable\_step\_functions](#input\_enable\_step\_functions) | Provisions infrastructure for step functions if enabled | `bool` | n/a | yes |
113117
| <a name="input_extra_ui_backend_env_vars"></a> [extra\_ui\_backend\_env\_vars](#input\_extra\_ui\_backend\_env\_vars) | Additional environment variables for UI backend container | `map(string)` | `{}` | no |
114118
| <a name="input_extra_ui_static_env_vars"></a> [extra\_ui\_static\_env\_vars](#input\_extra\_ui\_static\_env\_vars) | Additional environment variables for UI static app | `map(string)` | `{}` | no |

examples/eks_argo/metaflow.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ data "aws_availability_zones" "available" {
2020

2121
module "metaflow-datastore" {
2222
source = "outerbounds/metaflow/aws//modules/datastore"
23-
version = "0.8.0"
23+
version = "0.10.0"
2424

2525
force_destroy_s3_bucket = true
2626

@@ -37,18 +37,18 @@ module "metaflow-datastore" {
3737

3838
module "metaflow-common" {
3939
source = "outerbounds/metaflow/aws//modules/common"
40-
version = "0.8.0"
40+
version = "0.10.0"
4141
}
4242

4343
module "metaflow-metadata-service" {
4444
source = "outerbounds/metaflow/aws//modules/metadata-service"
45-
version = "0.8.0"
45+
version = "0.10.0"
4646

4747
resource_prefix = local.resource_prefix
4848
resource_suffix = local.resource_suffix
4949

5050
access_list_cidr_blocks = []
51-
api_basic_auth = true
51+
enable_api_basic_auth = true
5252
database_name = module.metaflow-datastore.database_name
5353
database_password = module.metaflow-datastore.database_password
5454
database_username = module.metaflow-datastore.database_username

examples/eks_argo/vpc.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# VPC infra using https://github.com/terraform-aws-modules/terraform-aws-vpc
33
module "vpc" {
44
source = "terraform-aws-modules/vpc/aws"
5-
version = "3.13.0"
5+
version = "5.1.2"
66

77
name = "${local.resource_prefix}-${local.resource_suffix}"
88
cidr = "10.10.0.0/16"

main.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
module "metaflow-datastore" {
22
source = "./modules/datastore"
33

4-
db_instance_type = var.db_instance_type
5-
64
force_destroy_s3_bucket = var.force_destroy_s3_bucket
5+
enable_key_rotation = var.enable_key_rotation
76

87
resource_prefix = local.resource_prefix
98
resource_suffix = local.resource_suffix
@@ -13,6 +12,9 @@ module "metaflow-datastore" {
1312
subnet1_id = var.subnet1_id
1413
subnet2_id = var.subnet2_id
1514

15+
db_instance_type = var.db_instance_type
16+
db_engine_version = var.db_engine_version
17+
1618
standard_tags = var.tags
1719
}
1820

@@ -26,6 +28,7 @@ module "metaflow-metadata-service" {
2628
database_name = module.metaflow-datastore.database_name
2729
database_password = module.metaflow-datastore.database_password
2830
database_username = module.metaflow-datastore.database_username
31+
db_migrate_lambda_zip_file = var.db_migrate_lambda_zip_file
2932
datastore_s3_bucket_kms_key_arn = module.metaflow-datastore.datastore_s3_bucket_kms_key_arn
3033
enable_api_basic_auth = var.metadata_service_enable_api_basic_auth
3134
enable_api_gateway = var.metadata_service_enable_api_gateway

modules/datastore/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ To read more, see [the Metaflow docs](https://docs.metaflow.org/metaflow-on-aws/
2121
|------|-------------|------|---------|:--------:|
2222
| <a name="input_db_engine"></a> [db\_engine](#input\_db\_engine) | n/a | `string` | `"postgres"` | no |
2323
| <a name="input_db_engine_version"></a> [db\_engine\_version](#input\_db\_engine\_version) | n/a | `string` | `"11"` | no |
24-
| <a name="input_db_instance_type"></a> [db\_instance\_type](#input\_db\_instance\_type) | RDS instance type to launch for PostgresQL database. | `string` | `"db.t2.small"` | no |
24+
| <a name="input_db_instance_type"></a> [db\_instance\_type](#input\_db\_instance\_type) | RDS instance type to launch for PostgresQL database. | `string` | `"db.t3.small"` | no |
2525
| <a name="input_db_name"></a> [db\_name](#input\_db\_name) | Name of PostgresQL database for Metaflow service. | `string` | `"metaflow"` | no |
2626
| <a name="input_db_username"></a> [db\_username](#input\_db\_username) | PostgresQL username; defaults to 'metaflow' | `string` | `"metaflow"` | no |
27+
| <a name="input_enable_key_rotation"></a> [enable\_key\_rotation](#input\_enable\_key\_rotation) | Enable key rotation for KMS keys | `bool` | `false` | no |
2728
| <a name="input_force_destroy_s3_bucket"></a> [force\_destroy\_s3\_bucket](#input\_force\_destroy\_s3\_bucket) | Empty S3 bucket before destroying via terraform destroy | `bool` | `false` | no |
2829
| <a name="input_metadata_service_security_group_id"></a> [metadata\_service\_security\_group\_id](#input\_metadata\_service\_security\_group\_id) | The security group ID used by the MetaData service. We'll grant this access to our DB. | `string` | n/a | yes |
2930
| <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 |

modules/datastore/kms.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
resource "aws_kms_key" "s3" {
2-
description = "This key is used to encrypt and decrypt the S3 bucket used to store blobs."
2+
description = "This key is used to encrypt and decrypt the S3 bucket used to store blobs."
3+
enable_key_rotation = var.enable_key_rotation
34

45
tags = var.standard_tags
56
}
67

78
resource "aws_kms_key" "rds" {
8-
description = "This key is used to encrypt and decrypt the RDS database used to store flow execution data."
9+
description = "This key is used to encrypt and decrypt the RDS database used to store flow execution data."
10+
enable_key_rotation = var.enable_key_rotation
911

1012
tags = var.standard_tags
1113
}

modules/datastore/variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
variable "db_instance_type" {
22
type = string
33
description = "RDS instance type to launch for PostgresQL database."
4-
default = "db.t2.small"
4+
default = "db.t3.small"
55
}
66

77
variable "db_engine" {
@@ -65,3 +65,9 @@ variable "subnet2_id" {
6565
type = string
6666
description = "Second subnet used for availability zone redundancy"
6767
}
68+
69+
variable "enable_key_rotation" {
70+
type = bool
71+
description = "Enable key rotation for KMS keys"
72+
default = false
73+
}

modules/metadata-service/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ If the `access_list_cidr_blocks` variable is set, only traffic originating from
2020
| <a name="input_database_password"></a> [database\_password](#input\_database\_password) | The database password | `string` | n/a | yes |
2121
| <a name="input_database_username"></a> [database\_username](#input\_database\_username) | The database username | `string` | n/a | yes |
2222
| <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 |
23+
| <a name="input_db_migrate_lambda_zip_file"></a> [db\_migrate\_lambda\_zip\_file](#input\_db\_migrate\_lambda\_zip\_file) | Output path for the zip file containing the DB migrate lambda | `string` | `null` | no |
2324
| <a name="input_enable_api_basic_auth"></a> [enable\_api\_basic\_auth](#input\_enable\_api\_basic\_auth) | Enable basic auth for API Gateway? (requires key export) | `bool` | `true` | no |
2425
| <a name="input_enable_api_gateway"></a> [enable\_api\_gateway](#input\_enable\_api\_gateway) | Enable API Gateway for public metadata service endpoint | `bool` | `true` | no |
2526
| <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 |

modules/metadata-service/lambda.tf

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,13 @@ resource "aws_iam_role_policy" "grant_lambda_ecs_vpc" {
7878
policy = data.aws_iam_policy_document.lambda_ecs_task_execute_policy_vpc.json
7979
}
8080

81-
resource "local_file" "db_migrate_lambda" {
82-
content = <<EOF
81+
data "archive_file" "db_migrate_lambda" {
82+
type = "zip"
83+
output_file_mode = "0666"
84+
output_path = local.db_migrate_lambda_zip_file
85+
86+
source {
87+
content = <<EOF
8388
import os, json
8489
from urllib import request
8590
@@ -101,21 +106,14 @@ def handler(event, context):
101106
print(response)
102107
return(response)
103108
EOF
104-
filename = local.db_migrate_lambda_source_file
105-
}
106-
107-
data "archive_file" "db_migrate_lambda" {
108-
type = "zip"
109-
source_file = local.db_migrate_lambda_source_file
110-
output_file_mode = "0666"
111-
output_path = local.db_migrate_lambda_zip_file
112-
depends_on = [local_file.db_migrate_lambda]
109+
filename = "index.py"
110+
}
113111
}
114112

115113
resource "aws_lambda_function" "db_migrate_lambda" {
116114
function_name = local.db_migrate_lambda_name
117115
handler = "index.handler"
118-
runtime = "python3.7"
116+
runtime = "python3.12"
119117
memory_size = 128
120118
timeout = 900
121119
description = "Trigger DB Migration"

modules/metadata-service/locals.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ locals {
2222
api_gateway_stage_name = "api"
2323
api_gateway_usage_plan_name = "${var.resource_prefix}usage-plan${var.resource_suffix}"
2424

25-
db_migrate_lambda_source_file = "${path.module}/index.py"
26-
db_migrate_lambda_zip_file = "${path.module}/db_migrate_lambda.zip"
27-
db_migrate_lambda_name = "${var.resource_prefix}db_migrate${var.resource_suffix}"
28-
lambda_ecs_execute_role_name = "${var.resource_prefix}lambda_ecs_execute${var.resource_suffix}"
25+
db_migrate_lambda_zip_file = coalesce(var.db_migrate_lambda_zip_file, "${path.module}/db_migrate_lambda.zip")
26+
db_migrate_lambda_name = "${var.resource_prefix}db_migrate${var.resource_suffix}"
27+
lambda_ecs_execute_role_name = "${var.resource_prefix}lambda_ecs_execute${var.resource_suffix}"
2928

3029
cloudwatch_logs_arn_prefix = "arn:${var.iam_partition}:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}"
3130
}

0 commit comments

Comments
 (0)