feat: Replace the use of toset()
with static keys for node IAM role policy attachment
#2962
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.
Description
Motivation and Context
The use of
toset()
infor_each
loops is known to be problematic. In hindsight, this should have been corrected during v20.0 but it must have been an oversight on my part. The use oftoset()
on the static policy attachment (custom/additional policy attachment was added awhile back with static keys) has worked without issue except for scenarios where users try to use an explicitdepends_on
(which is not recommended across modules for a number of reasons).Why is this an issue now? We have an issue with our user data where the cluster service CIDR is not being passed properly, causing nodes to have the wrong internal IP. Oddly enough, we haven't seen user reports for this prior to #2955, and I first noticed it on #2960 (comment) (see screen shot - some internal IPs are IPv6, others are IPv4 - they all should be IPv6). While drafting a PR to resolve the service CIDR issue, the dreaded
Error: Invalid for_each argument
appeared for reasons I can't quite understand (yet):Breaking Changes
From an API perspective, no. However, there will be a very brief (< 1s-2s) period where permission(s) will be removed and re-attached to the IAM role used by nodes. This has been minimized with the use of Terraform state
move
blocks, but due to limitations of the currentmove
functionality, they are unable to support moving from multiple sources to a single target (i.e. - the source will vary based on the partition -aws
,aws-cn
,aws-us-gov
) so only the commercialaws
region (majority) is supported. In addition,move
blocks do not support variables/dynamic values (which would also resolve the prior issue), which means that the IPv6 CNI policy attachment, which is not a managed policy and therefore user created and its ARN will contain the account ID, cannot be moved either. However, the majority use case for the commercialaws
partition, using the managed IPv4 CNI policy, is supported without disruptionThe potential disruption while unfortunate, is quite minimal and could be equated to a small blip in network connectivity. Therefore, I am proposing this change be made under the current v20 major version so that we can continue on to resolve the service CIDR issue and avoid introducing further, larger disruptions that would be captured under v21 at a later date.
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull request