From 231c5262f77d4605ac482b973fb5b20db6f7ae54 Mon Sep 17 00:00:00 2001 From: Florian Rumiel Date: Sun, 25 Feb 2024 08:10:32 -0500 Subject: [PATCH 1/3] Update Cognito user pool ID in lambda integration and API Gateway configuration --- lambdas/inference/lambda_integration.tf | 2 +- lambdas/inference/variables.tf | 2 +- terraform/api_gateway.tf | 2 +- terraform/cognito_authorizer.tf | 3 +++ terraform/modules.tf | 2 +- terraform/variables.tf | 6 ------ 6 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 terraform/cognito_authorizer.tf diff --git a/lambdas/inference/lambda_integration.tf b/lambdas/inference/lambda_integration.tf index f9ffc23..fd685fb 100644 --- a/lambdas/inference/lambda_integration.tf +++ b/lambdas/inference/lambda_integration.tf @@ -24,5 +24,5 @@ module "integration_cognito" { lambda_function_name = var.lambda_function_name api_key_required = false authorization_type = "COGNITO_USER_POOLS" - authorizer_id = var.cognito_user_pool_arn + authorizer_id = var.cognito_user_pool_id } \ No newline at end of file diff --git a/lambdas/inference/variables.tf b/lambdas/inference/variables.tf index 6d3549a..9f33614 100644 --- a/lambdas/inference/variables.tf +++ b/lambdas/inference/variables.tf @@ -84,7 +84,7 @@ variable "api_gateway_rest_api_root_resource_id" { nullable = false } -variable "cognito_user_pool_arn" { +variable "cognito_user_pool_id" { type = string nullable = false } diff --git a/terraform/api_gateway.tf b/terraform/api_gateway.tf index d0a557f..f1966c3 100644 --- a/terraform/api_gateway.tf +++ b/terraform/api_gateway.tf @@ -56,7 +56,7 @@ resource "aws_api_gateway_authorizer" "this" { name = "${var.api_name}-authorizer" rest_api_id = aws_api_gateway_rest_api.this.id type = "COGNITO_USER_POOLS" - provider_arns = [var.cognito_user_pool_arn] + provider_arns = [data.aws_cognito_user_pools.api_cognito.arn] } diff --git a/terraform/cognito_authorizer.tf b/terraform/cognito_authorizer.tf new file mode 100644 index 0000000..7d4eedf --- /dev/null +++ b/terraform/cognito_authorizer.tf @@ -0,0 +1,3 @@ +data "aws_cognito_user_pools" "api_cognito" { + name = "estaec814cb7e6_userpool_814cb7e6-dev" +} diff --git a/terraform/modules.tf b/terraform/modules.tf index 3430562..6d7841c 100644 --- a/terraform/modules.tf +++ b/terraform/modules.tf @@ -50,7 +50,7 @@ module "inference" { embedding_collection_name = local.storage_bucket_name api_gateway_rest_api_id = aws_api_gateway_rest_api.this.id api_gateway_rest_api_root_resource_id = aws_api_gateway_rest_api.this.root_resource_id - cognito_user_pool_arn = var.cognito_user_pool_arn + cognito_user_pool_id = data.aws_cognito_user_pools.api_cognito.id } module "memory" { diff --git a/terraform/variables.tf b/terraform/variables.tf index f3f728c..26dad2a 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -57,12 +57,6 @@ variable "api_gateway_stage_name" { type = string } -variable "cognito_user_pool_arn" { - nullable = false - type = string - default = "arn:aws:cognito-idp:us-east-1:446872271111:userpool/us-east-1_N0uQPJkjd" -} - variable "sender_email" { type = string nullable = false From 91a9b54b32e664ec5a772a53b83d9599e859a718 Mon Sep 17 00:00:00 2001 From: Florian Rumiel Date: Sun, 25 Feb 2024 08:21:24 -0500 Subject: [PATCH 2/3] Fix provider_arns typo in api_gateway.tf --- terraform/api_gateway.tf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/terraform/api_gateway.tf b/terraform/api_gateway.tf index f1966c3..badf807 100644 --- a/terraform/api_gateway.tf +++ b/terraform/api_gateway.tf @@ -53,10 +53,10 @@ resource "aws_api_gateway_usage_plan_key" "this" { ## Auth and Authorizer resource "aws_api_gateway_authorizer" "this" { - name = "${var.api_name}-authorizer" - rest_api_id = aws_api_gateway_rest_api.this.id - type = "COGNITO_USER_POOLS" - provider_arns = [data.aws_cognito_user_pools.api_cognito.arn] + name = "${var.api_name}-authorizer" + rest_api_id = aws_api_gateway_rest_api.this.id + type = "COGNITO_USER_POOLS" + provider_arns = [data.aws_cognito_user_pools.api_cognito.arns] } @@ -110,4 +110,4 @@ resource "aws_iam_role_policy" "this" { ] } POLICY -} \ No newline at end of file +} From 326f61277d8bf8fdb06625bd03be67f8cff25795 Mon Sep 17 00:00:00 2001 From: Florian Rumiel Date: Sun, 25 Feb 2024 08:50:21 -0500 Subject: [PATCH 3/3] Fix provider_arns assignment in api_gateway.tf --- terraform/api_gateway.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/api_gateway.tf b/terraform/api_gateway.tf index badf807..05ef7a5 100644 --- a/terraform/api_gateway.tf +++ b/terraform/api_gateway.tf @@ -56,7 +56,7 @@ resource "aws_api_gateway_authorizer" "this" { name = "${var.api_name}-authorizer" rest_api_id = aws_api_gateway_rest_api.this.id type = "COGNITO_USER_POOLS" - provider_arns = [data.aws_cognito_user_pools.api_cognito.arns] + provider_arns = data.aws_cognito_user_pools.api_cognito.arns }