Skip to content

Latest commit

 

History

History
69 lines (49 loc) · 1.73 KB

README.md

File metadata and controls

69 lines (49 loc) · 1.73 KB

AWS Alarm notifier boilerplate

Terraform

Installation

# Terraform CLI
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
terraform init

# AWS CLI
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
rm AWSCLIV2.pkg

Setup

Add access key from your AWS account to ~/.aws/credentials:

[demo-profile]
aws_access_key_id=...
aws_secret_access_key=...

Update aws_key_pair resource to contain your public key:

resource "aws_key_pair" "demo_key" {
  key_name   = "demokey"
  public_key = "ssh-rsa your-public-key-here [email protected]"
}

Slack

Setup webhook

  • Create a new app for your slack workspace
  • Turn on the Incoming Webhooks feature
  • Add new webhook to workspace

Update aws_lambda_function with your webhook url and the channel you want to notify:

resource "aws_lambda_function" "alarm_notifier_lambda" {
  # ... omitted
  
  environment {
    variables = {
      slack_channel     = "#channel-name"
      slack_webhook_url = "your-webhook-url"
    }
  }
}

Lambda

Changing the function

You can change the lambda function in the deployment-package directory. To upload the new function you can run yarn zip within the deployment-package directory and run terraform apply afterwards.

Ready to run

Just run terraform plan to see what will get setup/changed and terraform apply to actually apply it.