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

Running instance with pre-created NIC with DeviceIndex: 0 fails with API error #1178

Closed
3 tasks done
varnastadeus opened this issue Mar 17, 2021 · 3 comments
Closed
3 tasks done
Labels
bug This issue is a bug. service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@varnastadeus
Copy link

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
Running instance with pre-created network interface and DeviceIndex of 0 results in API error: api error InvalidParameterValue: Each network interface requires a device index. It seems 0 is treated as an empty value even though it is valid.

In sdk-v1 it was pointer and we used DeviceIndex: aws.Int64(0) which worked perfectly fine.

Version of AWS SDK for Go?
aws-sdk-go-v2/1.2.1

Version of Go (go version)?
go/1.16

To Reproduce (observed behavior)

subnetID := "TODO"
imageID := "TODO"

cfg, err := config.LoadDefaultConfig(context.Background())
if err != nil {
    return err
}

client := ec2.NewFromConfig(cfg)
nic, err := client.CreateNetworkInterface(context.Background(), &ec2.CreateNetworkInterfaceInput{
    SubnetId: &subnetID,
})
if err != nil {
    return err
}

_, err = client.RunInstances(context.Background(), &ec2.RunInstancesInput{
    InstanceType: ec2types.InstanceTypeT2Medium,
    ImageId:      &imageID,
    MaxCount:     1,
    MinCount:     1,
    NetworkInterfaces: []ec2types.InstanceNetworkInterfaceSpecification{
    {
	NetworkInterfaceId: nic.NetworkInterface.NetworkInterfaceId,
	DeviceIndex:        0,
    },
},
})
if err != nil {
    return err
}

return nil

Expected behavior
The instance should be able to start.

@varnastadeus varnastadeus added the bug This issue is a bug. label Mar 17, 2021
@jasdel jasdel added the service-api This issue is due to a problem in a service API, not the SDK implementation. label Mar 22, 2021
@jasdel
Copy link
Contributor

jasdel commented Mar 22, 2021

Thanks for reaching out @varnastadeus . This issue is similar to #1107 Where the EC2 API model is missing metadata instructing the SDK how it should serialize these operations. We're working with the EC2 service team on how best to address these operations.

@jasdel
Copy link
Contributor

jasdel commented May 7, 2021

This issue has been resolved in #1195 in the latest release tag, service/ec2/v1.6.0. You can update your application to use the latest version with

go get -d github.com/aws/aws-sdk-go-v2/service/ec2@v1.6.0

While this release fixes the client to be able to send all request parameters to the API, a breaking change to the generated code was needed. The parameters like MaxCount, MinCount, and DeviceIndex are pointer types now, not values. You can use either addresses, or the aws.Int32 utilities to not need to create a local variable when assigning the value.

@jasdel jasdel closed this as completed May 7, 2021
@github-actions
Copy link

github-actions bot commented May 7, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

2 participants