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

provider/aws: Fix SG update on instance with multiple network interfaces #14299

Merged
merged 1 commit into from
May 11, 2017

Commits on May 8, 2017

  1. provider/aws: Fix attach of SG to instance with multiple network inte…

    …rfaces
    
    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, the `ModifyInstanceAttribute()` API call would fail with the following error message:
    
     > There are multiple interfaces attached to instance 'i-XXXXX'. Please specify an interface ID for the operation instead.
    
     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 new `network_interface` attribute.
    
     Test Output:
    
     ```
     $ make testacc TEST=./builtin/providers/aws TESTARGS="-run=TestAccAWSInstance_addSecurityGroupNetworkInterface"
     ==> Checking that code complies with gofmt requirements...
     go generate $(go list ./... | grep -v /terraform/vendor/)
     2017/05/08 17:52:42 Generated command/internal_plugin_list.go
     TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSInstance_addSecurityGroupNetworkInterface -timeout 120m
     === RUN   TestAccAWSInstance_addSecurityGroupNetworkInterface
     --- PASS: TestAccAWSInstance_addSecurityGroupNetworkInterface (327.75s)
     PASS
     ok      github.com/hashicorp/terraform/builtin/providers/aws    327.756s
    ```
    grubernaut committed May 8, 2017
    Configuration menu
    Copy the full SHA
    0d6891d View commit details
    Browse the repository at this point in the history