Skip to content

Commit ebadd96

Browse files
authored
Merge pull request #2849 from kakakakakku/apigw-bedrock-nova-canvas
apigw-bedrock-nova-canvas: Small improvements (Fix Terraform warning and README)
2 parents f40b5ac + e5094f7 commit ebadd96

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

apigw-bedrock-nova-canvas/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ Important: this application uses various AWS services and there are costs associ
2222

2323
For this pattern, you would need access only to Amazon Nova Canvas foundation model (Model ID: amazon.nova-canvas-v1:0) in us-east-1 region, since the pattern uses us-east-1 region by default.
2424

25-
You must request access to the model before you can use it. If you try to use the model before you have requested access to it, you will receive an error message.
26-
2725
1. Create a new directory, navigate to that directory in a terminal and clone the GitHub repository:
2826
```
2927
git clone https://github.com/aws-samples/serverless-patterns
@@ -86,4 +84,4 @@ You must request access to the model before you can use it. If you try to use th
8684
----
8785
Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
8886
89-
SPDX-License-Identifier: MIT-0
87+
SPDX-License-Identifier: MIT-0

apigw-bedrock-nova-canvas/main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ resource "aws_iam_policy" "invoke_model_policy" {
3636
]
3737
Effect = "Allow"
3838
Resource = [
39-
"arn:aws:bedrock:${data.aws_region.current.name}::foundation-model/amazon.nova-canvas-v1:0"
39+
"arn:aws:bedrock:${data.aws_region.current.region}::foundation-model/amazon.nova-canvas-v1:0"
4040
]
4141
},
4242
]
@@ -45,23 +45,23 @@ resource "aws_iam_policy" "invoke_model_policy" {
4545

4646
# S3 bucket for storing images
4747
resource "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
5353
resource "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
6363
resource "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
147147
resource "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

177177
output "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

182182
output "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

Comments
 (0)