Skip to content

Commit d5842d9

Browse files
committed
clear terraform
1 parent 61bc8b5 commit d5842d9

File tree

5 files changed

+42
-12
lines changed

5 files changed

+42
-12
lines changed

terraform/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ locals {
44

55
module "model" {
66
source = "./modules/aws-sagemaker-hf-pytorch-inference-model-deployment"
7-
aws_region = "us-east-1"
87
model_name = "${local.env}-multilingual-sentiment-analysis"
98
python_version = "py310"
109
ubuntu_version = "22.04"

terraform/modules/aws-sagemaker-hf-pytorch-inference-model-deployment/main.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
data "aws_caller_identity" "current" {}
22

3+
data "aws_region" "current" {}
4+
35
locals {
46
account_id = data.aws_caller_identity.current.account_id
5-
ecr_image_name = "763104351884.dkr.ecr.${var.aws_region}.amazonaws.com/huggingface-pytorch-inference"
7+
ecr_image_name = "763104351884.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/huggingface-pytorch-inference"
68
ecr_image_tag = "${var.pytorch_version}-transformers${var.transformers_version}-cpu-${var.python_version}-ubuntu${var.ubuntu_version}"
79
}
810

@@ -64,7 +66,7 @@ resource "aws_iam_policy" "ecr_policy" {
6466
"ecr:ListTagsForResource",
6567
"ecr:DescribeImageScanFindings",
6668
],
67-
"Resource" : "arn:aws:ecr:${var.aws_region}:*:repository/*"
69+
"Resource" : "arn:aws:ecr:${data.aws_region.current.name}:*:repository/*"
6870
}
6971
]
7072
})
@@ -95,7 +97,7 @@ resource "aws_sagemaker_endpoint_configuration" "model_endpoint_configuration" {
9597
production_variants {
9698
initial_variant_weight = 1
9799
model_name = aws_sagemaker_model.model.name
98-
variant_name = "Version1"
100+
variant_name = var.endpoint_variant_name
99101

100102
serverless_config {
101103
memory_size_in_mb = var.memory_size_in_mb

terraform/modules/aws-sagemaker-hf-pytorch-inference-model-deployment/outputs.tf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,35 @@
22
output "sagemaker_endpoint_name" {
33
value = aws_sagemaker_endpoint.model_endpoint.name
44
}
5+
6+
output "sagemaker_endpoint_arn" {
7+
value = aws_sagemaker_endpoint.model_endpoint.arn
8+
}
9+
10+
output "sagemaker_endpoint_config_name" {
11+
value = aws_sagemaker_endpoint_configuration.model_endpoint_configuration.name
12+
}
13+
14+
output "sagemaker_endpoint_config_arn" {
15+
value = aws_sagemaker_endpoint_configuration.model_endpoint_configuration.arn
16+
}
17+
18+
output "sagemaker_model_name" {
19+
value = aws_sagemaker_model.model.name
20+
}
21+
22+
output "sagemaker_model_arn" {
23+
value = aws_sagemaker_model.model.arn
24+
}
25+
26+
output "sagemaker_model_image" {
27+
value = aws_sagemaker_model.model.primary_container.0.image
28+
}
29+
30+
output "sagemaker_model_data_url" {
31+
value = aws_sagemaker_model.model.primary_container.0.model_data_url
32+
}
33+
34+
output "sagemaker_model_execution_role_arn" {
35+
value = aws_sagemaker_model.model.execution_role_arn
36+
}

terraform/modules/aws-sagemaker-hf-pytorch-inference-model-deployment/variables.tf

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
2-
3-
variable "aws_region" {
4-
description = "AWS region"
5-
default = "us-east-1"
6-
}
7-
81
variable "model_name" {
92
description = "Name of the model"
103
}
114

5+
variable "endpoint_variant_name" {
6+
description = "Name of the endpoint variant"
7+
}
8+
129
variable "python_version" {
1310
description = "Python version"
1411
}

terraform/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ terraform {
1616
}
1717

1818
provider "aws" {
19-
region = var.aws_region
19+
region = "us-east-1"
2020
}

0 commit comments

Comments
 (0)