This is an example module to accompany the Code & Wild blog post Building a Machine Learning Orchestration Platform: Part 1.
As mentioned on the blog post, this module makes a few assumptions when it comes to naming conventions and to some of the monitoring tools used which are external to AWS, like Datadog for managing your application logs.
The module will link a GitHub repository to a CodePipeline pipeline which will check out the code and run a CodeBuild project that will execute the codebuild/buildspec.yml
file. An example GitHub repository that can be combined with this module can be found in our public GitHub profile, under the name opensource-ml-model-template. That repository will allow the pipeline to build and push a Docker image to ECR which then can be run via ECS Fargate.
The module also creates an ECR repository, an ECS task definition and some other supporting infrastructure.
Name | Version |
---|---|
terraform | ~> 1.0.0 |
aws | ~> 3.0 |
Name | Version |
---|---|
aws | ~> 3.0 |
No modules.
Name | Description | Type | Default | Required |
---|---|---|---|---|
additional_iam_policy | Additional IAM policy to attach to the execution role of the ECS task | string |
"" |
no |
codebuild_security_group_ids | Security Group IDs where we want the CD Pipeline CodeBuild Project to run in | list(string) |
n/a | yes |
codebuild_subnets | Subnets where we want the CD Pipeline CodeBuild Project to run in | list(string) |
n/a | yes |
codebuild_vpc_id | VPC id where we want the CD Pipeline CodeBuild Project to run in | string |
n/a | yes |
codestar_connection_arn | AWS CodeStar Connection ARN to use to connect GitHub with the CD Pipeline | string |
n/a | yes |
cpu | CPU allocation for the ECS task | string |
"256" |
no |
datadog_api_key | Datadog API key to use for the Firelens log driver | string |
n/a | yes |
environment | Environment of the model (e.g. production, staging, development) | string |
"production" |
no |
github_branch | GitHub branch that should trigger the CD Pipeline | string |
"main" |
no |
github_repository | GitHub repository for the model code | string |
n/a | yes |
memory | Memory allocation for the ECS task | string |
"512" |
no |
model_name | Name that uniquely identifies the ML model | string |
n/a | yes |
parameter_store_kms_key | KMS key ID to use to decrypt SSM parameters at run time on the ECS task | string |
n/a | yes |
No outputs.
Replace values as required.
module "ml_model" {
source = "github.com/BloomAndWild/terraform-aws-ml-model"
model_name = "example-model"
github_repository = "BloomAndWild/opensource-ml-model-template"
codestar_connection_arn = "arn:aws:codestar-connections:eu-west-1:XXXXXXXXXXXX:connection/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
codebuild_vpc_id = "vpc-xxxxxxx"
codebuild_security_group_ids = ["sg-xxxxxxx"]
codebuild_subnets = ["subnet-xxxxxxxxxxxx", "subnet-xxxxxxxxxxxx"]
datadog_api_key = "xxxxxxxxxxxxxxxxxxxxxx"
parameter_store_kms_key = "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}