provider/aws: Fix SG update on instance with multiple network interfaces #14299
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.
With an EC2 instance that only had a single network interface, the primary interface, the Update function would call
ModifyInstanceAttribute()
on the target instance. This would only work if there was a single network interface attached to the EC2 instance. If, however, a secondary network interface was attached to the instance, theModifyInstanceAttribute()
API call would fail with the following error message:After this changeset, modifying instance security groups now makes the correct call to
ModifyNetworkInterfaceAttribute()
in order to modify the list of security groups on the primary network interface, as initially configured during the instances creation.This change is also safe from an instance that has a non-default primary network interface, as the instance attribute
vpc_security_group_ids
conflicts with the newnetwork_interface
attribute.Test Output:
Fixes: #3205, #7635
Related to: #7711