Configuring the Slack Postprocessor¶
SLACK_WEBHOOK_URI: https://hooks.slack…..
- The webhook URI that will be used to push chat notifications into your Slack channel.
- You can create a new webook URI by signing into Slack from your web browser and then visiting the new webhook page.
SLACK_NOTIFY_USER_IMAGE_URI: http://www…..’
- The user icon that will appear in the Slack channel
SLACK_NOTIFY_USERNAME: PyTerraBackTYL
- The username that will appear in the Slack channel
SLACK_NOTIFICATIONS_ON_TF_ACTIONS: [OperationTypeApply, OperationTypePlan]
- The type of events the Slack channel should be notified for.
- Note that
terraform apply
andterraform destroy
both send PyTerrBackTYL the action type ofOperationTypeApply
- More than likely you will want to comment out
OperationTypePlan
notifications
SLACK_NOTIFY_HOST_LIST: true
- When set to true, and
HELPER_HOSTNAME_QUERY_MAP
has been correctly configured for the Terraform provider being used, the Slack channel will be updated with a list of newly created hosts.
- When set to true, and
SLACK_NOTIFY_UNLOCK: true
- When set to true, the Slack channel will be notified when a user has released their lock.
SLACK_NOTIFY_FORMAT: “_Who:_ *{Who}*\n_Operation:_ *{Operation}*\n_Version:_ {Version}\n_ID:_ {ID}”
- What details and formatting to use to update the Slack channel with.
- The use of double quotes (e.g. “double quotes”) is required for escape sequences like n (newline) to work.
- valid values (e.g. the
{Who}
in the above) are: - ID: An ID created by Terraform.
- Operation: The Terraform operation being carried out (plan, apply, etc.)
- Info: (check terraform documentation)
- Who: The username and hostname who initiated the terraform command.
- Version: The version of Terraform that was used.
- Created: Timestamp of when the terraform command ws run.
- Path: (check terraform documentation)
- valid values (e.g. the
SLACK_NOTIFY_UNLOCK_FORMAT: “_Who:_ *{Who}*\n_ID:_ {ID}”
- Similar to the previous configuration option, but only when the lock is released.
Full example configuration for SlackNotifyPostProcessor¶
POST_PROCESS_CLASSES:
- 'slack_notify_post_processor.SlackNotifyPostProcessor'
##
## slack_notify_post_processor.SlackNotifyPostProcessor configuration
##
# This should be the webhook for the 'random' room in the PyTerraBackTYL Slack.
SLACK_WEBHOOK_URI: https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZZZZZZZZZZZ
SLACK_NOTIFY_USER_IMAGE_URI: http://www.devdull.lol/pyterrabacktyl/pyterrabacktyl_logo_square.png
# Here's the terraform logo if you prefer: https://avatars0.githubusercontent.com/u/11051457?s=400&v=4
SLACK_NOTIFY_USERNAME: PyTerraBackTYL
# Which `terraform <command>` operations to notify Slack for.
SLACK_NOTIFICATIONS_ON_TF_ACTIONS:
- OperationTypeApply
- OperationTypePlan
SLACK_NOTIFY_HOST_LIST: true
SLACK_NOTIFY_UNLOCK: true
# The use of double quotes (e.g. "hello\nworld") is required for '\n' to be evaluated as a newline.
SLACK_NOTIFY_FORMAT: "_Who:_ *{Who}*\n_Operation:_ *{Operation}*\n_Version:_ {Version}\n_ID:_ {ID}"
SLACK_NOTIFY_UNLOCK_FORMAT: "_Who:_ *{Who}*\n_ID:_ {ID}"