Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transition from serverless framework to terraform #194

Merged
merged 35 commits into from
Dec 5, 2024

Conversation

AyodeAwe
Copy link
Contributor

@AyodeAwe AyodeAwe commented Nov 25, 2024

As outlined in the PR below, the latest version of the serverless framework is no longer free for large organizations.

#186

This PR provides a terraform-based implementation of the ops-bot deployment that Serverless Framework currently powers. It adds both terraform configs and a workflow that should support both PR and deployment workflows.

Tested with rapids-bot-testing app:

@AyodeAwe AyodeAwe force-pushed the replace-sf-w-terraform branch from d31d2f9 to 8c70215 Compare November 25, 2024 20:32
@AyodeAwe
Copy link
Contributor Author

Terraform Plan 📝

Show Plan
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_api_gateway_authorizer.ops_bot will be created
  + resource "aws_api_gateway_authorizer" "ops_bot" {
      + arn                              = (known after apply)
      + authorizer_credentials           = (known after apply)
      + authorizer_result_ttl_in_seconds = 300
      + authorizer_uri                   = (known after apply)
      + id                               = (known after apply)
      + identity_source                  = "method.request.header.Authorization"
      + name                             = "ops-bot-authorizer"
      + rest_api_id                      = (known after apply)
      + type                             = "REQUEST"
    }

  # aws_api_gateway_deployment.ops_bot will be created
  + resource "aws_api_gateway_deployment" "ops_bot" {
      + created_date  = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + triggers      = (known after apply)
    }

  # aws_api_gateway_integration.lambda will be created
  + resource "aws_api_gateway_integration" "lambda" {
      + cache_namespace         = (known after apply)
      + connection_type         = "INTERNET"
      + http_method             = "POST"
      + id                      = (known after apply)
      + integration_http_method = "POST"
      + passthrough_behavior    = (known after apply)
      + resource_id             = (known after apply)
      + rest_api_id             = (known after apply)
      + timeout_milliseconds    = 29000
      + type                    = "AWS_PROXY"
      + uri                     = (known after apply)
    }

  # aws_api_gateway_method.proxy will be created
  + resource "aws_api_gateway_method" "proxy" {
      + api_key_required = false
      + authorization    = "CUSTOM"
      + authorizer_id    = (known after apply)
      + http_method      = "POST"
      + id               = (known after apply)
      + resource_id      = (known after apply)
      + rest_api_id      = (known after apply)
    }

  # aws_api_gateway_resource.proxy will be created
  + resource "aws_api_gateway_resource" "proxy" {
      + id          = (known after apply)
      + parent_id   = (known after apply)
      + path        = (known after apply)
      + path_part   = "{proxy+}"
      + rest_api_id = (known after apply)
    }

  # aws_api_gateway_rest_api.ops_bot will be created
  + resource "aws_api_gateway_rest_api" "ops_bot" {
      + api_key_source               = (known after apply)
      + arn                          = (known after apply)
      + binary_media_types           = (known after apply)
      + created_date                 = (known after apply)
      + description                  = (known after apply)
      + disable_execute_api_endpoint = (known after apply)
      + execution_arn                = (known after apply)
      + id                           = (known after apply)
      + minimum_compression_size     = (known after apply)
      + name                         = "ops-bot-prod"
      + policy                       = (known after apply)
      + root_resource_id             = (known after apply)
      + tags_all                     = (known after apply)

      + endpoint_configuration (known after apply)
    }

  # aws_api_gateway_stage.ops_bot will be created
  + resource "aws_api_gateway_stage" "ops_bot" {
      + arn           = (known after apply)
      + deployment_id = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + stage_name    = "prod"
      + tags_all      = (known after apply)
      + web_acl_arn   = (known after apply)
    }

  # aws_cloudwatch_log_group.authorizer will be created
  + resource "aws_cloudwatch_log_group" "authorizer" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-authorizerFn"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_cloudwatch_log_group.probot_handler will be created
  + resource "aws_cloudwatch_log_group" "probot_handler" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-handleProbot"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_iam_role.api_gateway_authorizer will be created
  + resource "aws_iam_role" "api_gateway_authorizer" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "apigateway.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role.lambda_role will be created
  + resource "aws_iam_role" "lambda_role" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "lambda.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-lambda-role"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role_policy.api_gateway_authorizer will be created
  + resource "aws_iam_role_policy" "api_gateway_authorizer" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_iam_role_policy.lambda_policy will be created
  + resource "aws_iam_role_policy" "lambda_policy" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-lambda-policy"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_lambda_function.authorizer will be created
  + resource "aws_lambda_function" "authorizer" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-authorizerFn"
      + handler                        = "dist/authorizer.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "authorizer-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 3
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "probotFnName" = "ops-bot-prod-handleProbot"
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

  # aws_lambda_function.probot_handler will be created
  + resource "aws_lambda_function" "probot_handler" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-handleProbot"
      + handler                        = "dist/probot.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "probot-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 900
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "APP_ID"         = (sensitive value)
              + "GPUTESTER_PAT"  = (sensitive value)
              + "LOG_FORMAT"     = "json"
              + "LOG_LEVEL"      = "debug"
              + "NODE_ENV"       = "prod"
              + "PRIVATE_KEY"    = (sensitive value)
              + "WEBHOOK_SECRET" = (sensitive value)
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

