Ensure AWS API deployments enable Create before Destroy

Error: AWS API deployments do not enable Create before Destroy

Bridgecrew Policy ID: BC_AWS_GENERAL_145
Checkov Check ID: CKV_AWS_217
Severity: LOW

AWS API deployments do not enable Create before Destroy

Description

It is recommended to enable create_before_destroy argument inside the resource lifecycle configuration block to avoid possible return errors such as BadRequestException: Active stages pointing to this deployment must be moved or deleted on recreation.

Fix - Buildtime

CloudFormation

CloudFormation creates a new deployment first and then will delete the old one automatically.

Terraform

resource "aws_api_gateway_deployment" "example" {
  rest_api_id = aws_api_gateway_rest_api.example.id
  stage_name  = "example"
  
+ lifecycle {
+   create_before_destroy = true
+ }
}

Did this page help you?