<commit_before>resource "aws_api_gateway_resource" "main" {
  rest_api_id = "${var.rest_api_id}"
  parent_id   = "${var.parent_id}"
  path_part   = "${var.resource_part}"
}

resource "aws_api_gateway_method" "main" {
  rest_api_id   = "${var.rest_api_id}"
  resource_id   = "${aws_api_gateway_resource.main.id}"
  http_method   = "${var.method}"
  authorization = "NONE"
}

resource "aws_api_gateway_integration" "main" {
  depends_on              = ["aws_api_gateway_method.main"] 
  rest_api_id             = "${var.rest_api_id}"
  type                    = "AWS_PROXY"
  resource_id             = "${aws_api_gateway_resource.main.id}"
  http_method             = "${aws_api_gateway_method.main.http_method}"
  uri                     = "arn:aws:apigateway:${element(split(":", "${var.lambda_arn}"), 3)}:lambda:path/2015-03-31/functions/${var.lambda_arn}/invocations"
  integration_http_method = "POST"
  # request_templates = {
  #   "application/json" = "${file("${path.module}/mappings.js")}"
  # }
}

resource "aws_api_gateway_integration_response" "200" {
  depends_on  = ["aws_api_gateway_integration.main"]

  rest_api_id       = "${var.rest_api_id}"
  resource_id       = "${aws_api_gateway_resource.main.id}"
  http_method       = "${aws_api_gateway_method.main.http_method}"
  status_code       = "${aws_api_gateway_method_response.200.status_code}"
  response_parameters = {
    # "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'",
    # "method.response.header.Access-Control-Allow-Methods" = "'POST,OPTIONS,GET,PUT,PATCH,DELETE'",
    "method.response.header.Access-Control-Allow-Origin"  = "'${var.allow_origin}'"
  }
}

resource "aws_api_gateway_method_response" "200" {
  rest_api_id = "${var.rest_api_id}"
  resource_id = "${aws_api_gateway_resource.main.id}"
  http_method = "${aws_api_gateway_method.main.http_method}"
  status_code = "200"
  response_parameters = { 
    # "method.response.header.Access-Control-Allow-Headers" = true,
    # "method.response.header.Access-Control-Allow-Methods" = true,
    "method.response.header.Access-Control-Allow-Origin"  = true
  }

  provisioner "local-exec" {
    command = "sleep 3"
  }<commit_msg>added dependency on method<commit_after>resource "aws_api_gateway_resource" "main" {
  rest_api_id = "${var.rest_api_id}"
  parent_id   = "${var.parent_id}"
  path_part   = "${var.resource_part}"
}

resource "aws_api_gateway_method" "main" {
  rest_api_id   = "${var.rest_api_id}"
  resource_id   = "${aws_api_gateway_resource.main.id}"
  http_method   = "${var.method}"
  authorization = "NONE"
}

resource "aws_api_gateway_integration" "main" {
  depends_on              = ["aws_api_gateway_method.main"] 
  rest_api_id             = "${var.rest_api_id}"
  type                    = "AWS_PROXY"
  resource_id             = "${aws_api_gateway_resource.main.id}"
  http_method             = "${aws_api_gateway_method.main.http_method}"
  uri                     = "arn:aws:apigateway:${element(split(":", "${var.lambda_arn}"), 3)}:lambda:path/2015-03-31/functions/${var.lambda_arn}/invocations"
  integration_http_method = "POST"
  # request_templates = {
  #   "application/json" = "${file("${path.module}/mappings.js")}"
  # }
}

resource "aws_api_gateway_integration_response" "200" {
  depends_on  = ["aws_api_gateway_integration.main"]

  rest_api_id       = "${var.rest_api_id}"
  resource_id       = "${aws_api_gateway_resource.main.id}"
  http_method       = "${aws_api_gateway_method.main.http_method}"
  status_code       = "${aws_api_gateway_method_response.200.status_code}"
  response_parameters = {
    # "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'",
    # "method.response.header.Access-Control-Allow-Methods" = "'POST,OPTIONS,GET,PUT,PATCH,DELETE'",
    "method.response.header.Access-Control-Allow-Origin"  = "'${var.allow_origin}'"
  }
}

resource "aws_api_gateway_method_response" "200" {
  depends_on  = ["aws_api_gateway_method.main"] 
  rest_api_id = "${var.rest_api_id}"
  resource_id = "${aws_api_gateway_resource.main.id}"
  http_method = "${aws_api_gateway_method.main.http_method}"
  status_code = "200"
  response_parameters = { 
    # "method.response.header.Access-Control-Allow-Headers" = true,
    # "method.response.header.Access-Control-Allow-Methods" = true,
    "method.response.header.Access-Control-Allow-Origin"  = true
  }

  provisioner "local-exec" {
    command = "sleep 3"
  }
{'fraction_non_alphanumeric': 0.1535415750109987, 'fraction_numerical': 0.009678838539375276, 'mean_word_length': 3.9531590413943354, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3196536', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1612, 'n_words': 175}