cloudapi: Share an ec2 snapshot/ami with an account
This commit is contained in:
parent
6388aaff4c
commit
22c9f6af61
10 changed files with 118 additions and 28 deletions
|
|
@ -26,9 +26,10 @@ type AWSUploadRequestOptions struct {
|
|||
|
||||
// AWSUploadRequestOptionsEc2 defines model for AWSUploadRequestOptionsEc2.
|
||||
type AWSUploadRequestOptionsEc2 struct {
|
||||
AccessKeyId string `json:"access_key_id"`
|
||||
SecretAccessKey string `json:"secret_access_key"`
|
||||
SnapshotName *string `json:"snapshot_name,omitempty"`
|
||||
AccessKeyId string `json:"access_key_id"`
|
||||
SecretAccessKey string `json:"secret_access_key"`
|
||||
ShareWithAccounts *[]string `json:"share_with_accounts,omitempty"`
|
||||
SnapshotName *string `json:"snapshot_name,omitempty"`
|
||||
}
|
||||
|
||||
// AWSUploadRequestOptionsS3 defines model for AWSUploadRequestOptionsS3.
|
||||
|
|
|
|||
|
|
@ -210,6 +210,11 @@ components:
|
|||
snapshot_name:
|
||||
type: string
|
||||
example: 'my-snapshot'
|
||||
share_with_accounts:
|
||||
type: array
|
||||
example: ['123456789012']
|
||||
items:
|
||||
type: string
|
||||
Customizations:
|
||||
type: object
|
||||
properties:
|
||||
|
|
|
|||
|
|
@ -167,14 +167,19 @@ func (server *Server) Compose(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
var share []string
|
||||
if awsUploadOptions.Ec2.ShareWithAccounts != nil {
|
||||
share = *awsUploadOptions.Ec2.ShareWithAccounts
|
||||
}
|
||||
key := fmt.Sprintf("composer-api-%s", uuid.New().String())
|
||||
t := target.NewAWSTarget(&target.AWSTargetOptions{
|
||||
Filename: imageType.Filename(),
|
||||
Region: awsUploadOptions.Region,
|
||||
AccessKeyID: awsUploadOptions.S3.AccessKeyId,
|
||||
SecretAccessKey: awsUploadOptions.S3.SecretAccessKey,
|
||||
Bucket: awsUploadOptions.S3.Bucket,
|
||||
Key: key,
|
||||
Filename: imageType.Filename(),
|
||||
Region: awsUploadOptions.Region,
|
||||
AccessKeyID: awsUploadOptions.S3.AccessKeyId,
|
||||
SecretAccessKey: awsUploadOptions.S3.SecretAccessKey,
|
||||
Bucket: awsUploadOptions.S3.Bucket,
|
||||
Key: key,
|
||||
ShareWithAccounts: share,
|
||||
})
|
||||
if awsUploadOptions.Ec2.SnapshotName != nil {
|
||||
t.ImageName = *awsUploadOptions.Ec2.SnapshotName
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue