Comments (6)
Hi @invertigo !
This sounds like a bug but I don't understand why it happens.
Please show the code you use and log output during "terraform apply".
from terraform-aws-notify-slack.
Pretty basic usage.
data "aws_kms_ciphertext" "slack_url" {
plaintext = var.slack_webhook_url
key_id = aws_kms_key.stack_key.arn
}
module "slack_error_notifications" {
source = "terraform-aws-modules/notify-slack/aws"
version = "4.9.0"
create = var.slack_alarms
sns_topic_name = "${var.environment}-slack-alerts"
lambda_function_name = "${var.environment}-slack-alerts"
slack_webhook_url = data.aws_kms_ciphertext.slack_url.ciphertext_blob
slack_channel = var.slack_alert_channel
slack_username = "${var.environment}-alerts"
slack_emoji = var.slack_alert_emoji
kms_key_arn = aws_kms_key.stack_key.arn
create_with_kms_key = true
}
And then here's the terraform plan
output after the entire stack has been provisioned and nothing should be changing:
# module.mds.module.slack_error_notifications.module.lambda.aws_lambda_function.this[0] will be updated in-place
~ resource "aws_lambda_function" "this" {
arn = "arn:aws:lambda:us-west-2:12345678910:function:company-staging-slack-alerts"
filename = "builds/8cdc8be7573f183a30e8af9ce59d511795c17dd9fd51299e8d9e827e1f3de602.zip"
function_name = "company-staging-slack-alerts"
handler = "notify_slack.lambda_handler"
id = "company-staging-slack-alerts"
invoke_arn = "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:12345678910:function:company-staging-slack-alerts/invocations"
kms_key_arn = "arn:aws:kms:us-west-2:12345678910:key/a92cfa9e-712d-11eb-877b-83c2d3fe191b"
last_modified = "2021-02-17T01:04:08.564+0000"
layers = []
memory_size = 128
package_type = "Zip"
publish = true
~ qualified_arn = "arn:aws:lambda:us-west-2:12345678910:function:company-staging-slack-alerts:5" -> (known after apply)
reserved_concurrent_executions = -1
role = "arn:aws:iam::12345678910:role/lambda-company-staging-slack-alerts"
runtime = "python3.8"
source_code_hash = "SP923Y4gOpr1DQN9oV+jXPLvNr+SRbqD7IvhrwhdzwI="
source_code_size = 1570
tags = {}
timeout = 30
~ version = "5" -> (known after apply)
~ environment {
~ variables = {
"LOG_EVENTS" = "False"
"SLACK_CHANNEL" = "#alerts-nonprod"
"SLACK_EMOJI" = ":aws:"
"SLACK_USERNAME" = "company-staging-alerts"
~ "SLACK_WEBHOOK_URL" = "AQICAHhOH5OVERWRITINGZPARTSjOFETHISUctGu5Soj01/T4QEJ8aZOt6F15U9k8YXx9tfPAAAArzCBrAYJKoZIhvcNAQcGoIGeMIGbAgEAMIGVBgkqTOiRUINBTHEwBASE64ZIAWUDBAEuMBEEDL6mWZ/vpr6R1+H1oQIBEIBoWE5JSFQY6hvL+YsdmYrHdjBVTS3MOhh6Y4/8SEvpf35HeJa34xFfW1P0jOgG8D3UnGkUhAWHB8oqjKL0xTzVXmunbF4xPu/mtsTMcENLcxdzKa0wASsluOoG7KVVjT1O0u8BpRM3xLw=" -> "AQICAHhOH5sCMPQRzK2NOVERWRITINGZBITScHERESTOO1/T4QEwqTyEShWEoyqYRnIGplCDAAAArzCBrAYJKoZIhvcNAQcGoIGeMIGbAgEAMIGVBgkqhkiG9w0BBwEwHgYJYIZIASODBYOUMCANTJDECODEnnC5dc5ragIBEIBoVMsaDMUGk9XgFUxN8gxfIyc/JU2YlAvZvas1Pd1+ChELGmgcu/SSlJETcgyqXWs1519w1fGOjD/8jp5braxDa8bqjfVuLovzsvFWSLCniVRsxHw89IZIOT3d8SMUXNpqYO0Ce/1HvJM="
}
}
tracing_config {
mode = "PassThrough"
}
}
# module.mds.module.slack_error_notifications.module.lambda.aws_lambda_permission.current_version_triggers["AllowExecutionFromSNS"] must be replaced
-/+ resource "aws_lambda_permission" "current_version_triggers" {
action = "lambda:InvokeFunction"
function_name = "company-staging-slack-alerts"
~ id = "AllowExecutionFromSNS" -> (known after apply)
principal = "sns.amazonaws.com"
~ qualifier = "5" -> (known after apply) # forces replacement
source_arn = "arn:aws:sns:us-west-2:12345678910:company-staging-slack-alerts"
statement_id = "AllowExecutionFromSNS"
}
Plan: 1 to add, 2 to change, 1 to destroy.
The KMS-encrypted SLACK_WEBHOOK_URL changes every time I run terraform, forcing some new resources. I dunno how difficult it would be to get a lifecycle hook to ignore changes for that, but it would be welcome.
from terraform-aws-notify-slack.
So not quite a bug, since TF is acting properly given the environment variable changes on every run. I wonder if it's possible to tell TF not to regenerate the slack_url
ciphertext on every run.
from terraform-aws-notify-slack.
Aha: "The KMS ciphertext data source allows you to encrypt plaintext into ciphertext by using an AWS KMS customer master key. The value returned by this data source changes every apply. For a stable ciphertext value, see the aws_kms_ciphertext resource."
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/kms_ciphertext
from terraform-aws-notify-slack.
Exactly :)
Here is an example for this - https://github.com/terraform-aws-modules/terraform-aws-notify-slack/blob/master/examples/cloudwatch-alerts-to-slack/main.tf#L11-L14
from terraform-aws-notify-slack.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
from terraform-aws-notify-slack.
Related Issues (20)
- Noisy output HOT 4
- event to slack using event subscription HOT 1
- Noisy output HOT 4
- Support @here in Slack Notifications HOT 6
- lambda-runtime configurable HOT 3
- Make lambda logging level configurable HOT 3
- The link to the CloudWatch alarm is no longer valid. HOT 10
- SNS Feedback role is broken HOT 7
- Messages to slack are not delivered HOT 2
- Add formatting for Security Hub findings HOT 3
- Have a more descriptive Slack CloudTrail notification format HOT 3
- Apply fails when multiple module calls are used HOT 2
- Provider produced inconsistent final plan in CI/CD environment HOT 4
- AWS Lambda runtime python3.8 deprecation HOT 10
- SNS Feedback role is broken HOT 4
- Add formatter for Security Hub Findings HOT 4
- Add variable for Lambda Architecture to support ARM HOT 1
- Add formatter for Amazon Managed Prometheus alerts HOT 4
- Expected runtime expects Python 3.9 but locally using 3.11 HOT 1
- Lambda function isn't attaching to the specified VPC HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-aws-notify-slack.