Skip to content

Commit

Permalink
Prepare for removal of api gateway mock healthcheck (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcgrath authored Aug 14, 2020
1 parent a6b6422 commit 2ffce30
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
All notable changes to this project will be documented in this file.

## [Unreleased]
- Updated: Added explicit depends_on for the APIGateway /healthcheck resources, need this to be applied on all envs before we can remove this mock integration
- Added: ALB logging - both ALBs log to the same bucket, using distinct prefixes - api and push
- Updated: Upgraded AWS provider from = 2.68.0 to ~> 2.70.0
- Updated: Switched to using templatefile function rather than deprecated template provider
Expand Down
44 changes: 0 additions & 44 deletions gateway.tf
Original file line number Diff line number Diff line change
Expand Up @@ -551,47 +551,3 @@ resource "aws_api_gateway_authorizer" "main" {
authorizer_uri = coalesce(join("", aws_lambda_alias.authorizer_live.*.invoke_arn), aws_lambda_function.authorizer.invoke_arn)
authorizer_credentials = aws_iam_role.authorizer.arn
}

# PENDING: Had to restore this as we had an issue when doing an apply
# - Error: Cycle: module.this.aws_api_gateway_stage.live, module.this.aws_api_gateway_resource.api_healthcheck (destroy), module.this.aws_api_gateway_method.api_healthcheck_get (destroy), module.this.aws_api_gateway_deployment.live, module.this.aws_api_gateway_deployment.live (destroy deposed 754a6586), module.this.aws_api_gateway_integration.api_healthcheck_get_integration (destroy)
## /api/healthcheck
resource "aws_api_gateway_resource" "api_healthcheck" {
rest_api_id = aws_api_gateway_rest_api.main.id
parent_id = aws_api_gateway_resource.api.id
path_part = "healthcheck"
}

resource "aws_api_gateway_method" "api_healthcheck_get" {
rest_api_id = aws_api_gateway_rest_api.main.id
resource_id = aws_api_gateway_resource.api_healthcheck.id
http_method = "GET"
authorization = "NONE"
api_key_required = false
}

resource "aws_api_gateway_integration" "api_healthcheck_get_integration" {
rest_api_id = aws_api_gateway_rest_api.main.id
resource_id = aws_api_gateway_resource.api_healthcheck.id
http_method = aws_api_gateway_method.api_healthcheck_get.http_method
passthrough_behavior = "WHEN_NO_TEMPLATES"
type = "MOCK"
request_templates = {
"application/json" = jsonencode({
statusCode = 204
})
}
}

resource "aws_api_gateway_method_response" "api_healthcheck_get" {
rest_api_id = aws_api_gateway_rest_api.main.id
resource_id = aws_api_gateway_resource.api_healthcheck.id
http_method = aws_api_gateway_method.api_healthcheck_get.http_method
status_code = "204"
}

resource "aws_api_gateway_integration_response" "api_healthcheck_get_integration" {
rest_api_id = aws_api_gateway_rest_api.main.id
resource_id = aws_api_gateway_resource.api_healthcheck.id
http_method = aws_api_gateway_method.api_healthcheck_get.http_method
status_code = aws_api_gateway_method_response.api_healthcheck_get.status_code
}
58 changes: 58 additions & 0 deletions remove-me-later.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,65 @@ provider "aws" {
profile = var.dns_profile
}


## We keep this till we have applied all the way to prod and state files are updated
provider "template" {
version = "~> 2.1"
}


## Need to do a sequence to remove
## To remove we needed to add explicit depends_on
## Apply on all envs
## After the apply on all envs we can remove this and it should remove successfully
## Was getting this error
## Error: Cycle: module.this.aws_api_gateway_stage.live, module.this.aws_api_gateway_resource.api_healthcheck (destroy), module.this.aws_api_gateway_method.api_healthcheck_get (destroy), module.this.aws_api_gateway_deployment.live, module.this.aws_api_gateway_deployment.live (destroy deposed 754a6586), module.this.aws_api_gateway_integration.api_healthcheck_get_integration (destroy)
## /api/healthcheck
resource "aws_api_gateway_resource" "api_healthcheck" {
rest_api_id = aws_api_gateway_rest_api.main.id
parent_id = aws_api_gateway_resource.api.id
path_part = "healthcheck"
}

resource "aws_api_gateway_method" "api_healthcheck_get" {
rest_api_id = aws_api_gateway_rest_api.main.id
resource_id = aws_api_gateway_resource.api_healthcheck.id
http_method = "GET"
authorization = "NONE"
api_key_required = false

depends_on = [aws_api_gateway_resource.api_healthcheck]
}

resource "aws_api_gateway_integration" "api_healthcheck_get_integration" {
rest_api_id = aws_api_gateway_rest_api.main.id
resource_id = aws_api_gateway_resource.api_healthcheck.id
http_method = aws_api_gateway_method.api_healthcheck_get.http_method
passthrough_behavior = "WHEN_NO_TEMPLATES"
type = "MOCK"
request_templates = {
"application/json" = jsonencode({
statusCode = 204
})
}

depends_on = [aws_api_gateway_method.api_healthcheck_get]
}

resource "aws_api_gateway_method_response" "api_healthcheck_get" {
rest_api_id = aws_api_gateway_rest_api.main.id
resource_id = aws_api_gateway_resource.api_healthcheck.id
http_method = aws_api_gateway_method.api_healthcheck_get.http_method
status_code = "204"

depends_on = [aws_api_gateway_method.api_healthcheck_get]
}

resource "aws_api_gateway_integration_response" "api_healthcheck_get_integration" {
rest_api_id = aws_api_gateway_rest_api.main.id
resource_id = aws_api_gateway_resource.api_healthcheck.id
http_method = aws_api_gateway_method.api_healthcheck_get.http_method
status_code = aws_api_gateway_method_response.api_healthcheck_get.status_code

depends_on = [aws_api_gateway_integration.api_healthcheck_get_integration]
}

0 comments on commit 2ffce30

Please sign in to comment.