Skip to content

Commit

Permalink
Log security groups correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Claes Mogren authored and mogren committed Oct 16, 2019
1 parent 7f48fe1 commit 3aacadc
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions pkg/awsutils/awsutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,24 +625,24 @@ func (cache *EC2InstanceMetadataCache) attachENI(eniID string) (string, error) {
// return ENI id, error
func (cache *EC2InstanceMetadataCache) createENI(useCustomCfg bool, sg []*string, subnet string) (string, error) {
eniDescription := eniDescriptionPrefix + cache.instanceID
var input *ec2.CreateNetworkInterfaceInput
input := &ec2.CreateNetworkInterfaceInput{
Description: aws.String(eniDescription),
Groups: cache.securityGroups,
SubnetId: aws.String(cache.subnetID),
}

if useCustomCfg {
log.Infof("createENI: use custom network config, %v, %s", &sg, subnet)
input = &ec2.CreateNetworkInterfaceInput{
Description: aws.String(eniDescription),
Groups: sg,
SubnetId: aws.String(subnet),
}
log.Info("Using a custom network config for the new ENI")
input.Groups = sg
input.SubnetId = aws.String(subnet)
} else {
log.Infof("createENI: use primary interface's config, %v, %s", cache.securityGroups, cache.subnetID)
input = &ec2.CreateNetworkInterfaceInput{
Description: aws.String(eniDescription),
Groups: cache.securityGroups,
SubnetId: aws.String(cache.subnetID),
}
log.Info("Using same config as the primary interface for the new ENI")
}

var sgs []string
for i := range input.Groups {
sgs = append(sgs, *input.Groups[i])
}
log.Infof("Creating ENI with security groups: %v in subnet: %s", sgs, *input.SubnetId)
start := time.Now()
result, err := cache.ec2SVC.CreateNetworkInterface(input)
awsAPILatency.WithLabelValues("CreateNetworkInterface", fmt.Sprint(err != nil)).Observe(msSince(start))
Expand Down

0 comments on commit 3aacadc

Please sign in to comment.