Open jonasschoko opened 2 years ago
do a refresh and check the desired state and current state .
if not you can use ignore _changes and try.
refresh sadly didn't solve the issue. As well as it won't show anything about desired state or the current state. It just says: _awsbudgets.budget.name: Refreshing state... [id=id.name]
I didn't try the ignore_changes because of my lack of knowledge. Is it possible to do this with cdktf as well because I am using this instead of terraform.
Hey @jonasschoko 👋 Thank you for taking the time to raise this! So that we have all of the necessary information in order to look into this, can you update the issue description to include all of the information requested in the bug report template?
Hey, I have edited the issue description. If there is any more needed please just let me know and I will try to add it. Thanks in advance :)
This is still an issue with terraform-aws-provider 5.15.0.
Here's another way to reproduce the issue that doesn't need cdktf:
cat >main.tf <<EOF
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
region = "eu-central-1"
}
resource "aws_budgets_budget" "test" {
name = "test-terraform-aws-provider-bug-26547"
budget_type = "COST"
limit_amount = 99
limit_unit = "USD"
time_unit = "MONTHLY"
notification {
comparison_operator = "GREATER_THAN"
threshold = 50
threshold_type = "PERCENTAGE"
notification_type = "ACTUAL"
subscriber_email_addresses = ["user@example.com"]
}
}
EOF
terraform init
terraform apply
ACCOUNT=$(aws sts get-caller-identity | jq -r .Account)
aws budgets delete-notification --account-id ${ACCOUNT} --budget-name test-terraform-aws-provider-bug-26547 --notification NotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=50.0
# this should detect that the notification was deleted and try to create it again, but it doesn't detect any changes
terraform apply
Furthermore, if the notification is deleted and a change is made to the Terraform script, Terraform will then try to delete the existing (deleted!) notification before recreating it. This will lead to the following error:
│ Error: updating Budget (:test-terraform-aws-provider-bug-26547) notifications: deleting Budget (:test-terraform-aws-provider-bug-26547) notification: NotFoundException: Unable to delete notification: { notificationType: ACTUAL, comparisionOperator: GREATER_THAN, threshold: 50.0 } for budget: test-terraform-aws-provider-bug-26547 - it doesn't exist.
To fix this issue, the provider must send a budgets:DescribeNotificationsForBudget
API call in addition to budgets:DescribeBudget
and compare the output with all configured notifications in the state and/or the script.
Interestingly, there already seems to be some plumbing for this in the code, but it doesn't work correctly: https://github.com/hashicorp/terraform-provider-aws/blob/main/internal/service/budgets/budget.go#L557
Community Note
Description
When the budget alert that has been created with terraform will be deleted manually in the aws console, terraform won't create a new one with
terraform refresh
Terraform CLI and Terraform AWS Provider Version
Terraform v1.2.8 on linux_amd64 +provider registry.terraform.io/hashicorp/aws v4.28.0
Affected Resource(s)
Terraform Configuration Files
CDK for Terraform
main.py:
Expected Behavior
Create budget alert after manual deletion of it in the aws console.
Actual Behavior
Terraform does not recognize any changes and does not recreate the deleted budget alert.
Steps to Reproduce
cdktf synth
terraform apply
go to budgets in aws console and click the budget that was created by terraform
press Alerts and delete it by hand
terraform refresh
Important Factoids
No