Skip to content

Commit 9420457

Browse files
committed
Add new transcribe script
1 parent b1465ac commit 9420457

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,9 @@ Run `./email` and follow the prompts to enter an application name. The script wi
6363
The bucket script creates a new S3 bucket and an IAM user with read/write priveleges on it. It will also set up an initial CORS configuration to allow a specified domain name access from the browser.
6464

6565
Run `./bucket` and follow the prompts to enter an application name and a host domain name. The script will output the newly generated bucket name, and the access key id and secret access key for the new user.
66+
67+
### Transcribe
68+
69+
The transcribe script creates a new IAM user with access to AWS Transcribe along with read/write privileges to a specified S3 bucket where audio and transcriptions will be stored.
70+
71+
Run `./transcribe` and follow the prompts to enter an application name and a bucket name. The script will output the access key id and secret access key for the new user.

transcribe

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
read -p "App name (lowercase, letters, numbers, hyphen only): " APP_NAME
4+
read -p "Bucket name: " BUCKET_NAME
5+
6+
aws cloudformation create-stack --capabilities CAPABILITY_NAMED_IAM --stack-name ${APP_NAME}-transcribe --template-body file://./transcribe.json --parameters ParameterKey=ApplicationName,ParameterValue=$APP_NAME ParameterKey=BucketName,ParameterValue=$BUCKET_NAME --output text
7+
8+
# wait for completion
9+
aws cloudformation wait stack-create-complete --stack-name ${APP_NAME}-transcribe --output text
10+
11+
# output the access key id
12+
echo "Access Key ID:"
13+
aws cloudformation describe-stacks --stack-name ${APP_NAME}-transcribe --query 'Stacks[0].Outputs[?OutputKey==`TranscribeUserAccessKeyId`].OutputValue' --output text
14+
15+
# output the secret access key
16+
echo "Secret Access Key:"
17+
aws ssm get-parameter --name /iam/user/${APP_NAME}-transcribe-user/secret-access-key --with-decryption --query Parameter.Value --output text

transcribe.json

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"AWSTemplateFormatVersion": "2010-09-09",
3+
"Description": "IAM User account and credentials for accessing AWS Transcribe",
4+
"Outputs": {
5+
"TranscribeUserAccessKeyId": {
6+
"Description": "Access Key ID for the user",
7+
"Value": {
8+
"Ref": "TranscribeUserAccessKey"
9+
},
10+
"Export" : {
11+
"Name" : {"Fn::Sub": "${ApplicationName}-transcribe-user-access-key-id" }
12+
}
13+
}
14+
},
15+
"Parameters": {
16+
"ApplicationName": {
17+
"Description": "Name of the application (snake-case, will be prepended to make internal reference names)",
18+
"Type": "String",
19+
"Default": "app"
20+
},
21+
"BucketName": {
22+
"Description": "Name of the S3 bucket where audio files and resulting transcriptions will be stored",
23+
"Type": "String"
24+
}
25+
},
26+
"Resources": {
27+
"TranscribeUser": {
28+
"Type": "AWS::IAM::User",
29+
"Properties": {
30+
"Policies": [
31+
{
32+
"PolicyName": {
33+
"Fn::Sub": "${ApplicationName}-transcribe-policy"
34+
},
35+
"PolicyDocument": {
36+
"Version": "2012-10-17",
37+
"Statement": [
38+
{
39+
"Sid": "VisualEditor0",
40+
"Effect": "Allow",
41+
"Action": ["s3:PutObject", "s3:GetObject", "s3:ListBucket", "s3:DeleteObject"],
42+
"Resource": [
43+
{ "Fn::Sub": "arn:aws:s3:::${BucketName}/*" },
44+
{ "Fn::Sub": "arn:aws:s3:::${BucketName}" }
45+
]
46+
},
47+
{
48+
"Sid": "VisualEditor1",
49+
"Effect": "Allow",
50+
"Action": ["transcribe:GetTranscriptionJob", "transcribe:StartTranscriptionJob"],
51+
"Resource": "*"
52+
}
53+
]
54+
}
55+
}
56+
],
57+
"UserName": {
58+
"Fn::Sub": "${ApplicationName}-transcribe-user"
59+
}
60+
}
61+
},
62+
"TranscribeUserAccessKey": {
63+
"Type": "AWS::IAM::AccessKey",
64+
"Properties": {
65+
"Status": "Active",
66+
"UserName": {
67+
"Ref": "TranscribeUser"
68+
}
69+
}
70+
},
71+
"TranscribeUserSecretAccessKeyParameter": {
72+
"Type" : "Custom::SSMSecureStringParam",
73+
"Properties" : {
74+
"Name" : {
75+
"Fn::Sub": "/iam/user/${ApplicationName}-transcribe-user/secret-access-key"
76+
},
77+
"ServiceToken": {
78+
"Fn::ImportValue": "ssm-securestring-cfn-macro-function-arn"
79+
},
80+
"Type": "SecureString",
81+
"Value" : {
82+
"Fn::GetAtt": ["TranscribeUserAccessKey", "SecretAccessKey"]
83+
}
84+
}
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)