Plan: 15 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + api_gateway_url = (known after apply)

@AyodeAwe AyodeAwe force-pushed the replace-sf-w-terraform branch from b5cd4b1 to 80d8736 Compare November 25, 2024 21:11
@AyodeAwe
Copy link
Contributor Author

Terraform Plan 📝

Show Plan
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_api_gateway_authorizer.ops_bot will be created
  + resource "aws_api_gateway_authorizer" "ops_bot" {
      + arn                              = (known after apply)
      + authorizer_credentials           = (known after apply)
      + authorizer_result_ttl_in_seconds = 300
      + authorizer_uri                   = (known after apply)
      + id                               = (known after apply)
      + identity_source                  = "method.request.header.Authorization"
      + name                             = "ops-bot-authorizer"
      + rest_api_id                      = (known after apply)
      + type                             = "REQUEST"
    }

  # aws_api_gateway_deployment.ops_bot will be created
  + resource "aws_api_gateway_deployment" "ops_bot" {
      + created_date  = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + triggers      = (known after apply)
    }

  # aws_api_gateway_integration.lambda will be created
  + resource "aws_api_gateway_integration" "lambda" {
      + cache_namespace         = (known after apply)
      + connection_type         = "INTERNET"
      + http_method             = "POST"
      + id                      = (known after apply)
      + integration_http_method = "POST"
      + passthrough_behavior    = (known after apply)
      + resource_id             = (known after apply)
      + rest_api_id             = (known after apply)
      + timeout_milliseconds    = 29000
      + type                    = "AWS_PROXY"
      + uri                     = (known after apply)
    }

  # aws_api_gateway_method.proxy will be created
  + resource "aws_api_gateway_method" "proxy" {
      + api_key_required = false
      + authorization    = "CUSTOM"
      + authorizer_id    = (known after apply)
      + http_method      = "POST"
      + id               = (known after apply)
      + resource_id      = (known after apply)
      + rest_api_id      = (known after apply)
    }

  # aws_api_gateway_resource.proxy will be created
  + resource "aws_api_gateway_resource" "proxy" {
      + id          = (known after apply)
      + parent_id   = (known after apply)
      + path        = (known after apply)
      + path_part   = "{proxy+}"
      + rest_api_id = (known after apply)
    }

  # aws_api_gateway_rest_api.ops_bot will be created
  + resource "aws_api_gateway_rest_api" "ops_bot" {
      + api_key_source               = (known after apply)
      + arn                          = (known after apply)
      + binary_media_types           = (known after apply)
      + created_date                 = (known after apply)
      + description                  = (known after apply)
      + disable_execute_api_endpoint = (known after apply)
      + execution_arn                = (known after apply)
      + id                           = (known after apply)
      + minimum_compression_size     = (known after apply)
      + name                         = "ops-bot-prod"
      + policy                       = (known after apply)
      + root_resource_id             = (known after apply)
      + tags_all                     = (known after apply)

      + endpoint_configuration (known after apply)
    }

  # aws_api_gateway_stage.ops_bot will be created
  + resource "aws_api_gateway_stage" "ops_bot" {
      + arn           = (known after apply)
      + deployment_id = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + stage_name    = "prod"
      + tags_all      = (known after apply)
      + web_acl_arn   = (known after apply)
    }

  # aws_cloudwatch_log_group.authorizer will be created
  + resource "aws_cloudwatch_log_group" "authorizer" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-authorizerFn"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_cloudwatch_log_group.probot_handler will be created
  + resource "aws_cloudwatch_log_group" "probot_handler" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-handleProbot"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_iam_role.api_gateway_authorizer will be created
  + resource "aws_iam_role" "api_gateway_authorizer" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "apigateway.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role.lambda_role will be created
  + resource "aws_iam_role" "lambda_role" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "lambda.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-lambda-role"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role_policy.api_gateway_authorizer will be created
  + resource "aws_iam_role_policy" "api_gateway_authorizer" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_iam_role_policy.lambda_policy will be created
  + resource "aws_iam_role_policy" "lambda_policy" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-lambda-policy"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_lambda_function.authorizer will be created
  + resource "aws_lambda_function" "authorizer" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-authorizerFn"
      + handler                        = "dist/authorizer.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "authorizer-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 3
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "probotFnName" = "ops-bot-prod-handleProbot"
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

  # aws_lambda_function.probot_handler will be created
  + resource "aws_lambda_function" "probot_handler" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-handleProbot"
      + handler                        = "dist/probot.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "probot-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 900
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "APP_ID"         = (sensitive value)
              + "GPUTESTER_PAT"  = (sensitive value)
              + "LOG_FORMAT"     = "json"
              + "LOG_LEVEL"      = "debug"
              + "NODE_ENV"       = "prod"
              + "PRIVATE_KEY"    = (sensitive value)
              + "WEBHOOK_SECRET" = (sensitive value)
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

Plan: 15 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + api_gateway_url = (known after apply)

@GPUtester
Copy link

Terraform Plan 📝

Show Plan
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_api_gateway_authorizer.ops_bot will be created
  + resource "aws_api_gateway_authorizer" "ops_bot" {
      + arn                              = (known after apply)
      + authorizer_credentials           = (known after apply)
      + authorizer_result_ttl_in_seconds = 300
      + authorizer_uri                   = (known after apply)
      + id                               = (known after apply)
      + identity_source                  = "method.request.header.Authorization"
      + name                             = "ops-bot-authorizer"
      + rest_api_id                      = (known after apply)
      + type                             = "REQUEST"
    }

  # aws_api_gateway_deployment.ops_bot will be created
  + resource "aws_api_gateway_deployment" "ops_bot" {
      + created_date  = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + triggers      = (known after apply)
    }

  # aws_api_gateway_integration.lambda will be created
  + resource "aws_api_gateway_integration" "lambda" {
      + cache_namespace         = (known after apply)
      + connection_type         = "INTERNET"
      + http_method             = "POST"
      + id                      = (known after apply)
      + integration_http_method = "POST"
      + passthrough_behavior    = (known after apply)
      + resource_id             = (known after apply)
      + rest_api_id             = (known after apply)
      + timeout_milliseconds    = 29000
      + type                    = "AWS_PROXY"
      + uri                     = (known after apply)
    }

  # aws_api_gateway_method.proxy will be created
  + resource "aws_api_gateway_method" "proxy" {
      + api_key_required = false
      + authorization    = "CUSTOM"
      + authorizer_id    = (known after apply)
      + http_method      = "POST"
      + id               = (known after apply)
      + resource_id      = (known after apply)
      + rest_api_id      = (known after apply)
    }

  # aws_api_gateway_resource.proxy will be created
  + resource "aws_api_gateway_resource" "proxy" {
      + id          = (known after apply)
      + parent_id   = (known after apply)
      + path        = (known after apply)
      + path_part   = "{proxy+}"
      + rest_api_id = (known after apply)
    }

  # aws_api_gateway_rest_api.ops_bot will be created
  + resource "aws_api_gateway_rest_api" "ops_bot" {
      + api_key_source               = (known after apply)
      + arn                          = (known after apply)
      + binary_media_types           = (known after apply)
      + created_date                 = (known after apply)
      + description                  = (known after apply)
      + disable_execute_api_endpoint = (known after apply)
      + execution_arn                = (known after apply)
      + id                           = (known after apply)
      + minimum_compression_size     = (known after apply)
      + name                         = "ops-bot-prod"
      + policy                       = (known after apply)
      + root_resource_id             = (known after apply)
      + tags_all                     = (known after apply)

      + endpoint_configuration (known after apply)
    }

  # aws_api_gateway_stage.ops_bot will be created
  + resource "aws_api_gateway_stage" "ops_bot" {
      + arn           = (known after apply)
      + deployment_id = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + stage_name    = "prod"
      + tags_all      = (known after apply)
      + web_acl_arn   = (known after apply)
    }

  # aws_cloudwatch_log_group.authorizer will be created
  + resource "aws_cloudwatch_log_group" "authorizer" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-authorizerFn"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_cloudwatch_log_group.probot_handler will be created
  + resource "aws_cloudwatch_log_group" "probot_handler" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-handleProbot"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_iam_role.api_gateway_authorizer will be created
  + resource "aws_iam_role" "api_gateway_authorizer" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "apigateway.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role.lambda_role will be created
  + resource "aws_iam_role" "lambda_role" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "lambda.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-lambda-role"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role_policy.api_gateway_authorizer will be created
  + resource "aws_iam_role_policy" "api_gateway_authorizer" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_iam_role_policy.lambda_policy will be created
  + resource "aws_iam_role_policy" "lambda_policy" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-lambda-policy"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_lambda_function.authorizer will be created
  + resource "aws_lambda_function" "authorizer" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-authorizerFn"
      + handler                        = "dist/authorizer.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "authorizer-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 3
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "probotFnName" = "ops-bot-prod-handleProbot"
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

  # aws_lambda_function.probot_handler will be created
  + resource "aws_lambda_function" "probot_handler" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-handleProbot"
      + handler                        = "dist/probot.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "probot-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 900
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "APP_ID"         = (sensitive value)
              + "GPUTESTER_PAT"  = (sensitive value)
              + "LOG_FORMAT"     = "json"
              + "LOG_LEVEL"      = "debug"
              + "NODE_ENV"       = "prod"
              + "PRIVATE_KEY"    = (sensitive value)
              + "WEBHOOK_SECRET" = (sensitive value)
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

Plan: 15 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + api_gateway_url = (known after apply)

name: deploy-probot-terraform

on:
pull_request:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be removed once this PR is ready and approved as its only been used for the validation of this PR.

We will use the copy-prs plugin for a PR workflow.

@AyodeAwe AyodeAwe marked this pull request as ready for review November 25, 2024 21:37
@GPUtester
Copy link

Terraform Plan 📝

Show Plan
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_api_gateway_authorizer.ops_bot will be created
  + resource "aws_api_gateway_authorizer" "ops_bot" {
      + arn                              = (known after apply)
      + authorizer_credentials           = (known after apply)
      + authorizer_result_ttl_in_seconds = 300
      + authorizer_uri                   = (known after apply)
      + id                               = (known after apply)
      + identity_source                  = "method.request.header.Authorization"
      + name                             = "ops-bot-authorizer"
      + rest_api_id                      = (known after apply)
      + type                             = "REQUEST"
    }

  # aws_api_gateway_deployment.ops_bot will be created
  + resource "aws_api_gateway_deployment" "ops_bot" {
      + created_date  = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + triggers      = (known after apply)
    }

  # aws_api_gateway_integration.lambda will be created
  + resource "aws_api_gateway_integration" "lambda" {
      + cache_namespace         = (known after apply)
      + connection_type         = "INTERNET"
      + http_method             = "POST"
      + id                      = (known after apply)
      + integration_http_method = "POST"
      + passthrough_behavior    = (known after apply)
      + resource_id             = (known after apply)
      + rest_api_id             = (known after apply)
      + timeout_milliseconds    = 29000
      + type                    = "AWS_PROXY"
      + uri                     = (known after apply)
    }

  # aws_api_gateway_method.proxy will be created
  + resource "aws_api_gateway_method" "proxy" {
      + api_key_required = false
      + authorization    = "CUSTOM"
      + authorizer_id    = (known after apply)
      + http_method      = "POST"
      + id               = (known after apply)
      + resource_id      = (known after apply)
      + rest_api_id      = (known after apply)
    }

  # aws_api_gateway_resource.proxy will be created
  + resource "aws_api_gateway_resource" "proxy" {
      + id          = (known after apply)
      + parent_id   = (known after apply)
      + path        = (known after apply)
      + path_part   = "{proxy+}"
      + rest_api_id = (known after apply)
    }

  # aws_api_gateway_rest_api.ops_bot will be created
  + resource "aws_api_gateway_rest_api" "ops_bot" {
      + api_key_source               = (known after apply)
      + arn                          = (known after apply)
      + binary_media_types           = (known after apply)
      + created_date                 = (known after apply)
      + description                  = (known after apply)
      + disable_execute_api_endpoint = (known after apply)
      + execution_arn                = (known after apply)
      + id                           = (known after apply)
      + minimum_compression_size     = (known after apply)
      + name                         = "ops-bot-prod"
      + policy                       = (known after apply)
      + root_resource_id             = (known after apply)
      + tags_all                     = (known after apply)

      + endpoint_configuration (known after apply)
    }

  # aws_api_gateway_stage.ops_bot will be created
  + resource "aws_api_gateway_stage" "ops_bot" {
      + arn           = (known after apply)
      + deployment_id = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + stage_name    = "prod"
      + tags_all      = (known after apply)
      + web_acl_arn   = (known after apply)
    }

  # aws_cloudwatch_log_group.authorizer will be created
  + resource "aws_cloudwatch_log_group" "authorizer" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-authorizerFn"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_cloudwatch_log_group.probot_handler will be created
  + resource "aws_cloudwatch_log_group" "probot_handler" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-handleProbot"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_iam_role.api_gateway_authorizer will be created
  + resource "aws_iam_role" "api_gateway_authorizer" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "apigateway.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role.lambda_role will be created
  + resource "aws_iam_role" "lambda_role" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "lambda.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-lambda-role"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role_policy.api_gateway_authorizer will be created
  + resource "aws_iam_role_policy" "api_gateway_authorizer" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_iam_role_policy.lambda_policy will be created
  + resource "aws_iam_role_policy" "lambda_policy" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-lambda-policy"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_lambda_function.authorizer will be created
  + resource "aws_lambda_function" "authorizer" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-authorizerFn"
      + handler                        = "dist/authorizer.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "authorizer-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 3
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "probotFnName" = "ops-bot-prod-handleProbot"
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

  # aws_lambda_function.probot_handler will be created
  + resource "aws_lambda_function" "probot_handler" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-handleProbot"
      + handler                        = "dist/probot.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "probot-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 900
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "APP_ID"         = (sensitive value)
              + "GPUTESTER_PAT"  = (sensitive value)
              + "LOG_FORMAT"     = "json"
              + "LOG_LEVEL"      = "debug"
              + "NODE_ENV"       = "prod"
              + "PRIVATE_KEY"    = (sensitive value)
              + "WEBHOOK_SECRET" = (sensitive value)
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

