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

service_role is required in aws_batch_compute_environment but optional in AWS.Batch.CreateComputeEnvironment #19178

Closed
alex-bolenok-centralreach opened this issue Apr 30, 2021 · 5 comments · Fixed by #19205
Assignees
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/batch Issues and PRs that pertain to the batch service.
Milestone

Comments

@alex-bolenok-centralreach
Copy link

alex-bolenok-centralreach commented Apr 30, 2021

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 CLI and Terraform AWS Provider Version

Terraform v0.15.0
on windows_amd64
+ provider registry.terraform.io/hashicorp/aws v3.38.0

Affected Resource(s)

  • aws_batch_compute_environment

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "aws_batch_compute_environment" "environment_bug_test" {
  compute_environment_name = "environment-bug-test"

  compute_resources {
    type               = "FARGATE"
    min_vcpus          = 0
    max_vcpus          = 1
    subnets            = var.subnets
    security_group_ids = var.security_group_ids
  }

  # service_role = ""
  # ^^ should be optional
  type = "MANAGED"
}

Debug Output

Panic Output

Expected Behavior

Environment created with the default service role:

https://docs.aws.amazon.com/batch/latest/APIReference/API_CreateComputeEnvironment.html#Batch-CreateComputeEnvironment-request-serviceRole

The full Amazon Resource Name (ARN) of the IAM role that allows AWS Batch to make calls to other AWS services on your behalf. For more information, see AWS Batch service IAM role in the AWS Batch User Guide.

Important
If your account has already created the AWS Batch service-linked role, that role is used by default for your compute environment unless you specify a role here. If the AWS Batch service-linked role does not exist in your account, and no role is specified here, the service will try to create the AWS Batch service-linked role in your account.

If your specified role has a path other than /, then you must specify either the full role ARN (recommended) or prefix the role name with the path. For example, if a role with the name bar has a path of /foo/ then you would specify /foo/bar as the role name. For more information, see Friendly names and paths in the IAM User Guide.

Note
Depending on how you created your AWS Batch service role, its ARN might contain the service-role path prefix. When you only specify the name of the service role, AWS Batch assumes that your ARN doesn't use the service-role path prefix. Because of this, we recommend that you specify the full ARN of your service role when you create compute environments.

Type: String

Required: No

Actual Behavior

╷
│ Error: Missing required argument
│
│   on batch.tf line 1, in resource "aws_batch_compute_environment" "environment_bug_test":
│    1: resource "aws_batch_compute_environment" "environment_bug_test" {
│
│ The argument "service_role" is required, but no definition was found.
╵

Steps to Reproduce

  1. terraform apply

Important Factoids

References

Relates: #16819.

@ghost ghost added the service/batch Issues and PRs that pertain to the batch service. label Apr 30, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Apr 30, 2021
@ewbankkit
Copy link
Contributor

@alex-bolenok-centralreach Thanks for raising this issue.
Is this breaking an existing Terraform configuration?

@ewbankkit ewbankkit added waiting-response Maintainers are waiting on response from community or contributor. and removed needs-triage Waiting for first response or review from a maintainer. labels Apr 30, 2021
@alex-bolenok-centralreach
Copy link
Author

alex-bolenok-centralreach commented Apr 30, 2021 via email

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Apr 30, 2021
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. labels Apr 30, 2021
@ewbankkit
Copy link
Contributor

ewbankkit commented Apr 30, 2021

For UNMANAGED batch compute environments:

error creating Batch Compute Environment (testing001): : Error executing request, Exception : ServiceRole must be provided.

Also for MANAGED batch compute environments:

A CE using Batch Service Linked Role cannot be updated to use a user-provided role.

and

A CE using a user-provided role cannot be updated to use Batch Service Linked Role.

@ghost
Copy link

ghost commented May 7, 2021

This has been released in version 3.39.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!

@github-actions
Copy link

github-actions bot commented Jun 6, 2021

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 6, 2021
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. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/batch Issues and PRs that pertain to the batch service.
Projects
None yet
2 participants