hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.75k stars 9.1k forks source link

Terraform Elastic Beanstalk Application: Provider produced inconsistent result after apply #21012

Closed bolanlesd closed 10 months ago

bolanlesd commented 2 years ago

I get this error when i try to use the resource "aws_elastic_beanstalk_application"

│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to aws_elastic_beanstalk_application.default,
│ provider "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an
│ unexpected new value: Root resource was present, but now absent.
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵

Can I get help with this please?

To Reproduce:

resource "aws_elastic_beanstalk_application" "tftest" {
  name        = "tf-test-name"
  description = "tf-test-desc"

  appversion_lifecycle {
    service_role          = aws_iam_role.beanstalk_service.arn
    max_count             = 128
    delete_source_from_s3 = true
  }
}
anGie44 commented 2 years ago

Hi @bolanlesd , thank you for raising this issue. To further investigate, do you mind providing more details regarding which provider version you are working with, as well as the complete configuration?

bolanlesd commented 2 years ago

Hello @anGie44 , thank you for your response:

registry.terraform.io/hashicorp/aws, i used v3.57.0 and v3.59.0

As for the complete configuration, let me break it down, perhaps this is what you mean? (But i only have just that one resource)

main.tf:

resource "aws_elastic_beanstalk_application" "default" { name = "test1" description = "tf-test-desc"

appversion_lifecycle { service_role = "arn:aws:iam::XXXXXXXX:role/aws-elasticbeanstalk-service-role" max_count = 128 delete_source_from_s3 = true } }

I am using Terragrunt configuration on my terraform.

If this info is not what you need, please let me know. Or do you want me to attach the TF_LOG file during my apply?

bolanlesd commented 2 years ago

Hello,

Is there any update that can help with this issue please? I have not been able to resolve it yet.

Also please see attached a TF_Log file. I hope it helps.

Regards log-for-review.txt

anGie44 commented 2 years ago

Hi @bolanlesd , no updates from me atm :/ I'm not able to reproduce this on my end but I do see the error in the text file attached in your previous comment; terraform successfully creates the resource but when it goes to find the application via an API request DescribeApplications to the AWS service it's not found for some reason. Are you able to share the IAM service role configuration as well?

bolanlesd commented 2 years ago

Thanks for the prompt response @anGie44 ! Please see the JSON policies attached to the service role used for the deployment.

AWSElasticBeanstalkEnhancedHealth.txt AWSElasticBeanstalkManagedUpdatesCustomerRolePolicy.txt

vrajendra commented 2 years ago

I can reproduce the error, this happens when apply however plan is successfull.

aws_elastic_beanstalk_application.default: Creating... aws_elastic_beanstalk_application.default: Still creating... [10s elapsed] aws_elastic_beanstalk_application.default: Still creating... [20s elapsed] aws_elastic_beanstalk_application.default: Still creating... [30s elapsed] ╷ │ Error: Provider produced inconsistent result after apply │ │ When applying changes to aws_elastic_beanstalk_application.default, │ provider "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an │ unexpected new value: Root resource was present, but now absent. │ │ This is a bug in the provider, which should be reported in the provider's │ own issue tracker. ╵ Releasing state lock. This may take a few moments... ERRO[0043] Hit multiple errors: Hit multiple errors: exit status 1

vrajendra commented 2 years ago

Hi @anGie44 I have further checked the aws console and the application still gets creating while the terraform errors out. it creates after some time. So what I have found is the provider is exiting in 30 secs while the application is still creating . can this be resolved by putting a loop in the code till the application gets created. I found a similar issue and fix here

HariSankaranarayanan commented 2 years ago

Hi All, Even I am facing the exact issue as @bolanlesd , I can see for similar issues in other AWS services, for which there was a bug-fix released in upcoming release. Is there any plan or resolution for this issue?

github-actions[bot] commented 12 months ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

github-actions[bot] commented 9 months ago

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.