func()

in pkg/deploy/lattice/access_log_subscription_synthesizer.go [34:71]


func (s *accessLogSubscriptionSynthesizer) Synthesize(ctx context.Context) error {
	var accessLogSubscriptions []*model.AccessLogSubscription
	err := s.stack.ListResources(&accessLogSubscriptions)
	if err != nil {
		return err
	}

	for _, als := range accessLogSubscriptions {
		switch als.Spec.EventType {
		case core.CreateEvent:
			s.log.Debugf(ctx, "Started creating Access Log Subscription %s", als.ID())
			alsStatus, err := s.accessLogSubscriptionManager.Create(ctx, als)
			if err != nil {
				return err
			}
			als.Status = alsStatus
		case core.UpdateEvent:
			s.log.Debugf(ctx, "Started updating Access Log Subscription %s", als.ID())
			alsStatus, err := s.accessLogSubscriptionManager.Update(ctx, als)
			if err != nil {
				return err
			}
			als.Status = alsStatus
		case core.DeleteEvent:
			s.log.Debugf(ctx, "Started deleting Access Log Subscription %s", als.ID())
			if als.Status == nil {
				s.log.Debugf(ctx, "Ignoring deletion of Access Log Subscription because als %s has no ARN", als.ID())
				return nil
			}
			err := s.accessLogSubscriptionManager.Delete(ctx, als.Status.Arn)
			if err != nil {
				return err
			}
		}
	}

	return nil
}