Trying to use the AWS cli (or any) CircleCI orb for the first time, plus how to run shell scripts...help me understand

I can certainly try.

Hello @thekatertot :wave:

The example you are showing above does not seem to contain orbs, though orbs are not at all required to do anything. Orbs can however make a lot of what you have here easier (potentially).

You can absolutely use more than a single orb and intermix them. Each orb will provide a set of useful components that can be put together for instance to create a job for the task you are attempting.

Here is a simple example a manual nodejs testing job using the node orb’s “install-packages” command and the executor.

version: 2.1
orbs:
  node: 'circleci/node:x.y' #importing the node orb here. The version referrs to the version of the orb.
jobs:
  test:
    executor:
      name: node/default # From the node orb, provides a nodejs docker image
      tag: '13'
    steps:
      - checkout #standard CircleCI command to checkout code
      - node/install-packages # from the node orb. Installs and caches our npm modules
      - run:
          command: npm run test
workflows:
  test_my_app:
    jobs:
      - test

Registry page for the node orb: https://circleci.com/orbs/registry/orb/circleci/node#quick-start

Now, if we wanted to use the AWS CLI, we have an orb for that as well.
This useage example demonstrates how we can install the AWS CLI and set up our credentials with a single command “aws/setup”
https://circleci.com/orbs/registry/orb/circleci/aws-cli#usage-install-aws-cli

steps:
      - checkout
      - aws-cli/setup:
          profile-name: example
      - run: echo "Run your code here"

To clear up the question about what executor to use, that is entirely up to you. You dont have to use the executor from either of these orbs, you could simply just use the commands provided. If you attempted to use the “install-packages” command from the node orb in an environment that did not have node install though, there would obviously be an error, so for that reason, the Node orb provides this executor for your convenience, but it is not required.

The executor in the AWS CLI orb provides by default, a docker image with both Python and Node installed, which is typical for some serverless applications deployed to AWS for instance.
https://circleci.com/orbs/registry/orb/circleci/aws-cli#executors-default

So lets look at our config example again, a little closer to what you asked for.

version: 2.1
orbs:
  node: 'circleci/node:x.y' #importing the node orb here. The version referrs to the version of the orb.
  aws-cli: circleci/aws-cli@x.y
jobs:
  test:
    executor:
      name: node/default # From the node orb, provides a nodejs docker image
      tag: '13'
    steps:
      - checkout #standard CircleCI command to checkout code
      - aws-cli/setup
      - node/install-packages # from the node orb. Installs and caches our npm modules
      - run:
          name: my custom script
          command: |
              echo "my script"
      - run:
          command: npm run test
workflows:
  test_my_app:
    jobs:
      - test

To get an idea of how we use shell scrips in commands and such, you can take a look at the source code of the node orb itself, as all orbs are actually just config.

Hope that answered the majority of your questions. Let me know if that clears everything up :+1:

2 Likes