in pkg/deploy/lattice/rule_manager.go [247:289]
func (r *defaultRuleManager) create(
ctx context.Context,
currentLatticeRules []*vpclattice.GetRuleOutput,
ruleToCreate *vpclattice.GetRuleOutput,
latticeSvcId string,
latticeListenerId string,
) (model.RuleStatus, error) {
// when we create a rule, we just pick an available priority so we can
// successfully create the rule. After all rules are created, we update
// priorities based on the order they appear in the Route. Note, this
// approach is not fully compliant with the gw spec
priority, err := r.nextAvailablePriority(currentLatticeRules)
if err != nil {
return model.RuleStatus{}, err
}
ruleToCreate.Priority = aws.Int64(priority)
cri := vpclattice.CreateRuleInput{
Action: ruleToCreate.Action,
ServiceIdentifier: aws.String(latticeSvcId),
ListenerIdentifier: aws.String(latticeListenerId),
Match: ruleToCreate.Match,
Name: ruleToCreate.Name,
Priority: ruleToCreate.Priority,
Tags: r.cloud.DefaultTags(),
}
res, err := r.cloud.Lattice().CreateRuleWithContext(ctx, &cri)
if err != nil {
return model.RuleStatus{}, fmt.Errorf("failed CreateRule %s, %s due to %s", latticeListenerId, latticeSvcId, err)
}
r.log.Infof(ctx, "Success CreateRule %s, %s", aws.StringValue(res.Name), aws.StringValue(res.Id))
return model.RuleStatus{
Name: aws.StringValue(res.Name),
Arn: aws.StringValue(res.Arn),
Id: aws.StringValue(res.Id),
ServiceId: latticeSvcId,
ListenerId: latticeListenerId,
Priority: aws.Int64Value(res.Priority),
}, nil
}