@@ -15,10 +15,10 @@ resource "random_string" "suffix" {
1515
1616# Create Lambda layer for Pillow from provided zip file
1717resource "aws_lambda_layer_version" "pillow_layer" {
18- filename = " pillow.zip" # Make sure this zip file exists in your terraform directory
19- layer_name = " pillow_layer"
18+ filename = " pillow.zip" # Make sure this zip file exists in your terraform directory
19+ layer_name = " pillow_layer"
2020 compatible_runtimes = [" python3.11" ]
21- description = " Pillow library layer for image processing"
21+ description = " Pillow library layer for image processing"
2222}
2323
2424# IAM Policy for invoking Bedrock model
@@ -45,23 +45,23 @@ resource "aws_iam_policy" "invoke_model_policy" {
4545
4646# S3 bucket for storing images
4747resource "aws_s3_bucket" "image_bucket" {
48- bucket = " ${ lower (var. prefix )} -image-bucket-${ random_string . suffix . result } "
48+ bucket = " ${ lower (var. prefix )} -image-bucket-${ random_string . suffix . result } "
4949 force_destroy = true
5050}
5151
5252# Create CloudWatch Log Group for Lambda
5353resource "aws_cloudwatch_log_group" "lambda_log_group" {
5454 name = " /aws/lambda/${ lower (var. prefix )} -invoke-bedrock"
5555 retention_in_days = 14
56-
56+
5757 lifecycle {
5858 prevent_destroy = false
5959 }
6060}
6161
6262# Lambda function
6363resource "aws_lambda_function" "invoke_bedrock_function" {
64- filename = " index.zip" # Replace with your Lambda code zip file
64+ filename = " index.zip" # Replace with your Lambda code zip file
6565 function_name = " ${ lower (var. prefix )} -invoke-bedrock"
6666 role = aws_iam_role. lambda_role . arn
6767 handler = " index.handler"
@@ -146,7 +146,7 @@ resource "aws_api_gateway_integration" "lambda_integration" {
146146# API Gateway Deployment
147147resource "aws_api_gateway_deployment" "api_deployment" {
148148 rest_api_id = aws_api_gateway_rest_api. bedrock_api . id
149-
149+
150150 depends_on = [
151151 aws_api_gateway_integration . lambda_integration
152152 ]
@@ -176,12 +176,12 @@ output "lambda_function" {
176176
177177output "api_endpoint" {
178178 description = " The API Gateway endpoint URL "
179- value = " ${ aws_api_gateway_stage . api_stage . invoke_url } /image_gen"
179+ value = " ${ aws_api_gateway_stage . api_stage . invoke_url } /image_gen"
180180}
181181
182182output "s3_image_bucket" {
183183 description = " The Output S3 bucket is "
184- value = aws_s3_bucket. image_bucket . id
184+ value = aws_s3_bucket. image_bucket . id
185185}
186186
187187# Data source for current region
0 commit comments