Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log security groups correctly #646

Merged
merged 1 commit into from
Oct 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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