forked from confidential-containers/cloud-api-adaptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanager.go
57 lines (45 loc) · 2.61 KB
/
manager.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// (C) Copyright Confidential Containers Contributors
// SPDX-License-Identifier: Apache-2.0
package aws
import (
"flag"
provider "github.com/confidential-containers/cloud-api-adaptor/src/cloud-providers"
)
var awscfg Config
type Manager struct{}
func init() {
provider.AddCloudProvider("aws", &Manager{})
}
func (_ *Manager) ParseCmd(flags *flag.FlagSet) {
flags.StringVar(&awscfg.AccessKeyId, "aws-access-key-id", "", "Access Key ID, defaults to `AWS_ACCESS_KEY_ID`")
flags.StringVar(&awscfg.SecretKey, "aws-secret-key", "", "Secret Key, defaults to `AWS_SECRET_ACCESS_KEY`")
flags.StringVar(&awscfg.Region, "aws-region", "", "Region")
flags.StringVar(&awscfg.LoginProfile, "aws-profile", "", "AWS Login Profile")
flags.StringVar(&awscfg.LaunchTemplateName, "aws-lt-name", "kata", "AWS Launch Template Name")
flags.BoolVar(&awscfg.UseLaunchTemplate, "use-lt", false, "Use EC2 Launch Template for the Pod VMs")
flags.StringVar(&awscfg.ImageId, "imageid", "", "Pod VM ami id")
flags.StringVar(&awscfg.InstanceType, "instance-type", "m6a.large", "Pod VM instance type")
flags.Var(&awscfg.SecurityGroupIds, "securitygroupids", "Security Group Ids to be used for the Pod VM, comma separated")
flags.StringVar(&awscfg.KeyName, "keyname", "", "SSH Keypair name to be used with the Pod VM")
flags.StringVar(&awscfg.SubnetId, "subnetid", "", "Subnet ID to be used for the Pod VMs")
// Add a List parameter to indicate differet type of instance types to be used for the Pod VMs
flags.Var(&awscfg.InstanceTypes, "instance-types", "Instance types to be used for the Pod VMs, comma separated")
// Add a key value list parameter to indicate custom tags to be used for the Pod VMs
flags.Var(&awscfg.Tags, "tags", "Custom tags (key=value pairs) to be used for the Pod VMs, comma separated")
flags.BoolVar(&awscfg.UsePublicIP, "use-public-ip", false, "Use Public IP for connecting to the kata-agent inside the Pod VM")
// Add a parameter to indicate the root volume size for the Pod VMs
// Default is 30GiBs for free tier. Hence use it as default
flags.IntVar(&awscfg.RootVolumeSize, "root-volume-size", 30, "Root volume size (in GiB) for the Pod VMs")
flags.BoolVar(&awscfg.DisableCVM, "disable-cvm", false, "Use non-CVMs for peer pods")
}
func (_ *Manager) LoadEnv() {
provider.DefaultToEnv(&awscfg.AccessKeyId, "AWS_ACCESS_KEY_ID", "")
provider.DefaultToEnv(&awscfg.SecretKey, "AWS_SECRET_ACCESS_KEY", "")
provider.DefaultToEnv(&awscfg.InstanceType, "PODVM_INSTANCE_TYPE", "m6a.large")
}
func (_ *Manager) NewProvider() (provider.Provider, error) {
return NewProvider(&awscfg)
}
func (_ *Manager) GetConfig() (config *Config) {
return &awscfg
}