# Overrides

The Golden Path uses Boilerplate templating to set up your infrastructure. To get all the benefits from being on the Golden Path, use Terraform overrides when you need to diverge from the path.

<!-- prettier-ignore-start -->
!!! tip "Learn more about overrides"
    See the [HashiCorp documentation for override files](https://developer.hashicorp.com/terraform/language/files/override){:target="_blank"}.

!!! example "Reference implementation"
    See [how Terraform overrides are used in `pirates-iac`](https://github.com/oslokommune/pirates-iac/blob/main/stacks/dev/app-too-tikki/_gp_alb_tg_host_routing_override.tf#L11){:target="_blank"}.
<!-- prettier-ignore-end -->

## Why use overrides?

Overrides let you make changes based on your needs while still getting infrastructure updates.
Overrides that teams create are tracked and added to the Golden Path when possible.

`__gp_config.tf` files are always preserved and never overwritten during template re-rendering. All other `_gp` or `__gp` prefixed files are overwritten during re-rendering.

## Frequently asked questions

<!-- Entries under this heading must be phrased as questions. -->

### How to remove a resource created by Boilerplate?

<!-- prettier-ignore-start -->
!!! Warning "Considerations"
    Before you remove resources from Boilerplate you should consider if the change you need could be done as a feature toggle in Boilerplate. You should also consider that other parts of the Golden Path might depend on the resource you are trying to remove. Removing resources in this way should be a last resort.
<!-- prettier-ignore-end -->

You can remove a resource added by Boilerplate by adding a `count` to the resource. Given the following Terraform code:

```hcl
resource "aws_s3_bucket" "example" {
  bucket = "my-tf-test-bucket"

  tags = {
    Name        = "My bucket"
    Environment = "Dev"
  }
}
```

Adding a `count` override to the resource in a file with the ending `_override.tf` removes the resource:

```hcl
resource "aws_s3_bucket" "example" {
    count = 0
}
```
