Circle ci ecs orb deplpy-service is not working

version: 2.1
orbs:
    aws-ecr: circleci/aws-ecr@6.15.2
    aws-ecs: circleci/aws-ecs@1.4.0


jobs:
  build_push_deploy_notify:
    docker:
      - image: circleci/node
    steps:
      - checkout
      - aws-ecr/build-and-push-image:
          repo: "${AWS_RESOURCE_NAME_PREFIX}"
          tag: "$(git rev-parse --short HEAD)"
      - aws-ecs/deploy-service-update:
          requires:
            - aws-ecr/build-and-push-image # only run this job once aws-ecr/build-and-push-image has completed
          family: "test-cluster-td"
          cluster-name: "test-cluster"
          container-image-name-updates: "container=test-container,image-and-tag=${AWS_ECR_ACCOUNT_URL}/${AWS_RESOURCE_NAME_PREFIX}:$(echo $CIRCLE_SHA1 | cut -c -7)"
          force-new-deployment: true
          verify-revision-is-deployed: true
          max-poll-attempts: 6
      - run:
          name: Send Failed Slack Notifications 
          command: curl -X POST -H 'Content-type:application/json' --data '{"text":"Enter success message"}' https://hooks.slack.com/services/*/*
          when: on_fail
      - run:
          name: Send Success Slack Notifications
          command: curl -X POST -H 'Content-type:application/json' --data '{"text":"Enter fail message"}' https://hooks.slack.com/services/*/*
          when: on_success

workflows:
  ecr-ecs-ci-cd:
    jobs:
      - build_push_deploy_notify

So i have the above circle config file but the linter wont let me save it.
I want to send slack messages on failure and success.
There’s no official support to it so i want if there’s any workaround.

Here is the error that pops up:

Moves these jobs to the workflows: section:

workflows:
  ecr-ecs-ci-cd:
    jobs:
      - aws-ecr/build-and-push-image:
           repo: "${AWS_RESOURCE_NAME_PREFIX}"
           tag: "$(git rev-parse --short HEAD)"
      - aws-ecs/deploy-service-update:
           requires:
             - aws-ecr/build-and-push-image # only run this job once aws-ecr/build-and-push-image has completed
           family: "test-cluster-td"
           cluster-name: "test-cluster"
           container-image-name-updates: "container=test-container,image-and-tag=${AWS_ECR_ACCOUNT_URL}/${AWS_RESOURCE_NAME_PREFIX}:$(echo $CIRCLE_SHA1 | cut -c -7)"
           force-new-deployment: true
           verify-revision-is-deployed: true
           max-poll-attempts: 6

The issue is that the - aws-ecr/build-and-push-image: and - aws-ecs/deploy-service-update: are Jobs within the orbs so they’re already defined and you just call them from workflows. Your config is failing because you’re essentially nesting those jobs within the build_push_deploy_notify: job which is not allowed and is why the linter is balking at this config. See the orb usage examples for those jobs here.

Also there is a slack orb that you can also leverage instead of the curl commands. Check out the slack orb here. The slack orb should help execute the notification processes much easier

1 Like

Hi @punkdata , Thanks for the response but i cannot seem to add slack orb and use it when i do so i don’t know how to fix it in? like the slack/notify method how to use that in my above case where to put that ? can you update your answer with slack orb in it with on_success and on_fail events? So i can send notifications?
Thanks

Can you share your config file here? It’s easier to debug if I can see what your working with. thanks

1 Like

@punkdata sure ill do that in morning.

1 Like