diff --git a/docs/drivers/aws.md b/docs/drivers/aws.md index 512b0ba726f710af519abbbb4fb36f7e16a72145..27b5cf986aa74d4205c137b7b1160b2354bdaa93 100644 --- a/docs/drivers/aws.md +++ b/docs/drivers/aws.md @@ -74,6 +74,7 @@ You can use environment variables: - `--amazonec2-use-ebs-optimized-instance`: Create an EBS Optimized Instance, instance type must support it. - `--amazonec2-ssh-keypath`: Path to Private Key file to use for instance. Matching public key with .pub extension should exist - `--amazonec2-retries`: Set retry count for recoverable failures (use -1 to disable) +- `--amazonec2-credit-specification`: The credit option for CPU usage of the instance. Valid values: `standard`, `unlimited`. Defaults to [what AWS sets for the instance type](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-performance-instances-unlimited-mode.html). Only supported on [burstable instance types](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-performance-instances.html#burstable-instance-types) #### Environment variables and default values: @@ -106,6 +107,7 @@ You can use environment variables: | `--amazonec2-use-ebs-optimized-instance` | - | `false` | | `--amazonec2-ssh-keypath` | `AWS_SSH_KEYPATH` | - | | `--amazonec2-retries` | - | `5` | +| `--amazonec2-credit-specification` | - | - | ## Default AMIs diff --git a/drivers/amazonec2/amazonec2.go b/drivers/amazonec2/amazonec2.go index 046cf2d82ed0e17e723be74c5c6aec98e4bd64df..0c7bacb6c27bd8a52df760e3266a7320cec4fb46 100644 --- a/drivers/amazonec2/amazonec2.go +++ b/drivers/amazonec2/amazonec2.go @@ -118,6 +118,7 @@ type Driver struct { UserDataFile string MetadataTokenSetting string MetadataTokenResponseHopLimit int64 + CreditSpecification string } type clientFactory interface { @@ -309,6 +310,10 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { Usage: "The number of network hops that the metadata token can travel", Value: defaultMetadataTokenResponseHopLimit, }, + mcnflag.StringFlag{ + Name: "amazonec2-credit-specification", + Usage: "The credit option for CPU usage (unlimited or standard)", + }, } } @@ -414,6 +419,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { d.MetadataTokenSetting = flags.String("amazonec2-metadata-token") d.MetadataTokenResponseHopLimit = int64(flags.Int("amazonec2-metadata-token-response-hop-limit")) d.DisableSSL = flags.Bool("amazonec2-insecure-transport") + d.CreditSpecification = strings.TrimSpace(flags.String("amazonec2-credit-specification")) if d.DisableSSL && d.Endpoint == "" { return errorDisableSSLWithoutCustomEndpoint @@ -696,6 +702,11 @@ func (d *Driver) innerCreate() error { BlockDeviceMappings: []*ec2.BlockDeviceMapping{bdm}, UserData: &userdata, } + if d.CreditSpecification != "" { + req.CreditSpecification = &ec2.CreditSpecificationRequest{ + CpuCredits: &d.CreditSpecification, + } + } if d.RequestSpotInstance { req.InstanceMarketOptions = &ec2.InstanceMarketOptionsRequest{ MarketType: aws.String("spot"),