Skip to content

Commit

Permalink
only set tag specification if tags are passed
Browse files Browse the repository at this point in the history
  • Loading branch information
fishnix committed Dec 16, 2021
1 parent ef046ff commit b6d5026
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions api/orchestration_sgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,32 @@ func (o *ec2Orchestrator) createSecurityGroup(ctx context.Context, req *Ec2Secur
}
}()

tags := []*ec2.Tag{}
for _, tag := range req.Tags {
for k, v := range tag {
tags = append(tags, &ec2.Tag{
Key: aws.String(k),
Value: aws.String(v),
})
}
}

out, err := o.client.CreateSecurityGroup(ctx, &ec2.CreateSecurityGroupInput{
input := &ec2.CreateSecurityGroupInput{
Description: aws.String(req.Description),
GroupName: aws.String(req.GroupName),
VpcId: aws.String(req.VpcId),
TagSpecifications: []*ec2.TagSpecification{
}

if len(req.Tags) > 0 {
tags := []*ec2.Tag{}
for _, tag := range req.Tags {
for k, v := range tag {
tags = append(tags, &ec2.Tag{
Key: aws.String(k),
Value: aws.String(v),
})
}
}

input.SetTagSpecifications([]*ec2.TagSpecification{
{
ResourceType: aws.String("security-group"),
Tags: tags,
},
},
})
})
}

out, err := o.client.CreateSecurityGroup(ctx, input)
if err != nil {
return "", err
}
Expand Down

0 comments on commit b6d5026

Please sign in to comment.