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

fix: require deterministic values for the for loop from var.account_assignments #53

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

wquan1
Copy link

@wquan1 wquan1 commented Jan 20, 2024

what

Major fix:
Make local.assignment_map to be compiled from account_name instead of account id.

Minor fix:
Upgrade terraform local provider in examples to the latest version to make it working for Apple M1 chip platform.

why

The error:

Error: Invalid for_each argument
on .terraform/modules/sso_account_assignments/modules/account-assignments/main.tf line 29, in resource "aws_ssoadmin_account_assignment" "this":
  for_each = local.assignment_map
local.assignment_map will be known only after apply

In my use case, I am creating the AWS account within the same workspace of the SSO assignments. So, the input var.account_assignments[*].account(which is the account id) is not known until the resource is getting created. Thus, the local.assignment_map cannot be determined at terraform compiling stage, and the for_each loop on the local.assignment_map in resource.aws_ssoadmin_account_assignment.this can not be determined either.

However, the account name is something people can predefine before the aws account is created. So include the account name in the input var.account_assignments, and use the a.account_name which is deterministic, instead of a.account(account_id) will resolve this issue.

references

@wquan1 wquan1 requested review from a team as code owners January 20, 2024 17:58
@wquan1 wquan1 requested review from jamengual and woz5999 January 20, 2024 17:58
…e m1 chip

with the latest terraform provider local, terraform init works fine and
the terraform validate is success on the examples
@hans-d hans-d added stale This PR has gone stale wip Work in Progress: Not ready for final review or merge and removed wip Work in Progress: Not ready for final review or merge labels Mar 8, 2024
@hans-d hans-d requested review from Gowiem and removed request for woz5999 March 8, 2024 12:02
@Gowiem
Copy link
Member

Gowiem commented Mar 8, 2024

This sounds like a legitimate problem from the description. Before we make this breaking change to address this though... I wonder how Cloud Posse works around this. @osterman anyone on your team that should look at this?

Copy link

mergify bot commented Mar 10, 2024

Thanks @wquan1 for creating this pull request!

A maintainer will review your changes shortly. Please don't be discouraged if it takes a while.

While you wait, make sure to review our contributor guidelines.

Tip

Need help or want to ask for a PR review to be expedited?

Join us on Slack in the #pr-reviews channel.

@mergify mergify bot added triage Needs triage and removed stale This PR has gone stale labels Mar 15, 2024
@Nuru
Copy link
Contributor

Nuru commented Nov 12, 2024

Sorry, @wquan1 (and @Gowiem), creating the AWS account at the same time as making SSO assignments is not something I want to support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants