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

[Bug]: Empty "assume_role.role_arn" results in provider error and fails to plan/apply #39296

Closed
evan-cleary opened this issue Sep 13, 2024 · 9 comments · Fixed by #39328
Closed
Assignees
Labels
authentication Pertains to authentication; to the provider itself of otherwise. bug Addresses a defect in current functionality. provider Pertains to the provider itself, rather than any interaction with AWS. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement.
Milestone

Comments

@evan-cleary
Copy link
Contributor

evan-cleary commented Sep 13, 2024

Terraform Core Version

1.4.7

AWS Provider Version

5.67.0

Affected Resource(s)

  • all

Expected Behavior

Provider previously ignored assume role blocks when role_arn was left as empty string "" or null.

We depend on this as we optionally configure assume_role in our terraform using configurations like:

  assume_role {
    role_arn = var.assume_role
    ...
  }

and

assume_role {
   role_arn = var.assume_role
   duration = "15m"
}

Actual Behavior

Provider now fails to plan/apply saying the role_arn is required.

Relevant Error/Panic Output Snippet

Error: Missing required argument 
  with provider["registry.terraform.io/hashicorp/aws"], 
  on main.tf line 11, in provider "aws": 
  11: provider "aws" { 
The argument "role_arn" is required, but no definition was found.

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      version = "5.67.0"
      source = "hashicorp/aws"
    }
  }
}

provider "aws" {
  region = "us-east-1"
  assume_role {
    role_arn = ""
  }
}

data "aws_region" "current" {}
terraform {
  required_providers {
    aws = {
      version = "5.67.0"
      source = "hashicorp/aws"
    }
  }
}

provider "aws" {
  region = "us-east-1"
  assume_role {
    role_arn = null
    duration = "15m"
  }
}

data "aws_region" "current" {}

Steps to Reproduce

  1. Run the above configuration(s)

Debug Output

No response

Panic Output

No response

Important Factoids

The majority of our terraform configurations support conditionally using an assume_role to support our local development and the CI pipelines, this change has broken conditional assume roles for any configuration set up prior to the introduction of dynamics.

References

This appears to be the result of: #39255

Comments within the schema change show intentional of backwards compatibility with empty assume_role.role_arn attributes
https://github.com/hashicorp/terraform-provider-aws/pull/39255/files#diff-cddd9e71748414f0ca51a47f3c35f8c45522d41c9477d3cfae3374dd656610f1R192

But then in implementation requirement of that property is enforced
https://github.com/hashicorp/terraform-provider-aws/pull/39255/files#diff-58d6a027753b50994deb7e11e4a99dde423f35844986019bd9cea5e0c94aba22R793-R798

Would you like to implement a fix?

None

@evan-cleary evan-cleary added the bug Addresses a defect in current functionality. label Sep 13, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 13, 2024
@macetw
Copy link

macetw commented Sep 13, 2024

This issue was well documented by @evan-cleary. My team has experienced the same problem.

philippthun added a commit to sap-contributions/bosh-bootloader that referenced this issue Sep 13, 2024
Fix/workaround for error 'The argument "role_arn" is required, but no
definition was found.' (terraform-provider-aws v5.67.0).

See also issue hashicorp/terraform-provider-aws#39296.
@ewbankkit ewbankkit added regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. provider Pertains to the provider itself, rather than any interaction with AWS. authentication Pertains to authentication; to the provider itself of otherwise. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 13, 2024
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Sep 13, 2024
@gdavison gdavison self-assigned this Sep 13, 2024
@quentin9696
Copy link

Hi,

To have a cleaner TF syntax, this works with 5.67.0

dynamic "assume_role" {
    for_each = var.aws_assume_role != null ? [1] : []

    content {
      role_arn = var.aws_assume_role
    }
  }

@gdavison
Copy link
Contributor

This will be resolved by #39328. We're planning to release a bug fix update this Monday, 16 September.

In addition to the workarounds listed above, you can also set the value of var.aws_assume_role to null instead of "". For example:

variable "var.aws_assume_role" {
  type    = string
  default = null
}

@iNoahNothing
Copy link
Contributor

I am getting the same error even with with following config that defaults role_arn to null

provider "aws" {
  profile                  = var.aws_profile
  region                   = var.region
  shared_credentials_files = [pathexpand(var.shared_credentials_file)]

  assume_role {
    role_arn = var.role_arn

    # Inherit session tags from the configure-aws-credentials action
    transitive_tag_keys = [
      "GitHub",
      "Repository",
      "Workflow",
      "Action",
      "Actor",
      "Branch",
      "Commit"
    ]
  }

  default_tags {
    tags = local.tags
  }
}

variable "aws_profile" {
  type    = string
  default = null
}
variable "role_arn" {
  type    = string
  default = null
}
variable "shared_credentials_file" {
  type    = string
  default = "~/.aws/credentials"
}
variable "vault_address" {
  default = null
}

Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.68.0 milestone Sep 16, 2024
@selzoc
Copy link

selzoc commented Sep 17, 2024

This will be resolved by #39328. We're planning to release a bug fix update this Monday, 16 September.

Is this bug fix release still planned?

@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Sep 20, 2024
Copy link

This functionality has been released in v5.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. Thank you!

Copy link

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 Oct 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
authentication Pertains to authentication; to the provider itself of otherwise. bug Addresses a defect in current functionality. provider Pertains to the provider itself, rather than any interaction with AWS. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants