Skip to content
Snippets Groups Projects

Run instances with IMDSv2

Merged Thiago Presa requested to merge tpresa-run-instances-imdsv2 into master
All threads resolved!
@@ -113,6 +113,7 @@ type Driver struct {
Endpoint string
DisableSSL bool
UserDataFile string
MetadataToken string
spotInstanceRequestId string
}
@@ -287,6 +288,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Usage: "path to file with cloud-init user data",
EnvVar: "AWS_USERDATA",
},
mcnflag.StringFlag{
Name: "amazonec2-metadata-token",
Usage: "Whether the metadata token is required or optional",
Value: "optional",
},
}
}
@@ -385,7 +391,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.RetryCount = flags.Int("amazonec2-retries")
d.OpenPorts = flags.StringSlice("amazonec2-open-port")
d.UserDataFile = flags.String("amazonec2-userdata")
d.MetadataToken = flags.String("amazonec2-metadata-token")
d.DisableSSL = flags.Bool("amazonec2-insecure-transport")
if d.DisableSSL && d.Endpoint == "" {
@@ -739,7 +745,10 @@ func (d *Driver) innerCreate() error {
KeyName: &d.KeyName,
InstanceType: &d.InstanceType,
NetworkInterfaces: netSpecs,
Monitoring: &ec2.RunInstancesMonitoringEnabled{Enabled: aws.Bool(d.Monitoring)},
MetadataOptions: &ec2.InstanceMetadataOptionsRequest{
HttpTokens: &d.MetadataToken,
},
Monitoring: &ec2.RunInstancesMonitoringEnabled{Enabled: aws.Bool(d.Monitoring)},
IamInstanceProfile: &ec2.IamInstanceProfileSpecification{
Name: &d.IamInstanceProfile,
},
Loading