-
Notifications
You must be signed in to change notification settings - Fork 0
/
sagemaker.tf
53 lines (43 loc) · 1.35 KB
/
sagemaker.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Create role to allow github actions to perform actions on other buckets
resource "aws_iam_role" "sagemaker_role" {
name = "${var.prefix}-sagemaker"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "sagemaker.amazonaws.com"
}
},
]
})
}
resource "aws_iam_role_policy_attachment" "sagemaker_full_access" {
role = aws_iam_role.sagemaker_role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonSageMakerFullAccess"
}
resource "aws_sagemaker_model" "api" {
name = "${var.prefix}-api-model"
execution_role_arn = aws_iam_role.sagemaker_role.arn
primary_container {
image = "${aws_ecr_repository.python_scikit_learn.repository_url}:latest" # Specify your model's Docker image
}
}
resource "aws_sagemaker_endpoint_configuration" "api" {
name = "${var.prefix}-config"
production_variants {
variant_name = "${var.prefix}-api-1gb"
model_name = aws_sagemaker_model.api.name
serverless_config {
max_concurrency = 3
memory_size_in_mb = 4096
}
}
}
resource "aws_sagemaker_endpoint" "api" {
name = "${var.prefix}-api"
endpoint_config_name = aws_sagemaker_endpoint_configuration.api.name
depends_on = [aws_sagemaker_endpoint_configuration.api]
}