# 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
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]"
}
- 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"
}
}
}
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.
Just run terraform plan
to see what will get setup/changed and terraform apply
to actually apply it.