File tree Expand file tree Collapse file tree 5 files changed +54
-27
lines changed
modules/aws-sagemaker-hf-pytorch-inference-model-deployment Expand file tree Collapse file tree 5 files changed +54
-27
lines changed Original file line number Diff line number Diff line change
1
+ name : Create Sagemeker Model Endpoint
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - test
7
+ - main
8
+ workflow_dispatch :
9
+
10
+ permissions :
11
+ id-token : write
12
+ contents : read
13
+
14
+ env :
15
+ AWS_REGION : us-east-1
16
+ ENVIRONMENT : ${{ github.ref_name == 'main' && 'prod' || github.ref_name == 'test' && 'test' }}
17
+
18
+ jobs :
19
+ create_model_endpoint :
20
+ runs-on : ubuntu-latest
21
+
22
+ defaults :
23
+ run :
24
+ working-directory : terraform
25
+
26
+ steps :
27
+ - uses : actions/checkout@v3
28
+
29
+ - name : Configure AWS Credentials
30
+ uses : aws-actions/configure-aws-credentials@v4
31
+ with :
32
+ audience : sts.amazonaws.com
33
+ aws-region : ${{ env.AWS_REGION }}
34
+ role-to-assume : arn:aws:iam::639269844451:role/github-actions
35
+ role-session-name : ${{ env.ENVIRONMENT }}-deployment
36
+
37
+ - name : Setup Terraform
38
+ uses : hashicorp/setup-terraform@v3
39
+
40
+ - name : Terraform Init
41
+ run : terraform init
42
+
43
+ - name : Select/Create Terraform Workspace
44
+ run : |
45
+ terraform workspace list || echo "Workspace list unavailable"
46
+ terraform workspace select --or-create ${{ env.ENVIRONMENT }}
47
+
48
+ - name : Terraform Plan
49
+ run : terraform plan
50
+
51
+ - name : Terraform Apply
52
+ run : terraform apply -auto-approve
File renamed without changes.
Original file line number Diff line number Diff line change 5
5
module "model" {
6
6
source = " ./modules/aws-sagemaker-hf-pytorch-inference-model-deployment"
7
7
aws_region = " us-east-1"
8
- model_author_name = " tabularisai"
9
8
model_name = " multilingual-sentiment-analysis"
10
- model_src = abspath (" ../model.tar.gz" )
11
9
python_version = " py310"
12
10
ubuntu_version = " 22.04"
13
11
transformers_version = " 4.37.0"
Original file line number Diff line number Diff line change @@ -8,13 +8,6 @@ locals {
8
8
ecr_image_tag = " ${ var . pytorch_version } -transformers${ var . transformers_version } -cpu-${ var . python_version } -ubuntu${ var . ubuntu_version } "
9
9
}
10
10
11
- resource "aws_s3_object" "model_upload" {
12
- bucket = var. model_bucket_name
13
- key = var. model_bucket_key
14
- source = var. model_src
15
- etag = filemd5 (var. model_src )
16
- }
17
-
18
11
resource "aws_iam_role" "model_execution_role" {
19
12
name = " ${ local . env } -sagemaker-${ var . model_name } -execution-role"
20
13
@@ -92,17 +85,9 @@ resource "aws_iam_role_policy_attachment" "ecr_policy_attachment" {
92
85
resource "aws_sagemaker_model" "model" {
93
86
name = var. model_name
94
87
execution_role_arn = aws_iam_role. model_execution_role . arn
95
- # primary_container {
96
- # image = "${local.ecr_image_name}:${local.ecr_image_tag}"
97
- # model_data_url = "s3://${aws_s3_object.model_upload.bucket}/${aws_s3_object.model_upload.key}"
98
- # }
99
-
100
88
primary_container {
101
- image = " 763104351884.dkr.ecr.us-east-1.amazonaws.com/huggingface-pytorch-inference:2.1.0-transformers4.37.0-cpu-py310-ubuntu22.04"
102
- environment = {
103
- HF_MODEL_ID = " distilbert-base-uncased"
104
- HF_TASK = " text-classification"
105
- }
89
+ image = " ${ local . ecr_image_name } :${ local . ecr_image_tag } "
90
+ model_data_url = " s3://${ var . model_bucket_name } /${ var . model_bucket_key } "
106
91
}
107
92
}
108
93
Original file line number Diff line number Diff line change @@ -5,18 +5,10 @@ variable "aws_region" {
5
5
default = " us-east-1"
6
6
}
7
7
8
- variable "model_author_name" {
9
- description = " Author name of the model"
10
- }
11
-
12
8
variable "model_name" {
13
9
description = " Name of the model"
14
10
}
15
11
16
- variable "model_src" {
17
- description = " Path to the model.tar.gz file"
18
- }
19
-
20
12
variable "python_version" {
21
13
description = " Python version"
22
14
}
You can’t perform that action at this time.
0 commit comments