Add support for enabling nested virtualization for the ebs builder - #679
Conversation
This enable the ebs builder to launch an instances with NestedVirtualization enabled. This updates the aws-sdk v2 code paths, and updates the ec2 sdk dependency to v1.307.0 which includes the new NestedVirtualization field. The NestedVirtualization was originally added in v1.288.0, but the most recent version seems best. There appear to be legacy v1 SDK code paths in builder/common/ that use the deprecated v1 SDK, which does not support the NestedVirtualization field. So these will raise an error when that option is used instead.
|
+1, we need this! |
|
+1 |
|
+1, we've to use our own fork with a similar commit until this one is merged. |
|
Hi @wagnerm! I tested it successfully on C7i and on C8i instances. One suggestion: Consider adding config-time validation (similar to Note: I also reviewed the AWS documentation referenced in the current comments and found that nested virtualization is supported on both 7th and 8th generation Intel instance families. Based on that, the validation below covers the supported families from the documentation, including C7i, M7i, R7i, I7i, C8i, M8i, R8i, and X8i. Suggested validation code for if c.EnableNestedVirtualization {
if !c.SupportsNestedVirtualization() {
errs = append(errs, fmt.Errorf(
"Error: Nested virtualization requires 7th or 8th generation Intel instance types (C7i, M7i, R7i, I7i, C8i, M8i, R8i, X8i families), got: %s. "+
"See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-ec2-nested-virtualization.html",
c.InstanceType))
}
}func (c *RunConfig) SupportsNestedVirtualization() bool {
instanceType := strings.ToLower(c.InstanceType)
parts := strings.Split(instanceType, ".")
if len(parts) < 2 {
return false
}
family := parts[0]
supportedPrefixes := []string{"c7i", "m7i", "r7i", "i7i", "c8i", "m8i", "r8i", "x8i"}
for _, prefix := range supportedPrefixes {
if strings.HasPrefix(family, prefix) {
return true
}
}
return false
} |
…ed virtualization According to the documents they support 16 instance families.
|
@hariom-hashicorp thank you for the suggestion. I took your suggestion and modified it a little bit because the prefix matching would have allowed instance types, such as |
|
The CI check is failing because the generated documentation needs to be updated. Can you run The following files need to be committed after running
|
Description
This enables the ebs builder to launch an instances with NestedVirtualization enabled.
This updates the aws-sdk v2 code paths, and updates the ec2 sdk dependency to v1.307.0 which includes the new NestedVirtualization field. The NestedVirtualization was originally added in v1.288.0, but the most recent version seems best if we have to upgrade anyways. I'm happy to split this into another PR if you'd like, or downgrade to v1.288.0.
There appear to be legacy v1 SDK code paths in
builder/common/that use the deprecated v1 SDK, which does not support the NestedVirtualization field. So these will raise an error when that option is used instead. I don't totally understand why this code paths still exist using the v1 SDK, but let me know if something needs to be changed.Resolved Issues
Closes #655
Rollback Plan
If a change needs to be reverted, we will roll out an update to the code within 7 days.
Changes to Security Controls
No