Plan: 15 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + api_gateway_url = (known after apply)

.github/workflows/deploy-v2.yaml Outdated Show resolved Hide resolved
.github/workflows/deploy-v2.yaml Outdated Show resolved Hide resolved
terraform/lambda.tf Outdated Show resolved Hide resolved
terraform/lambda.tf Outdated Show resolved Hide resolved
terraform/iam.tf Outdated Show resolved Hide resolved
.github/workflows/deploy-v2.yaml Outdated Show resolved Hide resolved
@jjacobelli
Copy link
Contributor

Documentation should be updated too

@GPUtester
Copy link

Terraform Plan 📝

Show Plan
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_api_gateway_authorizer.ops_bot will be created
  + resource "aws_api_gateway_authorizer" "ops_bot" {
      + arn                              = (known after apply)
      + authorizer_credentials           = (known after apply)
      + authorizer_result_ttl_in_seconds = 300
      + authorizer_uri                   = (known after apply)
      + id                               = (known after apply)
      + identity_source                  = "method.request.header.Authorization"
      + name                             = "ops-bot-authorizer"
      + rest_api_id                      = (known after apply)
      + type                             = "REQUEST"
    }

  # aws_api_gateway_deployment.ops_bot will be created
  + resource "aws_api_gateway_deployment" "ops_bot" {
      + created_date  = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + triggers      = (known after apply)
    }

  # aws_api_gateway_integration.lambda will be created
  + resource "aws_api_gateway_integration" "lambda" {
      + cache_namespace         = (known after apply)
      + connection_type         = "INTERNET"
      + http_method             = "POST"
      + id                      = (known after apply)
      + integration_http_method = "POST"
      + passthrough_behavior    = (known after apply)
      + resource_id             = (known after apply)
      + rest_api_id             = (known after apply)
      + timeout_milliseconds    = 29000
      + type                    = "AWS_PROXY"
      + uri                     = (known after apply)
    }

  # aws_api_gateway_method.proxy will be created
  + resource "aws_api_gateway_method" "proxy" {
      + api_key_required = false
      + authorization    = "CUSTOM"
      + authorizer_id    = (known after apply)
      + http_method      = "POST"
      + id               = (known after apply)
      + resource_id      = (known after apply)
      + rest_api_id      = (known after apply)
    }

  # aws_api_gateway_resource.proxy will be created
  + resource "aws_api_gateway_resource" "proxy" {
      + id          = (known after apply)
      + parent_id   = (known after apply)
      + path        = (known after apply)
      + path_part   = "{proxy+}"
      + rest_api_id = (known after apply)
    }

  # aws_api_gateway_rest_api.ops_bot will be created
  + resource "aws_api_gateway_rest_api" "ops_bot" {
      + api_key_source               = (known after apply)
      + arn                          = (known after apply)
      + binary_media_types           = (known after apply)
      + created_date                 = (known after apply)
      + description                  = (known after apply)
      + disable_execute_api_endpoint = (known after apply)
      + execution_arn                = (known after apply)
      + id                           = (known after apply)
      + minimum_compression_size     = (known after apply)
      + name                         = "ops-bot-prod"
      + policy                       = (known after apply)
      + root_resource_id             = (known after apply)
      + tags_all                     = (known after apply)

      + endpoint_configuration (known after apply)
    }

  # aws_api_gateway_stage.ops_bot will be created
  + resource "aws_api_gateway_stage" "ops_bot" {
      + arn           = (known after apply)
      + deployment_id = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + stage_name    = "prod"
      + tags_all      = (known after apply)
      + web_acl_arn   = (known after apply)
    }

  # aws_cloudwatch_log_group.authorizer will be created
  + resource "aws_cloudwatch_log_group" "authorizer" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-authorizerFn"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_cloudwatch_log_group.probot_handler will be created
  + resource "aws_cloudwatch_log_group" "probot_handler" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-handleProbot"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_iam_role.api_gateway_authorizer will be created
  + resource "aws_iam_role" "api_gateway_authorizer" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "apigateway.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role.lambda_role will be created
  + resource "aws_iam_role" "lambda_role" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "lambda.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-lambda-role"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role_policy.api_gateway_authorizer will be created
  + resource "aws_iam_role_policy" "api_gateway_authorizer" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_iam_role_policy.lambda_policy will be created
  + resource "aws_iam_role_policy" "lambda_policy" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-lambda-policy"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_lambda_function.authorizer will be created
  + resource "aws_lambda_function" "authorizer" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-authorizerFn"
      + handler                        = "dist/authorizer.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "authorizer-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 3
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "probotFnName" = "ops-bot-prod-handleProbot"
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

  # aws_lambda_function.probot_handler will be created
  + resource "aws_lambda_function" "probot_handler" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-handleProbot"
      + handler                        = "dist/probot.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "probot-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 900
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "APP_ID"         = (sensitive value)
              + "GPUTESTER_PAT"  = (sensitive value)
              + "LOG_FORMAT"     = "json"
              + "LOG_LEVEL"      = "debug"
              + "NODE_ENV"       = "prod"
              + "PRIVATE_KEY"    = (sensitive value)
              + "WEBHOOK_SECRET" = (sensitive value)
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

Plan: 15 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + api_gateway_url = (known after apply)

@GPUtester
Copy link

Terraform Plan 📝

Show Plan
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_api_gateway_authorizer.ops_bot will be created
  + resource "aws_api_gateway_authorizer" "ops_bot" {
      + arn                              = (known after apply)
      + authorizer_credentials           = (known after apply)
      + authorizer_result_ttl_in_seconds = 300
      + authorizer_uri                   = (known after apply)
      + id                               = (known after apply)
      + identity_source                  = "method.request.header.Authorization"
      + name                             = "ops-bot-authorizer"
      + rest_api_id                      = (known after apply)
      + type                             = "REQUEST"
    }

  # aws_api_gateway_deployment.ops_bot will be created
  + resource "aws_api_gateway_deployment" "ops_bot" {
      + created_date  = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + triggers      = (known after apply)
    }

  # aws_api_gateway_integration.lambda will be created
  + resource "aws_api_gateway_integration" "lambda" {
      + cache_namespace         = (known after apply)
      + connection_type         = "INTERNET"
      + http_method             = "POST"
      + id                      = (known after apply)
      + integration_http_method = "POST"
      + passthrough_behavior    = (known after apply)
      + resource_id             = (known after apply)
      + rest_api_id             = (known after apply)
      + timeout_milliseconds    = 29000
      + type                    = "AWS_PROXY"
      + uri                     = (known after apply)
    }

  # aws_api_gateway_method.proxy will be created
  + resource "aws_api_gateway_method" "proxy" {
      + api_key_required = false
      + authorization    = "CUSTOM"
      + authorizer_id    = (known after apply)
      + http_method      = "POST"
      + id               = (known after apply)
      + resource_id      = (known after apply)
      + rest_api_id      = (known after apply)
    }

  # aws_api_gateway_resource.proxy will be created
  + resource "aws_api_gateway_resource" "proxy" {
      + id          = (known after apply)
      + parent_id   = (known after apply)
      + path        = (known after apply)
      + path_part   = "{proxy+}"
      + rest_api_id = (known after apply)
    }

  # aws_api_gateway_rest_api.ops_bot will be created
  + resource "aws_api_gateway_rest_api" "ops_bot" {
      + api_key_source               = (known after apply)
      + arn                          = (known after apply)
      + binary_media_types           = (known after apply)
      + created_date                 = (known after apply)
      + description                  = (known after apply)
      + disable_execute_api_endpoint = (known after apply)
      + execution_arn                = (known after apply)
      + id                           = (known after apply)
      + minimum_compression_size     = (known after apply)
      + name                         = "ops-bot-prod"
      + policy                       = (known after apply)
      + root_resource_id             = (known after apply)
      + tags_all                     = (known after apply)

      + endpoint_configuration (known after apply)
    }

  # aws_api_gateway_stage.ops_bot will be created
  + resource "aws_api_gateway_stage" "ops_bot" {
      + arn           = (known after apply)
      + deployment_id = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + stage_name    = "prod"
      + tags_all      = (known after apply)
      + web_acl_arn   = (known after apply)
    }

  # aws_cloudwatch_log_group.authorizer will be created
  + resource "aws_cloudwatch_log_group" "authorizer" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-authorizerFn"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_cloudwatch_log_group.probot_handler will be created
  + resource "aws_cloudwatch_log_group" "probot_handler" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-handleProbot"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_iam_role.api_gateway_authorizer will be created
  + resource "aws_iam_role" "api_gateway_authorizer" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "apigateway.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role.lambda_role will be created
  + resource "aws_iam_role" "lambda_role" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "lambda.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-lambda-role"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role_policy.api_gateway_authorizer will be created
  + resource "aws_iam_role_policy" "api_gateway_authorizer" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_iam_role_policy.lambda_policy will be created
  + resource "aws_iam_role_policy" "lambda_policy" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-lambda-policy"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_lambda_function.authorizer will be created
  + resource "aws_lambda_function" "authorizer" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-authorizerFn"
      + handler                        = "dist/authorizer.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "authorizer-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 3
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "probotFnName" = "ops-bot-prod-handleProbot"
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

  # aws_lambda_function.probot_handler will be created
  + resource "aws_lambda_function" "probot_handler" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-handleProbot"
      + handler                        = "dist/probot.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "probot-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 900
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "APP_ID"         = (sensitive value)
              + "GPUTESTER_PAT"  = (sensitive value)
              + "LOG_FORMAT"     = "json"
              + "LOG_LEVEL"      = "debug"
              + "NODE_ENV"       = "prod"
              + "PRIVATE_KEY"    = (sensitive value)
              + "WEBHOOK_SECRET" = (sensitive value)
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

