@@ -47,29 +47,28 @@ After a successful run, the final line of output will be a line of JSON describi
47
47
SilenceUsage : true ,
48
48
}
49
49
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
73
72
)
74
73
75
74
func init () {
@@ -95,8 +94,7 @@ func init() {
95
94
cmdUpload .Flags ().StringVar (& uploadVolumeType , "volume-type" , "gp3" , "EBS volume type (gp3, gp2, io1, st1, sc1, standard, etc.)" )
96
95
cmdUpload .Flags ().StringVar (& uploadX86BootMode , "x86-boot-mode" , "uefi-preferred" , "Set boot mode (uefi-preferred, uefi)" )
97
96
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" )
100
98
}
101
99
102
100
func defaultBucketNameForRegion (region string ) string {
@@ -140,10 +138,18 @@ func runUpload(cmd *cobra.Command, args []string) error {
140
138
fmt .Fprintf (os .Stderr , "Unrecognized args in aws upload cmd: %v\n " , args )
141
139
os .Exit (2 )
142
140
}
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
+ }
143
145
if uploadDiskSizeInspect && (uploadSourceObject != "" || uploadSourceSnapshot != "" ) {
144
146
fmt .Fprintf (os .Stderr , "--disk-size-inspect cannot be used with --source-object or --source-snapshot.\n " )
145
147
os .Exit (2 )
146
148
}
149
+ if uploadFile == "" && ! uploadCreateWinLIAMI {
150
+ fmt .Fprintf (os .Stderr , "specify --file\n " )
151
+ os .Exit (2 )
152
+ }
147
153
if uploadImageName == "" {
148
154
fmt .Fprintf (os .Stderr , "unknown image name; specify --name\n " )
149
155
os .Exit (2 )
@@ -152,24 +158,13 @@ func runUpload(cmd *cobra.Command, args []string) error {
152
158
fmt .Fprintf (os .Stderr , "unknown AMI name; specify --ami-name\n " )
153
159
os .Exit (2 )
154
160
}
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 , "--winli-billing-product 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 " )
167
+ os .Exit (2 )
173
168
}
174
169
175
170
var err error
@@ -270,20 +265,10 @@ func runUpload(cmd *cobra.Command, args []string) error {
270
265
}
271
266
}
272
267
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
- }
268
+ amiID , err = API .CreateHVMImage (sourceSnapshot , uploadDiskSizeGiB , uploadAMIName , uploadAMIDescription , uploadImageArchitecture , uploadVolumeType , uploadIMDSv2Only , uploadX86BootMode , uploadWinLIBillingProduct )
269
+ if err != nil {
270
+ fmt .Fprintf (os .Stderr , "unable to create HVM image: %v\n " , err )
271
+ os .Exit (1 )
287
272
}
288
273
289
274
if len (uploadGrantUsers ) > 0 {
0 commit comments