fix: require deterministic values for the for loop from var.account_assignments #53
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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 thefor_each
loop on thelocal.assignment_map
inresource.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 ofa.account
(account_id
) will resolve this issue.references