Skip to content

Commit

Permalink
chore: Make API authorizer pluggable
Browse files Browse the repository at this point in the history
  • Loading branch information
katsujukou committed Dec 25, 2024
1 parent 05b0821 commit 889f21d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions terraform/service/modules/api-server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ resource "aws_api_gateway_method" "this" {
resource_id = aws_api_gateway_resource.this.id
http_method = "ANY"
authorization = var.use_cognito_authorizer ? "COGNITO_USER_POOLS" : "NONE"
authorizer_id = var.use_cognito_authorizer ? aws_api_gateway_authorizer.this.id : null
authorizer_id = var.use_cognito_authorizer ? aws_api_gateway_authorizer.this[0].id : null
api_key_required = var.require_api_key

request_parameters = {
Expand Down Expand Up @@ -316,7 +316,7 @@ resource "aws_lambda_permission" "api_lambda_permission" {
}

resource "aws_api_gateway_authorizer" "this" {
count = var.use_cognito_authorizer ? 1 : 0
count = var.use_cognito_authorizer ? 1 : 0
name = "${var.product}-${var.org}-${var.env}-${var.identifier}"
rest_api_id = aws_api_gateway_rest_api.this.id
type = "COGNITO_USER_POOLS"
Expand Down
4 changes: 3 additions & 1 deletion terraform/service/oqtopus-dev/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ module "provider_api" {
lambda_handler = "oqtopus_cloud.provider.lambda_function.handler"
lambda_security_group_ids = data.terraform_remote_state.infrastructure.outputs.security_group.lambda_security_group_ids
lambda_subnet_ids = data.terraform_remote_state.infrastructure.outputs.network.private_subnet_ids
cognito_user_pool_arns = [data.terraform_remote_state.infrastructure.outputs.provider_cognito.user_pool_arn]
use_cognito_authorizer = false
require_api_key = true
cognito_user_pool_arns = []
power_tools_metrics_namespace = "provider-api"
power_tools_service_name = "provider-api"
allow_origins = "*"
Expand Down

0 comments on commit 889f21d

Please sign in to comment.