Skip to content

DevSecTop/nr-terraform-multiple-accounts

Repository files navigation

New Relic Terraform for Multiple Accounts

Prototype which adopts a flat, modular approach to generating resources at scale for multiple accounts using New Relic's Terraform provider without any dependencies.

Prerequisites

Usage

  1. Clone the repository.
  2. Access terraform.tfvars.json.
  3. Replace account_id, api_key, and (optionally) alias with your accounts' data.
  4. Initialise Terraform with latest provider: terraform init -upgrade.
  5. Apply configuration with placeholder data: terraform apply -auto-approve -compact-warnings.

Configuration

  • For a flat structure, shared configurations are prefixed shared-- at the root of the directory.
    • This removes the need for external wrappers, such as Terragrunt.
    • Each account requires an alias in order to pass its associated account_id into referenced modules via providers.
  • Each module is located in its own subdirectory to:
    • Encourage reusability: keeping code DRY.
    • Prevent conflict of duplicate entity names.
  • Modules are paired with a generic versions.tf which inherits version details from the root to remain flexible for upgrades.
Module Description Input Output
apm_alert APM alert policies and associated NRQL conditions. Account alias, runbook URL and channel IDs. None.
channel Alert notification channels. None. Channel IDs.
dashboard Dashboard. Account alias. Dashboard URL.
synthetic Synthetic monitors and associated multilocation alert conditions. Account alias, runbook URL, channel IDs, and endpoints. None.

Support

Issues

  • Synthetic multilocation alert condition is changed on every run.
    • Workaround: Add lifecycle { ignore_changes = [entities] } to the resource to ignore changes.

Contributing

Pull requests are welcome and appreciated. For major contributions, please open an issue to discuss what you would like to change.

License

GNU Affero General Public License v3.0

Credits

Neither myself nor this project are associated with New Relic™.

All works herein are my own and shared of my own volition.

Copyleft @ All wrongs reserved.