Skip to content

Commit 908529d

Browse files
author
Archana Venkitaramanan
committed
Updated with the requested changes
1 parent 52b7460 commit 908529d

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

apigw-lambda-transcribe/README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,37 @@ Important: this application uses various AWS services and there are costs associ
3434
terraform apply
3535
```
3636
1. During the prompts
37+
```
3738
#var.prefix
3839
- Enter a value: {enter any prefix to associate with resources}
3940
4041
#var.region
4142
- Enter a value: {enter the region for deployment}
42-
43+
```
44+
4345
## Testing
4446
4547
1. Make a POST request to the API using the following cURL command:
4648
47-
curl --location 'https://<api-id>.execute-api.<region>.amazonaws.com/dev/generate-presigned-url' --header 'Content-Type: application/json' --data '{"object_name": "audio.mp3", "content_type": "audio/mpeg"}'
49+
```
50+
curl --location 'API_ENDPOINT' --header 'Content-Type: application/json' --data '{"object_name": "audio.mp3", "content_type": "audio/mpeg"}'
51+
```
4852
49-
Note: Replace 'api-id' with the generated API ID from Terraform, 'region' with the region where the API is deployed (refer to the Terraform Outputs section) 'object_name' with your desired name for the S3 object and 'content_type' with the content type of the audio, for ex, mp3 or m4a
53+
Note: Replace `API_ENDPOINT` with the generated `api_endpoint` from Terraform (refer to the Terraform Outputs section) `object_name` with your desired name for the S3 object and `content_type` with the content type of the audio, for ex, mp3 or m4a
5054
5155
1. Get the pre-signed URL from the previous step and use the following cURL command to upload the object in S3:
5256
53-
curl -v --location --request PUT '<presigned-url>' --header 'Content-Type: application/json' --data '<path-of-the-object>.mp3'
57+
```
58+
curl -v --location -T "audio.mp3" \
59+
'PRESIGNED_URL' \
60+
--header 'Content-Type: audio/mpeg'
61+
```
5462
55-
Note: Replace 'presigned-url' with pre-signed URL generated in the previous step. 'Content-Type' should match the content type used to generate the pre-signed URL in the previous step. Make sure you are passing the correct path of the object in the --data parameter.
63+
Note: Replace `PRESIGNED_URL` with pre-signed URL generated in the previous step. `Content-Type` should match the content type used to generate the pre-signed URL in the previous step.
5664
5765
Once this command is run successfully and the object is uploaded, HTTP 200 OK should be seen. You can also check the S3 bucket to see if the object is uploaded correctly.
5866
59-
1. Once the object is uploaded successfully, the "process_s3_event" Lambda function is invoked. Lambda function will then invoke the StartTranscriptionJob API and Amazon Transcibe will upload the transcribed output to the output S3 bucket.
67+
1. Once the object is uploaded successfully, the `process_s3_event` Lambda function is invoked. Lambda function will then invoke the `StartTranscriptionJob` API and Amazon Transcribe will upload the transcribed output to the output S3 bucket (Refer to the Terraform Outputs section under `output_bucket_name`).
6068
6169
## Cleanup
6270

apigw-lambda-transcribe/main.tf

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,16 @@ resource "aws_lambda_permission" "allow_api_gateway" {
167167
resource "aws_api_gateway_deployment" "deployment" {
168168
depends_on = [aws_api_gateway_integration.integration]
169169
rest_api_id = aws_api_gateway_rest_api.api.id
170-
stage_name = "dev"
170+
171+
lifecycle {
172+
create_before_destroy = true
173+
}
174+
}
175+
176+
resource "aws_api_gateway_stage" "stage" {
177+
deployment_id = aws_api_gateway_deployment.deployment.id
178+
rest_api_id = aws_api_gateway_rest_api.api.id
179+
stage_name = "dev"
171180
}
172181

173182
output "api_id" {
@@ -212,5 +221,5 @@ output "lambda_process_s3_event_log_group" {
212221

213222
output "api_endpoint" {
214223
description = "The API Gateway endpoint URL"
215-
value = "${aws_api_gateway_deployment.deployment.invoke_url}/${aws_api_gateway_resource.resource.path_part}"
216-
}
224+
value = "${aws_api_gateway_stage.stage.invoke_url}/${aws_api_gateway_resource.resource.path_part}"
225+
}

0 commit comments

Comments
 (0)