func (p *AWSProvider) ServiceUnlinkSubscribe(a *structs.App, s *structs.Service) error { // delete from links apps := structs.Apps{} for _, linkedApp := range s.Apps { if a.Name != linkedApp.Name { apps = append(apps, linkedApp) } } s.Apps = apps formation, err := serviceFormation(s.Type, s) if err != nil { return err } req := &cloudformation.UpdateStackInput{ Capabilities: []*string{aws.String("CAPABILITY_IAM")}, StackName: aws.String(serviceStackName(s)), TemplateBody: aws.String(formation), } for key, value := range s.Parameters { req.Parameters = append(req.Parameters, &cloudformation.Parameter{ ParameterKey: aws.String(key), ParameterValue: aws.String(value), }) } _, err = p.cloudformation().UpdateStack(req) return err }
// delete from links func (p *AWSProvider) unlinkService(a *structs.App, s *structs.Service) error { apps := structs.Apps{} for _, linkedApp := range s.Apps { if a.Name != linkedApp.Name { apps = append(apps, linkedApp) } } s.Apps = apps return p.updateService(s) }
// add to links func (p *AWSProvider) linkService(a *structs.App, s *structs.Service) error { s.Apps = append(s.Apps, *a) return p.updateService(s) }