@@ -47,29 +47,28 @@ After a successful run, the final line of output will be a line of JSON describi
4747 SilenceUsage : true ,
4848 }
4949
50- uploadSourceObject string
51- uploadBucket string
52- uploadImageName string
53- uploadImageArchitecture string
54- uploadFile string
55- uploadDiskSizeGiB uint
56- uploadDiskSizeInspect bool
57- uploadDeleteObject bool
58- uploadForce bool
59- uploadSourceSnapshot string
60- uploadObjectFormat aws.EC2ImageFormat
61- uploadAMIName string
62- uploadAMIDescription string
63- uploadPublic bool
64- uploadGrantUsers []string
65- uploadGrantUsersSnapshot []string
66- uploadTags []string
67- uploadIMDSv2Only bool
68- uploadVolumeType string
69- uploadX86BootMode string
70- uploadCreateWinLIAMI bool
71- uploadWinLIwindowsServerAMI string
72- uploadWinLIInstanceType string
50+ uploadSourceObject string
51+ uploadBucket string
52+ uploadImageName string
53+ uploadImageArchitecture string
54+ uploadFile string
55+ uploadDiskSizeGiB uint
56+ uploadDiskSizeInspect bool
57+ uploadDeleteObject bool
58+ uploadForce bool
59+ uploadSourceSnapshot string
60+ uploadObjectFormat aws.EC2ImageFormat
61+ uploadAMIName string
62+ uploadAMIDescription string
63+ uploadPublic bool
64+ uploadGrantUsers []string
65+ uploadGrantUsersSnapshot []string
66+ uploadTags []string
67+ uploadIMDSv2Only bool
68+ uploadVolumeType string
69+ uploadX86BootMode string
70+ uploadCreateWinLIAMI bool
71+ uploadWinLIBillingProduct string
7372)
7473
7574func init () {
@@ -95,8 +94,7 @@ func init() {
9594 cmdUpload .Flags ().StringVar (& uploadVolumeType , "volume-type" , "gp3" , "EBS volume type (gp3, gp2, io1, st1, sc1, standard, etc.)" )
9695 cmdUpload .Flags ().StringVar (& uploadX86BootMode , "x86-boot-mode" , "uefi-preferred" , "Set boot mode (uefi-preferred, uefi)" )
9796 cmdUpload .Flags ().BoolVar (& uploadCreateWinLIAMI , "winli" , false , "Create a Windows LI AMI" )
98- cmdUpload .Flags ().StringVar (& uploadWinLIwindowsServerAMI , "windows-ami" , "" , "Windows Server AMI used to create a Windows LI AMI" )
99- cmdUpload .Flags ().StringVar (& uploadWinLIInstanceType , "winli-instance-type" , "t2.large" , "ec2 instance type used to create a Windows LI AMI" )
97+ cmdUpload .Flags ().StringVar (& uploadWinLIBillingProduct , "winli-billing-product" , "" , "Windows billing product code used to create a Windows LI AMI" )
10098}
10199
102100func defaultBucketNameForRegion (region string ) string {
@@ -140,10 +138,18 @@ func runUpload(cmd *cobra.Command, args []string) error {
140138 fmt .Fprintf (os .Stderr , "Unrecognized args in aws upload cmd: %v\n " , args )
141139 os .Exit (2 )
142140 }
141+ if uploadSourceObject != "" && uploadSourceSnapshot != "" {
142+ fmt .Fprintf (os .Stderr , "At most one of --source-object and --source-snapshot may be specified.\n " )
143+ os .Exit (2 )
144+ }
143145 if uploadDiskSizeInspect && (uploadSourceObject != "" || uploadSourceSnapshot != "" ) {
144146 fmt .Fprintf (os .Stderr , "--disk-size-inspect cannot be used with --source-object or --source-snapshot.\n " )
145147 os .Exit (2 )
146148 }
149+ if uploadFile == "" && ! uploadCreateWinLIAMI {
150+ fmt .Fprintf (os .Stderr , "specify --file\n " )
151+ os .Exit (2 )
152+ }
147153 if uploadImageName == "" {
148154 fmt .Fprintf (os .Stderr , "unknown image name; specify --name\n " )
149155 os .Exit (2 )
@@ -152,24 +158,12 @@ func runUpload(cmd *cobra.Command, args []string) error {
152158 fmt .Fprintf (os .Stderr , "unknown AMI name; specify --ami-name\n " )
153159 os .Exit (2 )
154160 }
155- if uploadCreateWinLIAMI {
156- if uploadWinLIwindowsServerAMI == "" {
157- fmt .Fprintf (os .Stderr , "--windows-ami must be provided with --winli\n " )
158- os .Exit (2 )
159- }
160- if uploadSourceSnapshot == "" {
161- fmt .Fprintf (os .Stderr , "--source-snapshot must be provided with --winli\n " )
162- os .Exit (2 )
163- }
164- } else {
165- if uploadSourceObject != "" && uploadSourceSnapshot != "" {
166- fmt .Fprintf (os .Stderr , "At most one of --source-object and --source-snapshot may be specified.\n " )
167- os .Exit (2 )
168- }
169- if uploadFile == "" {
170- fmt .Fprintf (os .Stderr , "specify --file\n " )
171- os .Exit (2 )
172- }
161+ if uploadWinLIBillingProduct != "" && ! uploadCreateWinLIAMI {
162+ fmt .Fprintf (os .Stderr , "--billing-code can only be used with --winli\n " )
163+ os .Exit (2 )
164+ }
165+ if uploadCreateWinLIAMI && uploadSourceSnapshot == "" {
166+ fmt .Fprintf (os .Stderr , "unknown source snapshot; specify --source-snapshot\n " )
173167 }
174168
175169 var err error
@@ -270,20 +264,10 @@ func runUpload(cmd *cobra.Command, args []string) error {
270264 }
271265 }
272266
273- // create AMIs and grant permissions
274- var amiID string
275- if uploadWinLIwindowsServerAMI == "" {
276- amiID , err = API .CreateHVMImage (sourceSnapshot , uploadDiskSizeGiB , uploadAMIName , uploadAMIDescription , uploadImageArchitecture , uploadVolumeType , uploadIMDSv2Only , uploadX86BootMode )
277- if err != nil {
278- fmt .Fprintf (os .Stderr , "unable to create HVM image: %v\n " , err )
279- os .Exit (1 )
280- }
281- } else {
282- amiID , sourceSnapshot , err = API .CreateWinLiImage (sourceSnapshot , uploadAMIName , uploadAMIDescription , uploadImageArchitecture , uploadWinLIwindowsServerAMI , uploadWinLIInstanceType , uploadVolumeType )
283- if err != nil {
284- fmt .Fprintf (os .Stderr , "unable to create WinLI image: %v\n " , err )
285- os .Exit (1 )
286- }
267+ amiID , err = API .CreateHVMImage (sourceSnapshot , uploadDiskSizeGiB , uploadAMIName , uploadAMIDescription , uploadImageArchitecture , uploadVolumeType , uploadIMDSv2Only , uploadX86BootMode , uploadWinLIBillingProduct )
268+ if err != nil {
269+ fmt .Fprintf (os .Stderr , "unable to create HVM image: %v\n " , err )
270+ os .Exit (1 )
287271 }
288272
289273 if len (uploadGrantUsers ) > 0 {
0 commit comments