Skip to content
Snippets Groups Projects
Commit 44911090 authored by Ruben's avatar Ruben Committed by Axel von Bertoldi
Browse files

AWS Credit Specification support

parent 145bd24f
Branches
Tags 7.8.3
No related merge requests found
...@@ -74,6 +74,7 @@ You can use environment variables: ...@@ -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-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-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-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: #### Environment variables and default values:
...@@ -106,6 +107,7 @@ You can use environment variables: ...@@ -106,6 +107,7 @@ You can use environment variables:
| `--amazonec2-use-ebs-optimized-instance` | - | `false` | | `--amazonec2-use-ebs-optimized-instance` | - | `false` |
| `--amazonec2-ssh-keypath` | `AWS_SSH_KEYPATH` | - | | `--amazonec2-ssh-keypath` | `AWS_SSH_KEYPATH` | - |
| `--amazonec2-retries` | - | `5` | | `--amazonec2-retries` | - | `5` |
| `--amazonec2-credit-specification` | - | - |
## Default AMIs ## Default AMIs
......
...@@ -118,6 +118,7 @@ type Driver struct { ...@@ -118,6 +118,7 @@ type Driver struct {
UserDataFile string UserDataFile string
MetadataTokenSetting string MetadataTokenSetting string
MetadataTokenResponseHopLimit int64 MetadataTokenResponseHopLimit int64
CreditSpecification string
} }
type clientFactory interface { type clientFactory interface {
...@@ -309,6 +310,10 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { ...@@ -309,6 +310,10 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Usage: "The number of network hops that the metadata token can travel", Usage: "The number of network hops that the metadata token can travel",
Value: defaultMetadataTokenResponseHopLimit, 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 { ...@@ -414,6 +419,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.MetadataTokenSetting = flags.String("amazonec2-metadata-token") d.MetadataTokenSetting = flags.String("amazonec2-metadata-token")
d.MetadataTokenResponseHopLimit = int64(flags.Int("amazonec2-metadata-token-response-hop-limit")) d.MetadataTokenResponseHopLimit = int64(flags.Int("amazonec2-metadata-token-response-hop-limit"))
d.DisableSSL = flags.Bool("amazonec2-insecure-transport") d.DisableSSL = flags.Bool("amazonec2-insecure-transport")
d.CreditSpecification = strings.TrimSpace(flags.String("amazonec2-credit-specification"))
if d.DisableSSL && d.Endpoint == "" { if d.DisableSSL && d.Endpoint == "" {
return errorDisableSSLWithoutCustomEndpoint return errorDisableSSLWithoutCustomEndpoint
...@@ -696,6 +702,11 @@ func (d *Driver) innerCreate() error { ...@@ -696,6 +702,11 @@ func (d *Driver) innerCreate() error {
BlockDeviceMappings: []*ec2.BlockDeviceMapping{bdm}, BlockDeviceMappings: []*ec2.BlockDeviceMapping{bdm},
UserData: &userdata, UserData: &userdata,
} }
if d.CreditSpecification != "" {
req.CreditSpecification = &ec2.CreditSpecificationRequest{
CpuCredits: &d.CreditSpecification,
}
}
if d.RequestSpotInstance { if d.RequestSpotInstance {
req.InstanceMarketOptions = &ec2.InstanceMarketOptionsRequest{ req.InstanceMarketOptions = &ec2.InstanceMarketOptionsRequest{
MarketType: aws.String("spot"), MarketType: aws.String("spot"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment