Comments (16)
I ran into this issue and found a permanent solution that doesn't require modifying the module.
The issue is as @stephgosling describes. The module's path is hard coded into the state. This is a problem because in the TF registry, each version of the module has a unique sha affixed path. So any time the module version changes, it will break. The only way to fix it, is to manually terraform taint
the lambda function resource. Again, you must do this every time the module changes.
However, this problem is caused exclusively by using the module via the terraform registry. Using any other module source (e.g. github) does not have this issue because the module path will not differ version to version, just the actual content (which is the only thing that matters)
So to fix this issue permanently:
- Change module source from terraform registry to github (e.g.
source = "github.com/terraform-aws-modules/terraform-aws-notify-slack.git?ref=v2.4.0"
) - Manually taint the resource e.g.
terraform taint "<nested-resource-path>.module.notify_slack.aws_lambda_function.notify_slack[0]"
- Run terraform plan/apply
Now if you change module version, it will update properly without manual intervention
from terraform-aws-notify-slack.
In my opinion updating a module should never lead to a problem with a previously made state, this zipfile is the first i've seen that happen.
from terraform-aws-notify-slack.
For folks running separate plan/applies in ephemeral CI/CD and not passing the .terraform directory between the two, this appears to be the cause of the issue.
from terraform-aws-notify-slack.
I see, sometimes when you have to deal with existing (often corrupted) information in state file you can try these workarounds (starting from the easiest at the top):
- Append
-refresh=false
to prevent it from updating the state before planning changes. - Append
-target=module.databases.module.rds_notify_slack.module.notify_slack.aws_lambda_function.notify_slack
to limit the scope of changes you want to plan and apply. - Use terraform taint within a module.
- If you don't mind doing surgery on json file (which is often not needed), you can use
terraform state pull
, do changes,terraform state push
. This is the most advanced way, so I put it at the end.
Let's see what @cgomestw thinks.
from terraform-aws-notify-slack.
I just ran into the same issue, fixed by removing this line:
https://github.com/terraform-aws-modules/terraform-aws-notify-slack/blob/master/main.tf#L80
FYI line 80 in main.tf is a moving target, I think you were referring to this specific version:
terraform-aws-notify-slack/main.tf
Line 80 in 1d2381a
Removing filename
from the lifecycle looks like this:
lifecycle {
ignore_changes = [
"last_modified",
]
}
And for what its worth that solved this problem for me as well. However it was added to address: #6
from terraform-aws-notify-slack.
@cgomestw had you just upgraded/re-get
'd the module? I've just seen the same behaviour as you and it's because my state had an hard-coded path to that zip file that no longer matched the hash for the module. If you edit your state file to use the correct hash you can then successfully apply
the module.
There does appear to be a breaking change in there at some point in the past. My local module here (written on the 28th of April 2018) was referencing this version in the state:
b3572a382f5c288bd459b66424b0ae78/terraform-aws-modules-terraform-aws-notify-slack-5cdd039/
which corresponds to this commit or version 1.1.0 of the module from what I can see.
from terraform-aws-notify-slack.
@antonbabenko this is biting us also, any chance it can be fixed?
from terraform-aws-notify-slack.
from terraform-aws-notify-slack.
@walterheck I'd like to help, but I don't know how. Example code works, I've just run https://github.com/terraform-aws-modules/terraform-aws-notify-slack/tree/master/examples/notify-slack-simple and it works as expected.
Can you try the low-level fix and see whether it helps - rm -rf .terraform && terraform init
?
@cgomestw If you can investigate and fix the problem it would very nice.
from terraform-aws-notify-slack.
@antonbabenko it has something to do with first having an older version fo the module, running terraform apply to write it to state, then updating the module and seeing the error.
rm -rf .terraform doesn't work as the statefile has an entry that mentions a path for the zip file, but once you upgrade the module the path in the statefile goes to the old directory and that doesn't exist anymore.
I got around it with a slightly different fix then @stephgosling: I created the old directory it was looking for manually and copied the slack_notify.zip file there. Pretty nasty, but it saved me from having to edit a remote terraform state file for a prod environment. Hope this gives more insight?
from terraform-aws-notify-slack.
We are having the same issue. But it doesn't always happen on every apply. Sometimes it works, sometimes it doesn't. We almost never change the code that calls or uses the module so it's not like there's a change that causes the issue.And we do have other terraformed lambda functions that don't cause this issue.
Just in case it was an issue with the way the file gets called, I re-wrote that part but without any success
resource "aws_lambda_function" "notify_slack" {
count = "${var.create}"
filename = "functions/notify_slack.zip"
function_name = "${var.lambda_function_name}"
role = "${aws_iam_role.lambda.arn}"
handler = "notify_slack.lambda_handler"
source_code_hash = "${base64sha256(file("${path.module}/functions/notify_slack.zip"))}"
from terraform-aws-notify-slack.
I just ran into the same issue, fixed by removing this line:
https://github.com/terraform-aws-modules/terraform-aws-notify-slack/blob/master/main.tf#L80
from terraform-aws-notify-slack.
I just ran into the same issue, fixed by removing this line:
https://github.com/terraform-aws-modules/terraform-aws-notify-slack/blob/master/main.tf#L80
Confirmed, thanks!
from terraform-aws-notify-slack.
Also affected by this issue all the time. Been using this module since years, always the same problem. Frustrating.
from terraform-aws-notify-slack.
Please give a try v3.0.0 which has been just released. There I use a new dedicated Lambda module, which has a lot of improvements when working with Lambda resources.
Closing this issue. Please open a new one if you find any issues with v3.0+
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 2
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.