Skip to content

Commit

Permalink
mantle/aws: add configuration support for boot mode
Browse files Browse the repository at this point in the history
Add configuration for boot mode when used with a supported architecture
i.e. 'amd64/x86_64'. With a default of 'uefi-preferred'.
  • Loading branch information
prestist authored and dustymabe committed Sep 16, 2023
1 parent 2e6871b commit 1b13b39
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion mantle/cmd/ore/aws/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ After a successful run, the final line of output will be a line of JSON describi
uploadTags []string
uploadIMDSv2Only bool
uploadVolumeType string
uploadX86BootMode string
)

func init() {
Expand All @@ -89,6 +90,7 @@ func init() {
cmdUpload.Flags().StringSliceVar(&uploadTags, "tags", []string{}, "list of key=value tags to attach to the AMI")
cmdUpload.Flags().BoolVar(&uploadIMDSv2Only, "imdsv2-only", false, "enable IMDSv2-only support")
cmdUpload.Flags().StringVar(&uploadVolumeType, "volume-type", "gp3", "EBS volume type (gp3, gp2, io1, st1, sc1, standard, etc.)")
cmdUpload.Flags().StringVar(&uploadX86BootMode, "x86-boot-mode", "uefi-preferred", "Set boot mode (uefi-preferred, uefi)")
}

func defaultBucketNameForRegion(region string) string {
Expand Down Expand Up @@ -247,7 +249,7 @@ func runUpload(cmd *cobra.Command, args []string) error {
}

// create AMIs and grant permissions
amiID, err := API.CreateHVMImage(sourceSnapshot, uploadDiskSizeGiB, uploadAMIName, uploadAMIDescription, uploadImageArchitecture, uploadVolumeType, uploadIMDSv2Only)
amiID, err := API.CreateHVMImage(sourceSnapshot, uploadDiskSizeGiB, uploadAMIName, uploadAMIDescription, uploadImageArchitecture, uploadVolumeType, uploadIMDSv2Only, uploadX86BootMode)
if err != nil {
fmt.Fprintf(os.Stderr, "unable to create HVM image: %v\n", err)
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions mantle/platform/api/aws/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (a *API) CreateImportRole(bucket string) error {
return nil
}

func (a *API) CreateHVMImage(snapshotID string, diskSizeGiB uint, name string, description string, architecture string, volumetype string, imdsv2Only bool) (string, error) {
func (a *API) CreateHVMImage(snapshotID string, diskSizeGiB uint, name string, description string, architecture string, volumetype string, imdsv2Only bool, X86BootMode string) (string, error) {
var awsArch string
var bootmode string
if architecture == "" {
Expand All @@ -338,7 +338,7 @@ func (a *API) CreateHVMImage(snapshotID string, diskSizeGiB uint, name string, d
switch architecture {
case "amd64", "x86_64":
awsArch = ec2.ArchitectureTypeX8664
bootmode = "uefi-preferred"
bootmode = X86BootMode
case "arm64", "aarch64":
awsArch = ec2.ArchitectureTypeArm64
bootmode = "uefi"
Expand Down
2 changes: 2 additions & 0 deletions src/cosalib/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def aws_run_ore(build, args):
ore_args.extend(['--imdsv2-only'])
if 'aws-volume-type' in image_yaml:
ore_args.extend(['--volume-type', image_yaml['aws-volume-type']])
if 'aws-x86-boot-mode' in image_yaml:
ore_args.extend(['--x86-boot-mode', image_yaml['aws-x86-boot-mode']])

ore_args.extend([
'--region', f"{region}",
Expand Down
1 change: 1 addition & 0 deletions src/image-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ vmware-secure-boot: true
# Defaults for AWS
aws-imdsv2-only: true
aws-volume-type: "gp3"
aws-x86-boot-mode: "uefi-preferred"

0 comments on commit 1b13b39

Please sign in to comment.