mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 11:23:12 +00:00
Some checks are pending
Deploy / Deploy to prod (push) Waiting to run
* fix(cutover): write Slack secrets into empty Terraform shells DescribeSecret succeeds on HCP-created shells with no version, so skip-if-exists left roster and Slack tokens unset. * feat(infra): migrate afterhours to HCP Terraform (PLAT-74) Replace the mgmt SAM stack with a prod-only HCP workspace, in-repo hcptf IAM, stub Lambdas, and zip CD on push to main. * fix(cutover): retry DDB unprocessed items and skip past at() holidays Unprocessed BatchWriteItem rows and leftover past at() schedules would drop roster data or abort holiday recreation during prod cutover.
82 lines
3 KiB
HCL
82 lines
3 KiB
HCL
# HTTP API: Slack events plus the Paychex roster contract.
|
|
|
|
resource "aws_apigatewayv2_api" "http" {
|
|
name = local.project
|
|
protocol_type = "HTTP"
|
|
description = "afterhours-shift-manager Slack and roster API"
|
|
}
|
|
|
|
resource "aws_apigatewayv2_integration" "slack_bot" {
|
|
api_id = aws_apigatewayv2_api.http.id
|
|
integration_type = "AWS_PROXY"
|
|
integration_method = "POST"
|
|
integration_uri = aws_lambda_function.this["slack_bot"].invoke_arn
|
|
payload_format_version = "2.0"
|
|
timeout_milliseconds = 30000
|
|
}
|
|
|
|
resource "aws_apigatewayv2_integration" "roster_api" {
|
|
api_id = aws_apigatewayv2_api.http.id
|
|
integration_type = "AWS_PROXY"
|
|
integration_method = "POST"
|
|
integration_uri = aws_lambda_function.this["roster_api"].invoke_arn
|
|
payload_format_version = "2.0"
|
|
timeout_milliseconds = 30000
|
|
}
|
|
|
|
resource "aws_apigatewayv2_route" "slack_events" {
|
|
api_id = aws_apigatewayv2_api.http.id
|
|
route_key = "POST /slack/events"
|
|
target = "integrations/${aws_apigatewayv2_integration.slack_bot.id}"
|
|
}
|
|
|
|
resource "aws_apigatewayv2_route" "put_roster" {
|
|
api_id = aws_apigatewayv2_api.http.id
|
|
route_key = "PUT /roster"
|
|
target = "integrations/${aws_apigatewayv2_integration.roster_api.id}"
|
|
}
|
|
|
|
resource "aws_apigatewayv2_route" "delete_roster" {
|
|
api_id = aws_apigatewayv2_api.http.id
|
|
route_key = "DELETE /roster/{extension}"
|
|
target = "integrations/${aws_apigatewayv2_integration.roster_api.id}"
|
|
}
|
|
|
|
resource "aws_apigatewayv2_stage" "default" {
|
|
api_id = aws_apigatewayv2_api.http.id
|
|
name = "$default"
|
|
auto_deploy = true
|
|
|
|
access_log_settings {
|
|
destination_arn = aws_cloudwatch_log_group.api_access.arn
|
|
format = "{\"requestId\":\"$context.requestId\",\"ip\":\"$context.identity.sourceIp\",\"requestTime\":\"$context.requestTime\",\"method\":\"$context.httpMethod\",\"routeKey\":\"$context.routeKey\",\"status\":\"$context.status\",\"protocol\":\"$context.protocol\",\"responseLength\":\"$context.responseLength\",\"integrationError\":\"$context.integrationErrorMessage\"}"
|
|
}
|
|
|
|
default_route_settings {
|
|
throttling_burst_limit = 50
|
|
throttling_rate_limit = 100
|
|
}
|
|
|
|
depends_on = [
|
|
aws_apigatewayv2_route.slack_events,
|
|
aws_apigatewayv2_route.put_roster,
|
|
aws_apigatewayv2_route.delete_roster,
|
|
aws_iam_role_policy.hcptf_apply_services,
|
|
]
|
|
}
|
|
|
|
resource "aws_lambda_permission" "api_slack_bot" {
|
|
statement_id = "AllowApiGatewayInvokeSlackBot"
|
|
action = "lambda:InvokeFunction"
|
|
function_name = aws_lambda_function.this["slack_bot"].function_name
|
|
principal = "apigateway.amazonaws.com"
|
|
source_arn = "${aws_apigatewayv2_api.http.execution_arn}/*/*"
|
|
}
|
|
|
|
resource "aws_lambda_permission" "api_roster_api" {
|
|
statement_id = "AllowApiGatewayInvokeRosterApi"
|
|
action = "lambda:InvokeFunction"
|
|
function_name = aws_lambda_function.this["roster_api"].function_name
|
|
principal = "apigateway.amazonaws.com"
|
|
source_arn = "${aws_apigatewayv2_api.http.execution_arn}/*/*"
|
|
}
|