Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: One compute environment is expected, but AWS return no compute environment #12337

Closed
BeeShall opened this issue Mar 10, 2020 · 5 comments · Fixed by #13935
Closed

Error: One compute environment is expected, but AWS return no compute environment #12337

BeeShall opened this issue Mar 10, 2020 · 5 comments · Fixed by #13935
Assignees
Labels
bug Addresses a defect in current functionality. service/batch Issues and PRs that pertain to the batch service.
Milestone

Comments

@BeeShall
Copy link

BeeShall commented Mar 10, 2020

Cannot create an aws batch environment with the following script. Was working perfectly before I made some changes in the name of the environment.

resource "aws_batch_compute_environment" "metaflow_batch" {

  compute_environment_name = "${var.namespace}-metaflow-batch"

  compute_resources {
    instance_role = aws_iam_instance_profile.ecs_instance_role.arn

    instance_type = [
      var.instances.type
    ]

    max_vcpus     = var.instances.max_vcpus
    desired_vcpus = var.instances.desired_vcpus
    min_vcpus     = var.instances.min_vcpus

    security_group_ids = [aws_security_group.db_sg.id]

    subnets = var.vpc_config.subnets


    type = "EC2"
  }

  service_role = aws_iam_role.aws_batch_service_role.arn
  type         = "MANAGED"
  depends_on   = [aws_iam_role_policy_attachment.aws_batch_service_role]
}

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.12.21

  • provider.aws v2.52.0

Affected Resource(s)

AWS BATCH

  • aws_XXXXX

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

Debug Output

Panic Output

Error: One compute environment is expected, but AWS return no compute environment

Expected Behavior

Batch environment should have been created

Actual Behavior

Error: One compute environment is expected, but AWS return no compute environment

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000
@ghost ghost added the service/batch Issues and PRs that pertain to the batch service. label Mar 10, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 10, 2020
@hughesadam87
Copy link

hughesadam87 commented Jun 8, 2020

I've had the same error occur when I removed an AWS Batch compute env. manually and then tried to recreate/refresh it. Because of coupling between aws batch components such as job queues and compute environments, I first had to manually add another aws batch compute environment with the same name as the one manually deleted, then marked the env's with taint command, then was able to to terraform plan to recreate.

@bflad bflad added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Jun 25, 2020
@bflad bflad self-assigned this Jun 25, 2020
bflad added a commit that referenced this issue Jun 25, 2020
…m state when not found instead of returning error

Reference: https://github.com/terraform-providers/terraform-provider-aws/blob/master/docs/contributing/running-and-writing-acceptance-tests.md#disappears-acceptance-tests
Reference: #12337
Reference: #13826

Previously:

```
=== CONT  TestAccAWSBatchComputeEnvironment_disappears
    TestAccAWSBatchComputeEnvironment_disappears: testing.go:684: Step 0 error: errors during follow-up refresh:

        Error: One compute environment is expected, but AWS return no compute environment

    TestAccAWSBatchComputeEnvironment_disappears: testing.go:745: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: errors during refresh: One compute environment is expected, but AWS return no compute environment

        State: <nil>
--- FAIL: TestAccAWSBatchComputeEnvironment_disappears (59.70s)
```

Output from acceptance testing:

```
--- PASS: TestAccAWSBatchComputeEnvironment_createEc2WithoutComputeResources (35.53s)
--- PASS: TestAccAWSBatchComputeEnvironment_createSpotWithoutBidPercentage (35.72s)
--- PASS: TestAccAWSBatchComputeEnvironment_createWithNamePrefix (64.40s)
--- PASS: TestAccAWSBatchComputeEnvironment_createUnmanagedWithComputeResources (67.27s)
--- PASS: TestAccAWSBatchComputeEnvironment_createUnmanaged (67.28s)
--- PASS: TestAccAWSBatchComputeEnvironment_disappears (71.92s)
--- PASS: TestAccAWSBatchComputeEnvironment_launchTemplate (72.52s)
--- PASS: TestAccAWSBatchComputeEnvironment_createSpot (72.67s)
--- PASS: TestAccAWSBatchComputeEnvironment_createSpotWithAllocationStrategy (74.33s)
--- PASS: TestAccAWSBatchComputeEnvironment_createEc2 (80.45s)
--- PASS: TestAccAWSBatchComputeEnvironment_createEc2WithTags (81.01s)
--- PASS: TestAccAWSBatchComputeEnvironment_updateState (93.78s)
--- PASS: TestAccAWSBatchComputeEnvironment_updateInstanceType (105.25s)
--- PASS: TestAccAWSBatchComputeEnvironment_updateComputeEnvironmentName (114.21s)
--- PASS: TestAccAWSBatchComputeEnvironment_UpdateLaunchTemplate (114.41s)
--- PASS: TestAccAWSBatchComputeEnvironment_ComputeResources_MaxVcpus (135.46s)
--- PASS: TestAccAWSBatchComputeEnvironment_ComputeResources_DesiredVcpus_Computed (171.29s)
--- PASS: TestAccAWSBatchComputeEnvironment_ComputeResources_MinVcpus (216.35s)
```
@bflad
Copy link
Contributor

bflad commented Jun 25, 2020

Fix submitted: #13935

@bflad bflad added this to the v2.68.0 milestone Jun 25, 2020
bflad added a commit that referenced this issue Jun 25, 2020
…m state when not found instead of returning error (#13935)

Reference: https://github.com/terraform-providers/terraform-provider-aws/blob/master/docs/contributing/running-and-writing-acceptance-tests.md#disappears-acceptance-tests
Reference: #12337
Reference: #13826

Previously:

```
=== CONT  TestAccAWSBatchComputeEnvironment_disappears
    TestAccAWSBatchComputeEnvironment_disappears: testing.go:684: Step 0 error: errors during follow-up refresh:

        Error: One compute environment is expected, but AWS return no compute environment

    TestAccAWSBatchComputeEnvironment_disappears: testing.go:745: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: errors during refresh: One compute environment is expected, but AWS return no compute environment

        State: <nil>
--- FAIL: TestAccAWSBatchComputeEnvironment_disappears (59.70s)
```

Output from acceptance testing:

```
--- PASS: TestAccAWSBatchComputeEnvironment_createEc2WithoutComputeResources (35.53s)
--- PASS: TestAccAWSBatchComputeEnvironment_createSpotWithoutBidPercentage (35.72s)
--- PASS: TestAccAWSBatchComputeEnvironment_createWithNamePrefix (64.40s)
--- PASS: TestAccAWSBatchComputeEnvironment_createUnmanagedWithComputeResources (67.27s)
--- PASS: TestAccAWSBatchComputeEnvironment_createUnmanaged (67.28s)
--- PASS: TestAccAWSBatchComputeEnvironment_disappears (71.92s)
--- PASS: TestAccAWSBatchComputeEnvironment_launchTemplate (72.52s)
--- PASS: TestAccAWSBatchComputeEnvironment_createSpot (72.67s)
--- PASS: TestAccAWSBatchComputeEnvironment_createSpotWithAllocationStrategy (74.33s)
--- PASS: TestAccAWSBatchComputeEnvironment_createEc2 (80.45s)
--- PASS: TestAccAWSBatchComputeEnvironment_createEc2WithTags (81.01s)
--- PASS: TestAccAWSBatchComputeEnvironment_updateState (93.78s)
--- PASS: TestAccAWSBatchComputeEnvironment_updateInstanceType (105.25s)
--- PASS: TestAccAWSBatchComputeEnvironment_updateComputeEnvironmentName (114.21s)
--- PASS: TestAccAWSBatchComputeEnvironment_UpdateLaunchTemplate (114.41s)
--- PASS: TestAccAWSBatchComputeEnvironment_ComputeResources_MaxVcpus (135.46s)
--- PASS: TestAccAWSBatchComputeEnvironment_ComputeResources_DesiredVcpus_Computed (171.29s)
--- PASS: TestAccAWSBatchComputeEnvironment_ComputeResources_MinVcpus (216.35s)
```
@bflad
Copy link
Contributor

bflad commented Jun 25, 2020

The fix for this has been merged and will be released with version 2.68.0 of the Terraform AWS Provider, likely later today. 👍

@ghost
Copy link

ghost commented Jun 26, 2020

This has been released in version 2.68.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Jul 26, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Jul 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/batch Issues and PRs that pertain to the batch service.
Projects
None yet
3 participants