mirror of https://github.com/kubernetes/kops.git
Tag EBS volumes when using launch templates with AWS API target
This commit is contained in:
parent
d70cc9e17f
commit
4b33efedaa
|
|
@ -97,6 +97,11 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tags, err := b.CloudTagsForInstanceGroup(ig)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error building cloud tags: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// @TODO check if there any a better way of doing this .. initially I had a type LaunchTemplate which included
|
// @TODO check if there any a better way of doing this .. initially I had a type LaunchTemplate which included
|
||||||
// LaunchConfiguration as an anonymous field, bit given up the task dependency walker works this caused issues, due
|
// LaunchConfiguration as an anonymous field, bit given up the task dependency walker works this caused issues, due
|
||||||
// to the creation of a implicit dependency
|
// to the creation of a implicit dependency
|
||||||
|
|
@ -115,6 +120,7 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde
|
||||||
RootVolumeType: lc.RootVolumeType,
|
RootVolumeType: lc.RootVolumeType,
|
||||||
SSHKey: lc.SSHKey,
|
SSHKey: lc.SSHKey,
|
||||||
SecurityGroups: lc.SecurityGroups,
|
SecurityGroups: lc.SecurityGroups,
|
||||||
|
Tags: tags,
|
||||||
Tenancy: lc.Tenancy,
|
Tenancy: lc.Tenancy,
|
||||||
UserData: lc.UserData,
|
UserData: lc.UserData,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ type LaunchTemplate struct {
|
||||||
SecurityGroups []*SecurityGroup
|
SecurityGroups []*SecurityGroup
|
||||||
// SpotPrice is set to the spot-price bid if this is a spot pricing request
|
// SpotPrice is set to the spot-price bid if this is a spot pricing request
|
||||||
SpotPrice string
|
SpotPrice string
|
||||||
|
// Tags are the keypairs to apply to the instance and volume on launch.
|
||||||
|
Tags map[string]string
|
||||||
// Tenancy. Can be either default or dedicated.
|
// Tenancy. Can be either default or dedicated.
|
||||||
Tenancy *string
|
Tenancy *string
|
||||||
// UserData is the user data configuration
|
// UserData is the user data configuration
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,25 @@ func (t *LaunchTemplate) RenderAWS(c *awsup.AWSAPITarget, a, ep, changes *Launch
|
||||||
} else {
|
} else {
|
||||||
lc.SecurityGroupIds = securityGroups
|
lc.SecurityGroupIds = securityGroups
|
||||||
}
|
}
|
||||||
|
// @step: add the tags
|
||||||
|
{
|
||||||
|
var list []*ec2.Tag
|
||||||
|
for k, v := range t.Tags {
|
||||||
|
list = append(list, &ec2.Tag{
|
||||||
|
Key: aws.String(k),
|
||||||
|
Value: aws.String(v),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
instanceTagSpec := ec2.LaunchTemplateTagSpecificationRequest{
|
||||||
|
ResourceType: aws.String("instance"),
|
||||||
|
Tags: list,
|
||||||
|
}
|
||||||
|
volumeTagSpec := ec2.LaunchTemplateTagSpecificationRequest{
|
||||||
|
ResourceType: aws.String("volume"),
|
||||||
|
Tags: list,
|
||||||
|
}
|
||||||
|
lc.TagSpecifications = []*ec2.LaunchTemplateTagSpecificationRequest{&instanceTagSpec, &volumeTagSpec}
|
||||||
|
}
|
||||||
// @step: add the userdata
|
// @step: add the userdata
|
||||||
if t.UserData != nil {
|
if t.UserData != nil {
|
||||||
d, err := t.UserData.AsBytes()
|
d, err := t.UserData.AsBytes()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue