Skip to content

Commit

Permalink
Merge pull request #28 from reiki4040/add/check-exists-task-definition
Browse files Browse the repository at this point in the history
added task definition validation.
  • Loading branch information
Songmu authored Dec 28, 2021
2 parents 8059717 + 3f55a45 commit 78f3636
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,25 @@ func (r *Rule) validateEnv() error {
return nil
}

func (r *Rule) validateTaskDefinition(sess *session.Session) error {
svc := ecs.New(sess, &aws.Config{Region: aws.String(r.Region)})
input := &ecs.DescribeTaskDefinitionInput{
TaskDefinition: aws.String(r.Target.TaskDefinition),
}
if _, err := svc.DescribeTaskDefinition(input); err != nil {
return fmt.Errorf("task definition %s is not defined: %s", r.Target.TaskDefinition, err.Error())
}
return nil
}

// Apply the rule
func (r *Rule) Apply(ctx context.Context, sess *session.Session, dryRun bool) error {
if err := r.validateEnv(); err != nil {
return err
}
if err := r.validateTaskDefinition(sess); err != nil {
return err
}
svc := cloudwatchevents.New(sess, &aws.Config{Region: aws.String(r.Region)})

from, to, err := r.diff(ctx, svc)
Expand Down

0 comments on commit 78f3636

Please sign in to comment.