Plan: 15 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + api_gateway_url = (known after apply)

@GPUtester
Copy link

Terraform Plan 📝

Show Plan
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_api_gateway_authorizer.ops_bot will be created
  + resource "aws_api_gateway_authorizer" "ops_bot" {
      + arn                              = (known after apply)
      + authorizer_credentials           = (known after apply)
      + authorizer_result_ttl_in_seconds = 300
      + authorizer_uri                   = (known after apply)
      + id                               = (known after apply)
      + identity_source                  = "method.request.header.Authorization"
      + name                             = "ops-bot-authorizer"
      + rest_api_id                      = (known after apply)
      + type                             = "REQUEST"
    }

  # aws_api_gateway_deployment.ops_bot will be created
  + resource "aws_api_gateway_deployment" "ops_bot" {
      + created_date  = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + triggers      = (known after apply)
    }

  # aws_api_gateway_integration.lambda will be created
  + resource "aws_api_gateway_integration" "lambda" {
      + cache_namespace         = (known after apply)
      + connection_type         = "INTERNET"
      + http_method             = "POST"
      + id                      = (known after apply)
      + integration_http_method = "POST"
      + passthrough_behavior    = (known after apply)
      + resource_id             = (known after apply)
      + rest_api_id             = (known after apply)
      + timeout_milliseconds    = 29000
      + type                    = "AWS_PROXY"
      + uri                     = (known after apply)
    }

  # aws_api_gateway_method.proxy will be created
  + resource "aws_api_gateway_method" "proxy" {
      + api_key_required = false
      + authorization    = "CUSTOM"
      + authorizer_id    = (known after apply)
      + http_method      = "POST"
      + id               = (known after apply)
      + resource_id      = (known after apply)
      + rest_api_id      = (known after apply)
    }

  # aws_api_gateway_resource.proxy will be created
  + resource "aws_api_gateway_resource" "proxy" {
      + id          = (known after apply)
      + parent_id   = (known after apply)
      + path        = (known after apply)
      + path_part   = "{proxy+}"
      + rest_api_id = (known after apply)
    }

  # aws_api_gateway_rest_api.ops_bot will be created
  + resource "aws_api_gateway_rest_api" "ops_bot" {
      + api_key_source               = (known after apply)
      + arn                          = (known after apply)
      + binary_media_types           = (known after apply)
      + created_date                 = (known after apply)
      + description                  = (known after apply)
      + disable_execute_api_endpoint = (known after apply)
      + execution_arn                = (known after apply)
      + id                           = (known after apply)
      + minimum_compression_size     = (known after apply)
      + name                         = "ops-bot-prod"
      + policy                       = (known after apply)
      + root_resource_id             = (known after apply)
      + tags_all                     = (known after apply)

      + endpoint_configuration (known after apply)
    }

  # aws_api_gateway_stage.ops_bot will be created
  + resource "aws_api_gateway_stage" "ops_bot" {
      + arn           = (known after apply)
      + deployment_id = (known after apply)
      + execution_arn = (known after apply)
      + id            = (known after apply)
      + invoke_url    = (known after apply)
      + rest_api_id   = (known after apply)
      + stage_name    = "prod"
      + tags_all      = (known after apply)
      + web_acl_arn   = (known after apply)
    }

  # aws_cloudwatch_log_group.authorizer will be created
  + resource "aws_cloudwatch_log_group" "authorizer" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-authorizerFn"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_cloudwatch_log_group.probot_handler will be created
  + resource "aws_cloudwatch_log_group" "probot_handler" {
      + arn               = (known after apply)
      + id                = (known after apply)
      + log_group_class   = (known after apply)
      + name              = "/aws/lambda/ops-bot-prod-handleProbot"
      + name_prefix       = (known after apply)
      + retention_in_days = 60
      + skip_destroy      = false
      + tags_all          = (known after apply)
    }

  # aws_iam_role.api_gateway_authorizer will be created
  + resource "aws_iam_role" "api_gateway_authorizer" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "apigateway.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role.lambda_role will be created
  + resource "aws_iam_role" "lambda_role" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "sts:AssumeRole",
                        ]
                      + Effect    = "Allow"
                      + Principal = {
                          + Service = [
                              + "lambda.amazonaws.com",
                            ]
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = false
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "ops-bot-prod-lambda-role"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)

      + inline_policy (known after apply)
    }

  # aws_iam_role_policy.api_gateway_authorizer will be created
  + resource "aws_iam_role_policy" "api_gateway_authorizer" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-api-gateway-authorizer"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_iam_role_policy.lambda_policy will be created
  + resource "aws_iam_role_policy" "lambda_policy" {
      + id          = (known after apply)
      + name        = "ops-bot-prod-lambda-policy"
      + name_prefix = (known after apply)
      + policy      = (known after apply)
      + role        = (known after apply)
    }

  # aws_lambda_function.authorizer will be created
  + resource "aws_lambda_function" "authorizer" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-authorizerFn"
      + handler                        = "dist/authorizer.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "authorizer-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 3
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "probotFnName" = "ops-bot-prod-handleProbot"
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

  # aws_lambda_function.probot_handler will be created
  + resource "aws_lambda_function" "probot_handler" {
      + architectures                  = (known after apply)
      + arn                            = (known after apply)
      + code_sha256                    = (known after apply)
      + function_name                  = "ops-bot-prod-handleProbot"
      + handler                        = "dist/probot.handler"
      + id                             = (known after apply)
      + invoke_arn                     = (known after apply)
      + last_modified                  = (known after apply)
      + memory_size                    = 1024
      + package_type                   = "Zip"
      + publish                        = false
      + qualified_arn                  = (known after apply)
      + qualified_invoke_arn           = (known after apply)
      + reserved_concurrent_executions = -1
      + role                           = (known after apply)
      + runtime                        = "nodejs18.x"
      + s3_bucket                      = "rapidsai-serverless-deployments"
      + s3_key                         = "probot-.zip"
      + signing_job_arn                = (known after apply)
      + signing_profile_version_arn    = (known after apply)
      + skip_destroy                   = false
      + source_code_hash               = (known after apply)
      + source_code_size               = (known after apply)
      + tags_all                       = (known after apply)
      + timeout                        = 900
      + version                        = (known after apply)

      + environment {
          + variables = {
              + "APP_ID"         = (sensitive value)
              + "GPUTESTER_PAT"  = (sensitive value)
              + "LOG_FORMAT"     = "json"
              + "LOG_LEVEL"      = "debug"
              + "NODE_ENV"       = "prod"
              + "PRIVATE_KEY"    = (sensitive value)
              + "WEBHOOK_SECRET" = (sensitive value)
            }
        }

      + ephemeral_storage (known after apply)

      + logging_config (known after apply)

      + tracing_config (known after apply)
    }

Plan: 15 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + api_gateway_url = (known after apply)

.github/workflows/ci.yaml Outdated Show resolved Hide resolved
terraform/variables.tf Outdated Show resolved Hide resolved
terraform/lambda.tf Outdated Show resolved Hide resolved
@AyodeAwe AyodeAwe mentioned this pull request Dec 2, 2024
.github/workflows/ci.yaml Outdated Show resolved Hide resolved
.github/workflows/ci.yaml Outdated Show resolved Hide resolved
.github/workflows/ci.yaml Outdated Show resolved Hide resolved
terraform/lambda.tf Outdated Show resolved Hide resolved
terraform/variables.tf Outdated Show resolved Hide resolved
.github/workflows/ci.yaml Outdated Show resolved Hide resolved
@AyodeAwe
Copy link
Contributor Author

AyodeAwe commented Dec 5, 2024

@raydouglass any final thoughts before I merge?

The deployment has been tested (via rapids-bot-testing app) with https://github.com/rapidsai/literate-octo-potato/pull/873.

Once this is merged and deployed, I will go ahead to switch the webhook endpoints here (and immediately test again).

@AyodeAwe AyodeAwe merged commit fdeb43f into main Dec 5, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants