Deploy with Terraform

Use Terraform to deploy Deepgram on Amazon SageMaker from an AWS Marketplace Model Package subscription.

This guide provides a complete Terraform configuration for deploying Deepgram on Amazon SageMaker. The configuration creates an IAM execution role, a SageMaker Model from your AWS Marketplace subscription, an Endpoint Configuration, and a live Endpoint. An optional module adds auto-scaling. The same configuration can deploy either a real-time endpoint (the default) or an asynchronous endpoint that processes large pre-recorded files from S3 and can scale to zero — set enable_async_inference = true.

Before running Terraform, you must subscribe to a Deepgram product on the AWS Marketplace and note the Model Package ARN. Subscribe via the AWS Management Console or the AWS Marketplace API, then see Find the Model Package ARN.

Prerequisites

  • Terraform 1.5 or later
  • The Terraform AWS provider 5.56 or later, which is the first release supporting inference_ami_version
  • AWS credentials configured for the target account (via environment variables, shared credentials file, or an IAM role)
  • An active AWS Marketplace subscription to a Deepgram SageMaker product. You can subscribe through the console or, if you provision infrastructure as code, via the Marketplace API.
  • The Model Package ARN for the subscribed product. See Find the Model Package ARN for how to locate it in the AWS Marketplace Manage subscriptions console.

Subscribe to a Deepgram product via the Marketplace API

If you provision infrastructure as code, you can subscribe to a Deepgram SageMaker product entirely through the AWS Marketplace API instead of the console. This section is an alternative to Subscribe to Deepgram Products via AWS Marketplace Console — use whichever method fits your workflow, then continue to Find the Model Package ARN.

The steps below use the AWS CLI, but AWS also publishes SDKs for many languages — including Python (Boto3), Node.js, Java, Go, and .NET — that expose the same Marketplace Discovery and Agreement Service APIs. Use whichever SDK fits your stack to build your own subscription automations and scripts.

Subscribing creates a billing agreement on your AWS account. You are not charged until you deploy a SageMaker Endpoint and send it traffic — the usage-based pricing term has no upfront cost — but AcceptAgreementRequest (the last step below) is not a dry run. It creates a real, active agreement.

Permissions

The AWSMarketplaceManageSubscriptions policy referenced in Prerequisites covers product discovery (SearchListings, GetOffer, GetOfferTerms, ListPurchaseOptions, and similar) but does not include the AWS Marketplace Agreement Service actions this flow also needs: CreateAgreementRequest, AcceptAgreementRequest, DescribeAgreement, SearchAgreements, and GetAgreementTerms. Either attach AWSMarketplaceFullAccess or add those five actions to a custom policy alongside AWSMarketplaceManageSubscriptions.

1

Find the product ID

List Deepgram’s SageMaker-deployable products, filtered by fulfillment type and seller:

$aws marketplace-discovery search-listings \
> --region us-east-1 \
> --filters '[
> {"filterType": "FULFILLMENT_OPTION_TYPE", "filterValues": ["SAGEMAKER_MODEL"]},
> {"filterType": "PUBLISHER", "filterValues": ["6efa21f9-9a33-4cae-ba44-756436fa71dd"]}
> ]' \
> --query 'listingSummaries[].{name:listingName,productId:associatedEntities[0].product.productId}'
1[
2 {
3 "name": "Deepgram Voice AI Nova-3 Monolingual Speech-to-Text (STT) Streaming",
4 "productId": "prod-tnv5pm6nlcm44"
5 },
6 {
7 "name": "Deepgram Voice AI- Aura-2 Text-to-Speech- English",
8 "productId": "prod-..."
9 }
10]

6efa21f9-9a33-4cae-ba44-756436fa71dd is Deepgram’s AWS Marketplace seller profile ID. Note the productId for the listing you want to deploy (eg. prod-tnv5pm6nlcm44 for Nova-3 Monolingual Streaming).

Calls the SearchListings action of the AWS Marketplace Discovery API.

2

Find the standard offer for that product

$aws marketplace-discovery list-purchase-options \
> --region us-east-1 \
> --filters '[{"filterType": "PRODUCT_ID", "filterValues": ["prod-tnv5pm6nlcm44"]}]' \
> --query 'purchaseOptions[].{offerId:purchaseOptionId,name:purchaseOptionName,badges:badges}'

This can return more than one purchase option — for example, a private offer your account manager extended to you, alongside the standard public offer. The standard public offer has no PRIVATE_PRICING badge and no custom purchaseOptionName (AWS labels it "Offer created on <timestamp>"). Use a private offer’s ID instead if your account has negotiated pricing.

Calls the ListPurchaseOptions action of the AWS Marketplace Discovery API.

3

Get the offer's proposal ID and pricing model

$aws marketplace-discovery get-offer --region us-east-1 --offer-id <offer-id-from-previous-step>

Note the agreementProposalId and pricingModel.pricingModelType from the response — you need both for the next steps.

Calls the GetOffer action of the AWS Marketplace Discovery API.

4

Get the offer's terms

$aws marketplace-discovery get-offer-terms --region us-east-1 --offer-id <offer-id>

The response lists one or more terms, each with an id. For a USAGE-priced Deepgram SageMaker product, expect LegalTerm, SupportTerm, and UsageBasedPricingTerm — collect all three id values. Deepgram’s public SageMaker listings also include a FreeTrialPricingTerm (14 days); collect its id too if you want to claim the trial. See Required terms by pricing model if the offer uses a different pricing model.

Calls the GetOfferTerms action of the AWS Marketplace Discovery API.

5

Generate a quote

$aws marketplace-agreement create-agreement-request \
> --region us-east-1 \
> --agreement-proposal-identifier <agreementProposalId-from-step-3> \
> --intent NEW \
> --requested-terms '[
> {"id": "<LegalTerm id>"},
> {"id": "<SupportTerm id>"},
> {"id": "<UsageBasedPricingTerm id>"},
> {"id": "<FreeTrialPricingTerm id>"}
> ]'

Returns an agreementRequestId and a chargeSummary. For usage-based pricing, newAgreementValue is "0.00" — you’re only quoted for the mandatory terms, not future usage.

Calls the CreateAgreementRequest action of the AWS Marketplace Agreement Service API.

FreeTrialPricingTerm can be accepted only once per product. If your account has already used the trial for this product, omit that term’s id from requestedTerms — including it again returns a ValidationException. If your account already has an active agreement for this product at all, the whole call fails with ValidationException / UNSUPPORTED_ACTION (“This action is not supported when an active agreement exists on the same resourceId”). Check first with the SearchAgreements action: aws marketplace-agreement search-agreements --region us-east-1 --catalog AWSMarketplace --filters '[{"name":"PartyType","values":["Acceptor"]},{"name":"AgreementType","values":["PurchaseAgreement"]},{"name":"ResourceIdentifier","values":["<productId>"]}]' — if an agreement with "status": "ACTIVE" already exists, you’re already subscribed; skip to Find the Model Package ARN.

6

Accept the quote to subscribe

$aws marketplace-agreement accept-agreement-request \
> --region us-east-1 \
> --agreement-request-id <agreementRequestId-from-previous-step>

Returns the new agreementId. This is the subscribe action — it’s equivalent to clicking Subscribe in the console.

Calls the AcceptAgreementRequest action of the AWS Marketplace Agreement Service API.

7

Confirm the subscription is active

$aws marketplace-agreement describe-agreement --region us-east-1 --agreement-id <agreementId>

status moves from ACTIVE immediately, but the underlying entitlement can take a few minutes to provision — the same delay you’d see waiting on the console’s subscription page. Poll aws marketplace-agreement get-agreement-entitlements --region us-east-1 --agreement-id <agreementId> until it clears PENDING/PROVISIONING_IN_PROGRESS before continuing to Find the Model Package ARN.

Calls the DescribeAgreement and GetAgreementEntitlements actions of the AWS Marketplace Agreement Service API.

Find the Model Package ARN

The Terraform configuration references the Model Package ARN for the product version and AWS Region you plan to deploy. The AWS Marketplace surfaces the ARN through the CLI configuration view.

1

In the AWS Management Console, navigate to the AWS Marketplace Manage subscriptions console

2

On the Active subscriptions tab, find the subscription for the Deepgram product you want to deploy (eg. Deepgram Voice AI- Nova-3 Monolingual Speech-to-Text (STT) Streaming)

3

Click the Configure button in the Actions column on the right-hand side

4

In the Setup box, under Service, choose AWS command line interface (CLI)

5

Under the Version header, select the product version from the dropdown. If the listing has more than one version, read the version name and the release notes to understand the set of languages (or features) each version provides, and choose the version that matches your needs

6

Scroll down. On the right-hand side of the page, a list of Model ARNs is shown. Note the correct Model Package ARN for the AWS Region you plan to deploy to

Project layout

deepgram-sagemaker-terraform/
├── main.tf # Provider and resource definitions
├── variables.tf # Input variables
├── outputs.tf # Endpoint name, ARN, and status outputs
└── terraform.tfvars # Your variable values (do not commit secrets)

Variables

Create variables.tf with the input variables the configuration needs. The only required value is the Model Package ARN from your Marketplace subscription.

variables.tf
1variable "aws_region" {
2 description = "AWS region where the SageMaker Endpoint will be deployed."
3 type = string
4 default = "us-east-1"
5}
6
7variable "model_package_arn" {
8 description = "ARN of the Deepgram Model Package from AWS Marketplace."
9 type = string
10}
11
12variable "model_name" {
13 description = "Name for the SageMaker Model resource."
14 type = string
15 default = "deepgram-stt"
16}
17
18variable "endpoint_name" {
19 description = "Name for the SageMaker Endpoint."
20 type = string
21 default = "deepgram-stt-endpoint"
22}
23
24variable "instance_type" {
25 description = "SageMaker instance type for the endpoint."
26 type = string
27 default = "ml.g5.2xlarge"
28}
29
30variable "inference_ami_version" {
31 description = "SageMaker-managed host AMI (NVIDIA driver + container runtime) for the production variant. Defaults to the latest available version. Set to \"\" to use the SageMaker default for your instance type."
32 type = string
33 default = "al2023-ami-sagemaker-inference-gpu-4-1"
34
35 validation {
36 condition = contains([
37 "",
38 "al2-ami-sagemaker-inference-gpu-2",
39 "al2-ami-sagemaker-inference-gpu-2-1",
40 "al2-ami-sagemaker-inference-gpu-3-1",
41 "al2023-ami-sagemaker-inference-gpu-4-1",
42 ], var.inference_ami_version)
43 error_message = "inference_ami_version must be a supported GPU AMI version, or \"\" to use the SageMaker default."
44 }
45}
46
47variable "initial_instance_count" {
48 description = "Number of instances to launch at endpoint creation."
49 type = number
50 default = 1
51}
52
53variable "variant_name" {
54 description = "Name of the production variant."
55 type = string
56 default = "AllTraffic"
57}
58
59variable "deepgram_engine_env" {
60 description = "Map of DEEPGRAM_ENGINE_* environment variables for TOML overrides."
61 type = map(string)
62 default = {}
63}
64
65variable "deepgram_api_env" {
66 description = "Map of DEEPGRAM_API_* environment variables for TOML overrides."
67 type = map(string)
68 default = {}
69}
70
71variable "enable_autoscaling" {
72 description = "Enable auto-scaling for the endpoint."
73 type = bool
74 default = false
75}
76
77variable "autoscaling_min_capacity" {
78 description = "Minimum instance count for auto-scaling."
79 type = number
80 default = 1
81}
82
83variable "autoscaling_max_capacity" {
84 description = "Maximum instance count for auto-scaling."
85 type = number
86 default = 4
87}
88
89variable "autoscaling_target_value" {
90 description = "Target concurrent requests per instance for the scaling policy."
91 type = number
92 default = 5.0
93}
94
95variable "enable_async_inference" {
96 description = "Deploy an asynchronous endpoint (queued, S3 in/out) instead of a real-time endpoint. Async endpoints accept only asynchronous invocations."
97 type = bool
98 default = false
99}
100
101variable "async_s3_output_path" {
102 description = "S3 URI for async transcription output, e.g. s3://my-bucket/output/. Required when enable_async_inference = true."
103 type = string
104 default = ""
105
106 validation {
107 condition = var.async_s3_output_path == "" || can(regex("^s3://", var.async_s3_output_path))
108 error_message = "async_s3_output_path must be an s3:// URI."
109 }
110}
111
112variable "async_s3_failure_path" {
113 description = "Optional S3 URI for async failure output, e.g. s3://my-bucket/failures/."
114 type = string
115 default = ""
116}

In async mode, autoscaling_target_value is interpreted as the target ApproximateBacklogSizePerInstance (queued requests per instance), and autoscaling_min_capacity may be set to 0 to enable scale-to-zero. In real-time mode it remains concurrent-requests-per-instance with a minimum of 1.

Main configuration

Create main.tf with the provider, IAM role, and SageMaker resources. The configuration uses the Model Package ARN from your AWS Marketplace subscription to create the model without referencing a container image directly.

main.tf
1###############################################################################
2# Provider
3###############################################################################
4
5terraform {
6 required_version = ">= 1.5"
7
8 required_providers {
9 aws = {
10 source = "hashicorp/aws"
11 version = ">= 5.56" # inference_ami_version requires provider >= 5.56.0
12 }
13 }
14}
15
16provider "aws" {
17 region = var.aws_region
18}
19
20###############################################################################
21# IAM Role — SageMaker Execution
22###############################################################################
23
24data "aws_iam_policy_document" "sagemaker_assume_role" {
25 statement {
26 actions = ["sts:AssumeRole"]
27
28 principals {
29 type = "Service"
30 identifiers = ["sagemaker.amazonaws.com"]
31 }
32 }
33}
34
35resource "aws_iam_role" "sagemaker_execution" {
36 name = "${var.model_name}-execution-role"
37 assume_role_policy = data.aws_iam_policy_document.sagemaker_assume_role.json
38}
39
40resource "aws_iam_role_policy_attachment" "sagemaker_full_access" {
41 role = aws_iam_role.sagemaker_execution.name
42 policy_arn = "arn:aws:iam::aws:policy/AmazonSageMakerFullAccess"
43}
44
45###############################################################################
46# Async S3 access (only when enable_async_inference = true)
47###############################################################################
48
49locals {
50 async_buckets = var.enable_async_inference ? toset(compact([
51 try(split("/", replace(var.async_s3_output_path, "s3://", ""))[0], ""),
52 try(split("/", replace(var.async_s3_failure_path, "s3://", ""))[0], ""),
53 ])) : toset([])
54}
55
56resource "aws_iam_role_policy" "async_s3" {
57 count = var.enable_async_inference ? 1 : 0
58
59 name = "${var.model_name}-async-s3"
60 role = aws_iam_role.sagemaker_execution.id
61
62 policy = jsonencode({
63 Version = "2012-10-17"
64 Statement = [
65 {
66 Effect = "Allow"
67 Action = ["s3:GetObject", "s3:PutObject"]
68 Resource = [for b in local.async_buckets : "arn:aws:s3:::${b}/*"]
69 },
70 {
71 Effect = "Allow"
72 Action = ["s3:ListBucket"]
73 Resource = [for b in local.async_buckets : "arn:aws:s3:::${b}"]
74 },
75 ]
76 })
77}
78
79###############################################################################
80# Merge Deepgram environment variables
81###############################################################################
82
83locals {
84 deepgram_env = merge(
85 { for k, v in var.deepgram_engine_env : "DEEPGRAM_ENGINE_${k}" => v },
86 { for k, v in var.deepgram_api_env : "DEEPGRAM_API_${k}" => v },
87 )
88}
89
90###############################################################################
91# SageMaker Model — from AWS Marketplace Model Package
92###############################################################################
93
94resource "aws_sagemaker_model" "deepgram" {
95 name = var.model_name
96 execution_role_arn = aws_iam_role.sagemaker_execution.arn
97 enable_network_isolation = true
98
99 primary_container {
100 model_package_name = var.model_package_arn
101 environment = local.deepgram_env
102 }
103}
104
105###############################################################################
106# SageMaker Endpoint Configuration
107###############################################################################
108
109resource "aws_sagemaker_endpoint_configuration" "deepgram" {
110 name = "${var.endpoint_name}-config"
111
112 production_variants {
113 variant_name = var.variant_name
114 model_name = aws_sagemaker_model.deepgram.name
115 initial_instance_count = var.initial_instance_count
116 instance_type = var.instance_type
117 inference_ami_version = var.inference_ami_version != "" ? var.inference_ami_version : null
118 }
119
120 dynamic "async_inference_config" {
121 for_each = var.enable_async_inference ? [1] : []
122 content {
123 output_config {
124 s3_output_path = var.async_s3_output_path
125 s3_failure_path = var.async_s3_failure_path != "" ? var.async_s3_failure_path : null
126 }
127 }
128 }
129
130 lifecycle {
131 precondition {
132 condition = !var.enable_async_inference || var.async_s3_output_path != ""
133 error_message = "async_s3_output_path is required when enable_async_inference = true."
134 }
135 }
136}
137
138###############################################################################
139# SageMaker Endpoint
140###############################################################################
141
142resource "aws_sagemaker_endpoint" "deepgram" {
143 name = var.endpoint_name
144 endpoint_config_name = aws_sagemaker_endpoint_configuration.deepgram.name
145}
146
147###############################################################################
148# Auto-Scaling (optional)
149###############################################################################
150
151resource "aws_appautoscaling_target" "sagemaker" {
152 count = var.enable_autoscaling ? 1 : 0
153
154 max_capacity = var.autoscaling_max_capacity
155 min_capacity = var.autoscaling_min_capacity
156 resource_id = "endpoint/${aws_sagemaker_endpoint.deepgram.name}/variant/${var.variant_name}"
157 scalable_dimension = "sagemaker:variant:DesiredInstanceCount"
158 service_namespace = "sagemaker"
159}
160
161resource "aws_appautoscaling_policy" "sagemaker" {
162 count = var.enable_autoscaling ? 1 : 0
163
164 name = "${var.endpoint_name}-concurrency-policy"
165 policy_type = "TargetTrackingScaling"
166 resource_id = aws_appautoscaling_target.sagemaker[0].resource_id
167 scalable_dimension = aws_appautoscaling_target.sagemaker[0].scalable_dimension
168 service_namespace = aws_appautoscaling_target.sagemaker[0].service_namespace
169
170 target_tracking_scaling_policy_configuration {
171 target_value = var.autoscaling_target_value
172
173 # Real-time: scale on concurrent requests per model.
174 dynamic "predefined_metric_specification" {
175 for_each = var.enable_async_inference ? [] : [1]
176 content {
177 predefined_metric_type = "SageMakerVariantConcurrentRequestsPerModelHighResolution"
178 }
179 }
180
181 # Async: scale on queue depth per instance.
182 dynamic "customized_metric_specification" {
183 for_each = var.enable_async_inference ? [1] : []
184 content {
185 metric_name = "ApproximateBacklogSizePerInstance"
186 namespace = "AWS/SageMaker"
187 statistic = "Average"
188 dimensions {
189 name = "EndpointName"
190 value = aws_sagemaker_endpoint.deepgram.name
191 }
192 }
193 }
194
195 scale_in_cooldown = 300
196 scale_out_cooldown = 60
197 }
198}
199
200###############################################################################
201# Async scale-from-zero (only when async + autoscaling are enabled)
202###############################################################################
203
204resource "aws_appautoscaling_policy" "async_scale_from_zero" {
205 count = var.enable_async_inference && var.enable_autoscaling ? 1 : 0
206
207 name = "${var.endpoint_name}-scale-from-zero"
208 policy_type = "StepScaling"
209 resource_id = aws_appautoscaling_target.sagemaker[0].resource_id
210 scalable_dimension = aws_appautoscaling_target.sagemaker[0].scalable_dimension
211 service_namespace = aws_appautoscaling_target.sagemaker[0].service_namespace
212
213 step_scaling_policy_configuration {
214 adjustment_type = "ChangeInCapacity"
215 metric_aggregation_type = "Average"
216 cooldown = 300
217
218 step_adjustment {
219 metric_interval_lower_bound = 0
220 scaling_adjustment = 1
221 }
222 }
223}
224
225resource "aws_cloudwatch_metric_alarm" "async_has_backlog" {
226 count = var.enable_async_inference && var.enable_autoscaling ? 1 : 0
227
228 alarm_name = "${var.endpoint_name}-has-backlog-without-capacity"
229 namespace = "AWS/SageMaker"
230 metric_name = "HasBacklogWithoutCapacity"
231 statistic = "Average"
232 period = 60
233 evaluation_periods = 2
234 datapoints_to_alarm = 2
235 threshold = 1
236 comparison_operator = "GreaterThanOrEqualToThreshold"
237 treat_missing_data = "missing"
238
239 dimensions = {
240 EndpointName = aws_sagemaker_endpoint.deepgram.name
241 }
242
243 alarm_actions = [aws_appautoscaling_policy.async_scale_from_zero[0].arn]
244}

Outputs

Create outputs.tf to surface the endpoint details after terraform apply completes.

outputs.tf
1output "endpoint_name" {
2 description = "Name of the deployed SageMaker Endpoint."
3 value = aws_sagemaker_endpoint.deepgram.name
4}
5
6output "endpoint_arn" {
7 description = "ARN of the deployed SageMaker Endpoint."
8 value = aws_sagemaker_endpoint.deepgram.arn
9}
10
11output "model_name" {
12 description = "Name of the SageMaker Model."
13 value = aws_sagemaker_model.deepgram.name
14}
15
16output "execution_role_arn" {
17 description = "ARN of the IAM execution role."
18 value = aws_iam_role.sagemaker_execution.arn
19}
20
21output "async_s3_output_path" {
22 description = "S3 location where async transcription results are written (async mode only)."
23 value = var.enable_async_inference ? var.async_s3_output_path : null
24}

Example variable values

Create a terraform.tfvars file with your specific values. Replace the model_package_arn with the ARN from your AWS Marketplace subscription.

terraform.tfvars
1aws_region = "us-east-1"
2model_package_arn = "arn:aws:sagemaker:us-east-1:123456789012:model-package/deepgram-stt-nova-3/1"
3model_name = "deepgram-streaming-stt"
4endpoint_name = "my-deepgram-stt"
5instance_type = "ml.g5.2xlarge"
6inference_ami_version = "al2023-ami-sagemaker-inference-gpu-4-1"
7
8# Optional: Deepgram configuration overrides
9deepgram_engine_env = {
10 "01" = "max_active_requests=120"
11}
12deepgram_api_env = {
13 "01" = "features.listen_v2=true"
14}
15
16# Optional: Enable auto-scaling
17enable_autoscaling = true
18autoscaling_min_capacity = 1
19autoscaling_max_capacity = 4
20autoscaling_target_value = 5.0
21
22# Optional: deploy an asynchronous endpoint instead of real-time
23# enable_async_inference = true
24# async_s3_output_path = "s3://my-deepgram-async/output/"
25# async_s3_failure_path = "s3://my-deepgram-async/failures/"
26# enable_autoscaling = true
27# autoscaling_min_capacity = 0 # async supports scale-to-zero
28# autoscaling_target_value = 5.0 # target ApproximateBacklogSizePerInstance

Do not commit terraform.tfvars to version control if it contains sensitive values. Add it to .gitignore or use environment variables instead.

Deploy

1

Initialize the Terraform working directory

$terraform init
2

Preview the resources Terraform will create

$terraform plan

Verify the plan shows the expected resources: an IAM role, a SageMaker Model, an Endpoint Configuration, and an Endpoint.

3

Apply the configuration

$terraform apply

Terraform creates the resources and waits for the SageMaker Endpoint to reach InService status. This typically takes several minutes.

4

Verify the endpoint

Confirm the endpoint is running:

$aws sagemaker describe-endpoint \
> --endpoint-name $(terraform output -raw endpoint_name) \
> --region $(terraform output -raw aws_region 2>/dev/null || echo "us-east-1") \
> --query "EndpointStatus"

The output should be "InService".

Validate the endpoint

After the endpoint reaches InService, run a test inference to confirm it returns results. See Validate a Deepgram SageMaker Endpoint for the full testing guide using the dg-sagemaker test clients.

Customize the deployment

Instance types

Choose an instance type based on the Deepgram product you are deploying. GPU-accelerated instances are required.

ProductRecommended instance typeNotes
Speech-to-Text (Nova-3, Flux)ml.g5.2xlargeSingle NVIDIA A10G GPU, 32 GB GPU RAM
Text-to-Speech (Aura)ml.g5.12xlarge4 NVIDIA A10G GPUs (TTS requires 2+ GPUs)

For a full list of compatible instances, see the Deployment Environments hardware specifications.

The host driver your instances boot with is set separately — see Inference AMI versions.

Inference AMI versions

A SageMaker Endpoint Configuration can pin an inference AMI version — the SageMaker-managed host image supplying the NVIDIA driver and container runtime your instances boot with. It is independent of the Deepgram container: it determines which driver the container runs against. If you do not set it, SageMaker selects a default for your instance type, which on older GPU families is an older driver.

AMI versionNVIDIA driverCUDA
al2-ami-sagemaker-inference-gpu-253512.2
al2-ami-sagemaker-inference-gpu-2-153512.2
al2-ami-sagemaker-inference-gpu-3-155012.4
al2023-ami-sagemaker-inference-gpu-4-158013.0

Deepgram recommends the latest available version, al2023-ami-sagemaker-inference-gpu-4-1, which provides the NVIDIA 580 driver. Deepgram containers select the correct CUDA compatibility layer at startup based on the host driver they detect, so a newer host driver requires no change to your deployment.

Support for older driver versions may be removed in the latest Deepgram Model Package. Pin an up-to-date inference AMI version rather than relying on the SageMaker default for your instance type.

For the full list of AMI versions and their driver and CUDA versions, see InferenceAmiVersion in the SageMaker API reference. For the driver each instance family runs by default, see the SageMaker GPU driver table.

Set it through the inference_ami_version variable. Set it to an empty string to use the SageMaker default for your instance type instead.

Changing inference_ami_version on an existing deployment replaces the endpoint configuration and updates the endpoint. Expect a rolling instance replacement, not an in-place driver upgrade.

Environment variable overrides

Pass Deepgram configuration overrides through the deepgram_engine_env and deepgram_api_env variables. Each map key becomes the suffix (for example, "01", "02"), and the value is the TOML expression. See Configure Amazon SageMaker Deployments for the full reference.

1deepgram_engine_env = {
2 "01" = "flux.max_streams=25"
3 "02" = "chunking.streaming.step=0.5"
4}

VPC configuration

To deploy the endpoint inside a VPC, add a vpc_config block to the aws_sagemaker_model resource:

VPC configuration
1resource "aws_sagemaker_model" "deepgram" {
2 name = var.model_name
3 execution_role_arn = aws_iam_role.sagemaker_execution.arn
4 enable_network_isolation = true
5
6 primary_container {
7 model_package_name = var.model_package_arn
8 environment = local.deepgram_env
9 }
10
11 vpc_config {
12 subnets = ["subnet-0123456789abcdef0", "subnet-0123456789abcdef1"]
13 security_group_ids = ["sg-0123456789abcdef0"]
14 }
15}

Asynchronous endpoints

By default this configuration deploys a real-time endpoint for streaming and synchronous transcription. To instead deploy an asynchronous endpoint — for large pre-recorded files (up to 1 GB), queued processing, and scale-to-zero — set enable_async_inference = true and provide an async_s3_output_path.

Asynchronous inference is a distinct endpoint mode: an async endpoint accepts only asynchronous invocations (InvokeEndpointAsync with S3 input/output) and cannot serve streaming or synchronous requests. Switching enable_async_inference replaces the endpoint configuration and endpoint.

When async is enabled, the configuration also:

  • grants the execution role s3:GetObject, s3:PutObject, and s3:ListBucket on the output and failure buckets;
  • switches the autoscaling target metric to ApproximateBacklogSizePerInstance and allows autoscaling_min_capacity = 0 for scale-to-zero;
  • adds a scale-from-zero policy so the endpoint wakes on the first queued request instead of waiting for the backlog to exceed the target value.

For invocation details, see Deploy Deepgram on Amazon SageMaker. For autoscaling details, see Auto-Scaling Asynchronous Endpoints.

Tear down

To delete all resources created by this configuration:

$terraform destroy

This removes the SageMaker Endpoint, Endpoint Configuration, Model, auto-scaling resources (if enabled), and the IAM execution role. You are no longer billed for SageMaker compute after the endpoint is deleted. Your AWS Marketplace subscription remains active.