You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Terraform and aws_organizations_account to create new AWS accounts in my organization, and then want to create groups and permissionsets using this module, associating them with the accounts to be created, in a signle terraform apply run.
However, this does not currently work, because the IDs of the accounts are not known until the apply has been performed, so terraform can not create the aws_ssoadmin_account_assignmenthere as for_each does not work with sets that contain values that are unknown in the plan phase (Error: The "for_each" set includes values derived from resource attributes that cannot be determined until apply, and so Terraform cannot determine the full set of keys that will identify the instances of this resource.)
A solution is to instead of a list of accounts, have a map from e.g. account name (which is known at apply time) to account id (which is not know), and use the account name, rather than the id as the resource key when creating the account associations,
A workaround is to not pass any accounts to the module, and create the aws_ssoadmin_account_assignments myself in this manner outside the module. However, it would be nice to have support for this in the module itself.
One solution might be to e.g. add an accounts_map input to the module, and use the keys and values from there if it is defined, instead of the accounts input. This would keep the module backwards compatible. We would then have something like
I'm using Terraform and aws_organizations_account to create new AWS accounts in my organization, and then want to create groups and permissionsets using this module, associating them with the accounts to be created, in a signle
terraform apply
run.However, this does not currently work, because the IDs of the accounts are not known until the apply has been performed, so terraform can not create the
aws_ssoadmin_account_assignment
here asfor_each
does not work with sets that contain values that are unknown in the plan phase (Error:The "for_each" set includes values derived from resource attributes that cannot be determined until apply, and so Terraform cannot determine the full set of keys that will identify the instances of this resource.
)A solution is to instead of a list of accounts, have a map from e.g. account name (which is known at apply time) to account id (which is not know), and use the account name, rather than the id as the resource key when creating the account associations,
A workaround is to not pass any accounts to the module, and create the
aws_ssoadmin_account_assignment
s myself in this manner outside the module. However, it would be nice to have support for this in the module itself.One solution might be to e.g. add an
accounts_map
input to the module, and use the keys and values from there if it is defined, instead of theaccounts
input. This would keep the module backwards compatible. We would then have something likeIf this seems like an acceptable change, I could open a PR to implement it.
The text was updated successfully, but these errors were encountered: