Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real-time speech to text #275

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
dwilkie committed Feb 23, 2023
commit ddfceb958abd686ad6dfec0bea70a0cdc8415ec5
59 changes: 50 additions & 9 deletions infrastructure/modules/somleng_switch/switch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,49 @@ resource "aws_iam_user_policy" "recordings" {
EOF
}

# Custom FreeSWITCH modules user
resource "aws_iam_user" "fs_modules" {
name = "${var.switch_identifier}_fs_modules"
}

resource "aws_iam_access_key" "fs_modules" {
user = aws_iam_user.fs_modules.name
}


resource "aws_iam_user_policy" "fs_modules" {
name = aws_iam_user.fs_modules.name
user = aws_iam_user.fs_modules.name

policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"transcribe:StartStreamTranscription",
"transcribe:StartStreamTranscriptionWebSocket"
],
"Resource": "*"
}
]
}
EOF
}

resource "aws_ssm_parameter" "fs_modules_access_key_id" {
name = "somleng-switch.${var.app_environment}.fs_modules_access_key_id"
type = "SecureString"
value = aws_iam_access_key.fs_modules.id
}

resource "aws_ssm_parameter" "fs_modules_secret_access_key" {
name = "somleng-switch.${var.app_environment}.fs_modules_secret_access_key"
type = "SecureString"
value = aws_iam_access_key.fs_modules.secret
}

# IAM
data "aws_iam_policy_document" "ecs_task_assume_role_policy" {
version = "2012-10-17"
Expand Down Expand Up @@ -260,7 +303,9 @@ resource "aws_iam_policy" "task_execution_custom_policy" {
"${aws_ssm_parameter.freeswitch_event_socket_password.arn}",
"${var.json_cdr_password_parameter_arn}",
"${aws_ssm_parameter.recordings_bucket_access_key_id.arn}",
"${aws_ssm_parameter.recordings_bucket_secret_access_key.arn}"
"${aws_ssm_parameter.recordings_bucket_secret_access_key.arn}",
"${aws_ssm_parameter.fs_modules_access_key_id.arn}",
"${aws_ssm_parameter.fs_modules_secret_access_key.arn}"
]
}
]
Expand All @@ -282,14 +327,6 @@ resource "aws_iam_policy" "ecs_task_policy" {
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"transcribe:StartStreamTranscription",
"transcribe:StartStreamTranscriptionWebSocket"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
Expand Down Expand Up @@ -413,6 +450,10 @@ data "template_file" "switch" {
recordings_bucket_secret_access_key_parameter_arn = aws_ssm_parameter.recordings_bucket_secret_access_key.arn
recordings_bucket_region = aws_s3_bucket.recordings.region

fs_modules_access_key_id_parameter_arn = aws_ssm_parameter.fs_modules_access_key_id.arn
fs_modules_secret_access_key_parameter_arn = aws_ssm_parameter.fs_modules_secret_access_key.arn
aws_transcribe_region = aws_s3_bucket.recordings.region

services_function_arn = aws_lambda_function.services.arn
}
}
Expand Down
16 changes: 16 additions & 0 deletions infrastructure/modules/somleng_switch/templates/switch.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@
{
"name": "FS_EVENT_SOCKET_PASSWORD",
"valueFrom": "${freeswitch_event_socket_password_parameter_arn}"
},
{
"name": "AWS_ACCESS_KEY_ID",
"valueFrom": "${fs_modules_access_key_id_parameter_arn}"
},
{
"name": "AWS_SECRET_ACCESS_KEY",
"valueFrom": "${fs_modules_secret_access_key_parameter_arn}"
}
],
"portMappings": [
Expand All @@ -158,6 +166,14 @@
"name": "AWS_DEFAULT_REGION",
"value": "${region}"
},
{
"name": "AWS_TRANSCRIBE_REGION",
"value": "${aws_transcribe_region}"
},
{
"name": "AWS_REGION",
"value": "${aws_transcribe_region}"
},
{
"name": "FS_CACHE_DIRECTORY",
"value": "${cache_directory}"
Expand Down