DevOps teams often use infrastructure-as-code (IaC) to provision, deploy, and manage applications in the cloud. AWS CloudFormation is one tool that provides IaC functionality, and AWS customers can now use third-party resource providers in their application stacks configured with CloudFormation.

In New Relic One, you can now create NRQL alert conditions as resources directly in CloudFormation templates.

At New Relic, we believe that observability is fundamental to building great software, and part of any successful observability practice is noticing when things go wrong. New Relic alerts allow you to flexibly create and configure alerting for your services and applications. Alert conditions describe when the behavior of a monitored service or application is considered a violation. For example, DevOps teams at New Relic use alert conditions to watch for increases in resource use that may require them to scale their infrastructure capacity.

In this post, we’ll execute an example CloudFormation template that creates an AWS Lambda function with a built-in New Relic alert condition resource type.

About AWS CloudFormation

In CloudFormation, you use templates written in JSON or YAML to express a high-level description of how your various AWS resources and the interactions between them form a "stack." An execution engine uses this template to build the stack using the resources you specified. Since this infrastructure is expressed as code, CloudFormation can build this stack again and again, and it will be the same every time.

AWS services typically have well-documented APIs. CloudFormation simply calls these APIs to create, delete, and update resources (all of which are described in terms of a resource type, a name, and a set of properties). When you tell CloudFormation to create your stack, the execution engine makes API calls to the AWS service APIs and supplies your resource properties as parameters to those calls. The translation layer between the stack and the API calls is the "resource provider."

Create or update New Relic One NRQL alerts from a CloudFormation stack

The newrelic-alerts-cloudformation experimental solution, published on New Relic Instant Observability and on GitHub in the newrelic-experimental repository, provides an AWS CloudFormation resource for creating or updating New Relic NRQL alerts from a CloudFormation stack. (Note: This project is provided as-is, without warranty of dedicated support. Report issues and contributions to the newrelic-alerts-cloudformation project on GitHub.)

To install, follow the installation instructions in the repository.