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]: hashicorp/aws version 5.67.0 breaks compatibility with role_arn for dynamic naming of AWS accounts #39331

Closed
domijana opened this issue Sep 14, 2024 · 5 comments · Fixed by #39328
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

@domijana
Copy link

domijana commented Sep 14, 2024

Terraform Core Version

1.9.5

AWS Provider Version

5.67.0

Affected Resource(s)

Use case - I am trying to create an AWS commercial account using credentials from the management account of an AWS Organization. Once that account is created, I want to assume a role and create a VPC in this new commercial account. My secret/access keys are saved in my credentials file under the profile of commercial.

Expected Behavior

Terraform plan should show the following

Plan: 3 to add, 0 to change, 0 to destroy.

Changes to Outputs:

new_account_id = (known after apply)

Actual Behavior

│ Error: Missing required argument

│ with provider["registry.terraform.io/hashicorp/aws"].new_account,
│ on provider.tf line 7, in provider "aws":
│ 7: provider "aws" {

│ The argument "role_arn" is required, but no definition was found.

Relevant Error/Panic Output Snippet

https://gist.github.com/domijana/8220eb9a1040d2d03a57279764f601c3

Terraform Configuration Files

The below code does NOT work as is.

provider.tf

provider "aws" {
  alias  = "management"
  region = "us-east-1"
  profile = "commercial"
}

provider "aws" {
  alias = "new_account"
  region = "us-east-1"
  profile = "commercial"
  assume_role {
    role_arn = "arn:aws:iam::${aws_organizations_account.new_account.id}:role/OrganizationAccountAccessRole"
  }
}

account.tf

# Create a new AWS account
resource "aws_organizations_account" "new_account" {
  provider  = aws.management
  email     = "[email protected]"
  name      = "NewCommercialAccount"
  role_name = "OrganizationAccountAccessRole"
}

# Output the new account ID
output "new_account_id" {
  value = aws_organizations_account.new_account.id
}

vpc.tf

resource "aws_vpc" "my_vpc" {
  provider   = aws.new_account
  cidr_block = "10.0.0.0/16"

  tags = {
    Name = "MyVPC"
  }
}

resource "aws_subnet" "my_subnet" {
  provider   = aws.new_account
  vpc_id     = aws_vpc.my_vpc.id
  cidr_block = "10.0.1.0/24"

  tags = {
    Name = "MySubnet"
  }
}

Steps to Reproduce

terraform init
terraform plan

Debug Output

https://gist.github.com/domijana/8220eb9a1040d2d03a57279764f601c3

Panic Output

No response

Important Factoids

In order to fix this issue, I specified version 5.66.0 in my provider file. I then deleted the terraform and terraform.lock.hcl files. Then I did terraform init, terraform plan, and it works.

Below code was added to the provider.tf file to fix it.

terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.66.0" # Specify the desired AWS provider version
}
}
}

References

No response

Would you like to implement a fix?

None

@domijana domijana added the bug Addresses a defect in current functionality. label Sep 14, 2024
@github-actions github-actions bot added service/organizations Issues and PRs that pertain to the organizations service. service/vpc Issues and PRs that pertain to the vpc service. labels Sep 14, 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 14, 2024
@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 service/organizations Issues and PRs that pertain to the organizations service. needs-triage Waiting for first response or review from a maintainer. service/vpc Issues and PRs that pertain to the vpc service. labels Sep 16, 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 16, 2024
@ewbankkit
Copy link
Contributor

Relates #39306.
Relates #39296.

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
@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.

2 participants