LanguageModel class

Resource for managing an AWS Transcribe LanguageModel.

> This resource can take a significant amount of time to provision. See Language Model FAQ for more details.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = aws.iam.getPolicyDocument({
    statements: [{
        principals: [{
            type: "Service",
            identifiers: ["transcribe.amazonaws.com"],
        }],
        actions: ["sts:AssumeRole"],
    }],
});
const exampleRole = new aws.iam.Role("example", {
    name: "example",
    assumeRolePolicy: example.then(example => example.json),
});
const testPolicy = new aws.iam.RolePolicy("test_policy", {
    name: "example",
    role: exampleRole.id,
    policy: JSON.stringify({
        Version: "2012-10-17",
        Statement: [{
            Action: [
                "s3:GetObject",
                "s3:ListBucket",
            ],
            Effect: "Allow",
            Resource: ["*"],
        }],
    }),
});
const exampleBucket = new aws.s3.Bucket("example", {
    bucket: "example-transcribe",
    forceDestroy: true,
});
const object = new aws.s3.BucketObjectv2("object", {
    bucket: exampleBucket.id,
    key: "transcribe/test1.txt",
    source: new pulumi.asset.FileAsset("test1.txt"),
});
const exampleLanguageModel = new aws.transcribe.LanguageModel("example", {
    inputDataConfig: {
        dataAccessRoleArn: exampleRole.arn,
        s3Uri: pulumi.interpolate`s3://${exampleBucket.id}/transcribe/`,
    },
    modelName: "example",
    baseModelName: "NarrowBand",
    languageCode: "en-US",
    tags: {
        ENVIRONMENT: "development",
    },
});
import pulumi
import json
import pulumi_aws as aws

example = aws.iam.get_policy_document(statements=[{
    "principals": [{
        "type": "Service",
        "identifiers": ["transcribe.amazonaws.com"],
    }],
    "actions": ["sts:AssumeRole"],
}])
example_role = aws.iam.Role("example",
    name="example",
    assume_role_policy=example.json)
test_policy = aws.iam.RolePolicy("test_policy",
    name="example",
    role=example_role.id,
    policy=json.dumps({
        "Version": "2012-10-17",
        "Statement": [{
            "Action": [
                "s3:GetObject",
                "s3:ListBucket",
            ],
            "Effect": "Allow",
            "Resource": ["*"],
        }],
    }))
example_bucket = aws.s3.Bucket("example",
    bucket="example-transcribe",
    force_destroy=True)
object = aws.s3.BucketObjectv2("object",
    bucket=example_bucket.id,
    key="transcribe/test1.txt",
    source=pulumi.FileAsset("test1.txt"))
example_language_model = aws.transcribe.LanguageModel("example",
    input_data_config={
        "data_access_role_arn": example_role.arn,
        "s3_uri": example_bucket.id.apply(lambda id: f"s3://{id}/transcribe/"),
    },
    model_name="example",
    base_model_name="NarrowBand",
    language_code="en-US",
    tags={
        "ENVIRONMENT": "development",
    })
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "Service",
                        Identifiers = new[]
                        {
                            "transcribe.amazonaws.com",
                        },
                    },
                },
                Actions = new[]
                {
                    "sts:AssumeRole",
                },
            },
        },
    });

    var exampleRole = new Aws.Iam.Role("example", new()
    {
        Name = "example",
        AssumeRolePolicy = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

    var testPolicy = new Aws.Iam.RolePolicy("test_policy", new()
    {
        Name = "example",
        Role = exampleRole.Id,
        Policy = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["Version"] = "2012-10-17",
            ["Statement"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["Action"] = new[]
                    {
                        "s3:GetObject",
                        "s3:ListBucket",
                    },
                    ["Effect"] = "Allow",
                    ["Resource"] = new[]
                    {
                        "*",
                    },
                },
            },
        }),
    });

    var exampleBucket = new Aws.S3.Bucket("example", new()
    {
        BucketName = "example-transcribe",
        ForceDestroy = true,
    });

    var @object = new Aws.S3.BucketObjectv2("object", new()
    {
        Bucket = exampleBucket.Id,
        Key = "transcribe/test1.txt",
        Source = new FileAsset("test1.txt"),
    });

    var exampleLanguageModel = new Aws.Transcribe.LanguageModel("example", new()
    {
        InputDataConfig = new Aws.Transcribe.Inputs.LanguageModelInputDataConfigArgs
        {
            DataAccessRoleArn = exampleRole.Arn,
            S3Uri = exampleBucket.Id.Apply(id => $"s3://{id}/transcribe/"),
        },
        ModelName = "example",
        BaseModelName = "NarrowBand",
        LanguageCode = "en-US",
        Tags =
        {
            { "ENVIRONMENT", "development" },
        },
    });

});
package main

import (
	"encoding/json"
	"fmt"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/s3"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/transcribe"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Principals: []iam.GetPolicyDocumentStatementPrincipal{
						{
							Type: "Service",
							Identifiers: []string{
								"transcribe.amazonaws.com",
							},
						},
					},
					Actions: []string{
						"sts:AssumeRole",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		exampleRole, err := iam.NewRole(ctx, "example", &iam.RoleArgs{
			Name:             pulumi.String("example"),
			AssumeRolePolicy: pulumi.String(example.Json),
		})
		if err != nil {
			return err
		}
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"Version": "2012-10-17",
			"Statement": []map[string]interface{}{
				map[string]interface{}{
					"Action": []string{
						"s3:GetObject",
						"s3:ListBucket",
					},
					"Effect": "Allow",
					"Resource": []string{
						"*",
					},
				},
			},
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		_, err = iam.NewRolePolicy(ctx, "test_policy", &iam.RolePolicyArgs{
			Name:   pulumi.String("example"),
			Role:   exampleRole.ID().ToIDOutput().ToStringOutput(),
			Policy: pulumi.String(json0),
		})
		if err != nil {
			return err
		}
		exampleBucket, err := s3.NewBucket(ctx, "example", &s3.BucketArgs{
			Bucket:       pulumi.String("example-transcribe"),
			ForceDestroy: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		_, err = s3.NewBucketObjectv2(ctx, "object", &s3.BucketObjectv2Args{
			Bucket: exampleBucket.ID().ToIDOutput().ToStringOutput(),
			Key:    pulumi.String("transcribe/test1.txt"),
			Source: pulumi.NewFileAsset("test1.txt"),
		})
		if err != nil {
			return err
		}
		_, err = transcribe.NewLanguageModel(ctx, "example", &transcribe.LanguageModelArgs{
			InputDataConfig: &transcribe.LanguageModelInputDataConfigArgs{
				DataAccessRoleArn: exampleRole.Arn,
				S3Uri: exampleBucket.ID().ApplyT(func(id pulumi.ID) (string, error) {
					return fmt.Sprintf("s3://%v/transcribe/", id), nil
				}).(pulumi.StringOutput),
			},
			ModelName:     pulumi.String("example"),
			BaseModelName: pulumi.String("NarrowBand"),
			LanguageCode:  pulumi.String("en-US"),
			Tags: pulumi.StringMap{
				"ENVIRONMENT": pulumi.String("development"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "example" {
  statements {
    principals {
      type        = "Service"
      identifiers = ["transcribe.amazonaws.com"]
    }
    actions = ["sts:AssumeRole"]
  }
}

resource "aws_iam_role" "example" {
  name               = "example"
  assume_role_policy = data.aws_iam_getpolicydocument.example.json
}
resource "aws_iam_rolepolicy" "test_policy" {
  name = "example"
  role = aws_iam_role.example.id
  policy = jsonencode({
    "Version" = "2012-10-17"
    "Statement" = [{
      "Action"   = ["s3:GetObject", "s3:ListBucket"]
      "Effect"   = "Allow"
      "Resource" = ["*"]
    }]
  })
}
resource "aws_s3_bucket" "example" {
  bucket        = "example-transcribe"
  force_destroy = true
}
resource "aws_s3_bucketobjectv2" "object" {
  bucket = aws_s3_bucket.example.id
  key    = "transcribe/test1.txt"
  source = fileAsset("test1.txt")
}
resource "aws_transcribe_languagemodel" "example" {
  input_data_config = {
    data_access_role_arn = aws_iam_role.example.arn
    s3_uri               ="s3://${aws_s3_bucket.example.id}/transcribe/"
  }
  model_name      = "example"
  base_model_name = "NarrowBand"
  language_code   = "en-US"
  tags = {
    "ENVIRONMENT" = "development"
  }
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.iam.RolePolicy;
import com.pulumi.aws.iam.RolePolicyArgs;
import com.pulumi.aws.s3.Bucket;
import com.pulumi.aws.s3.BucketArgs;
import com.pulumi.aws.s3.BucketObjectv2;
import com.pulumi.aws.s3.BucketObjectv2Args;
import com.pulumi.aws.transcribe.LanguageModel;
import com.pulumi.aws.transcribe.LanguageModelArgs;
import com.pulumi.aws.transcribe.inputs.LanguageModelInputDataConfigArgs;
import com.pulumi.asset.FileAsset;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .type("Service")
                    .identifiers("transcribe.amazonaws.com")
                    .build())
                .actions("sts:AssumeRole")
                .build())
            .build());

        var exampleRole = new Role("exampleRole", RoleArgs.builder()
            .name("example")
            .assumeRolePolicy(example.json())
            .build());

        var testPolicy = new RolePolicy("testPolicy", RolePolicyArgs.builder()
            .name("example")
            .role(exampleRole.id())
            .policy(serializeJson(
                jsonObject(
                    jsonProperty("Version", "2012-10-17"),
                    jsonProperty("Statement", jsonArray(jsonObject(
                        jsonProperty("Action", jsonArray(
                            "s3:GetObject",
                            "s3:ListBucket"
                        )),
                        jsonProperty("Effect", "Allow"),
                        jsonProperty("Resource", jsonArray("*"))
                    )))
                )))
            .build());

        var exampleBucket = new Bucket("exampleBucket", BucketArgs.builder()
            .bucket("example-transcribe")
            .forceDestroy(true)
            .build());

        var object = new BucketObjectv2("object", BucketObjectv2Args.builder()
            .bucket(exampleBucket.id())
            .key("transcribe/test1.txt")
            .source(new FileAsset("test1.txt"))
            .build());

        var exampleLanguageModel = new LanguageModel("exampleLanguageModel", LanguageModelArgs.builder()
            .inputDataConfig(LanguageModelInputDataConfigArgs.builder()
                .dataAccessRoleArn(exampleRole.arn())
                .s3Uri(exampleBucket.id().applyValue(_id -> String.format("s3://%s/transcribe/", _id)))
                .build())
            .modelName("example")
            .baseModelName("NarrowBand")
            .languageCode("en-US")
            .tags(Map.of("ENVIRONMENT", "development"))
            .build());

    }
}
resources:
  exampleRole:
    type: aws:iam:Role
    name: example
    properties:
      name: example
      assumeRolePolicy: ${example.json}
  testPolicy:
    type: aws:iam:RolePolicy
    name: test_policy
    properties:
      name: example
      role: ${exampleRole.id}
      policy:
        fn::toJSON:
          Version: 2012-10-17
          Statement:
            - Action:
                - s3:GetObject
                - s3:ListBucket
              Effect: Allow
              Resource:
                - '*'
  exampleBucket:
    type: aws:s3:Bucket
    name: example
    properties:
      bucket: example-transcribe
      forceDestroy: true
  object:
    type: aws:s3:BucketObjectv2
    properties:
      bucket: ${exampleBucket.id}
      key: transcribe/test1.txt
      source:
        fn::fileAsset: test1.txt
  exampleLanguageModel:
    type: aws:transcribe:LanguageModel
    name: example
    properties:
      inputDataConfig:
        dataAccessRoleArn: ${exampleRole.arn}
        s3Uri: s3://${exampleBucket.id}/transcribe/
      modelName: example
      baseModelName: NarrowBand
      languageCode: en-US
      tags:
        ENVIRONMENT: development
variables:
  example:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - principals:
              - type: Service
                identifiers:
                  - transcribe.amazonaws.com
            actions:
              - sts:AssumeRole

Import

Using pulumi import, import Transcribe LanguageModel using the modelName. For example:

$ pulumi import aws:transcribe/languageModel:LanguageModel example example-name

Constructors

LanguageModel(String name, {LanguageModelArgs? args, CustomResourceOptions? options})
Creates a new LanguageModel. name The Pulumi resource name. args Arguments used to configure this LanguageModel. The set of arguments for LanguageModel. options Resource options controlling this resource's behavior.
LanguageModel.reference(String urn)
Creates a typed reference to an existing LanguageModel resource.

Properties

arn ↔ Output<String>
ARN of the LanguageModel.
latefinal
baseModelName ↔ Output<String>
Name of reference base model.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
inputDataConfig ↔ Output<LanguageModelInputDataConfig>
Input data configuration for the LanguageModel. See inputDataConfig Block for details.
latefinal
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
languageCode ↔ Output<String>
Language code you selected for your language model. Refer to the supported languages page for accepted codes.
latefinal
modelName ↔ Output<String>
Model name.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tags ↔ Output<Map<String, String>?>
Map of tags to assign to the LanguageModel. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
latefinal
tagsAll ↔ Output<Map<String, String>>
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {LanguageModelState? state, CustomResourceOptions? options}) → LanguageModel
Gets an existing LanguageModel resource's state with the given name and id.