Can I use an orb as a step?

Hi!
I’m a n00b, so apologies in advance if this is a dumb question.
I’m trying to create two multi-architecture builds from a singe pipeline (arm and x86) The easiest way I can think of, would be to spin up two machines and build on the separate machines and then use the aws-ecr orb to push both images into aws ecr.

The problem I am having is that it appears that the aws-ecr orb needs to be a job and not a step within the job.

The error I am getting is

`Error calling workflow: 'deploy'Error calling job: 'arm-build'Cannot find a definition for command named aws-ecr/build_and_push_image`. 

I have also pasted the config.yml file below. It doesn’t work, but maybe it will give you a hint as to what kind of shenanigans that I’m up to!

Thank you!

version: 2.1

orbs: 
  aws-ecr: circleci/aws-ecr@8.1.2

jobs:

  arm-build:
    machine:
      image: ubuntu-2004:current
    resource_class: arm.medium
    steps:
      - checkout
      - aws-ecr/build_and_push_image:
          account-url: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com"
          repo: "${AWS_RESOURCE_NAME_PREFIX}"
          region: ${AWS_DEFAULT_REGION}
          tag: "arm-${CIRCLE_SHA1}"

  x86-build:
    machine:
      image: ubuntu-2004:current
    resource_class: x86.medium
    steps:
      - checkout
      - aws-ecr/build_and_push_image:
          account-url: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com"
          repo: "${AWS_RESOURCE_NAME_PREFIX}"
          region: ${AWS_DEFAULT_REGION}
          tag: "x86-${CIRCLE_SHA1}"

workflows:
  version: 2
  deploy:
    jobs:
      - arm-build
      - x86-build

Hi, the command is build-and-push-image not build_and_push_image

So dashes not underscore.

Once you have tidied the typo up the next thing you will need to check is that you are providing values for aws-access-key-id and aws-secret-access-key

So I fixed the command name and got a new error:

Error calling workflow: 'deploy'Error calling job: 'arm-build'Error calling command: 'aws-ecr/build-and-push-image'Unexpected argument(s): account-url

It wasn’t a typo, I got it from the CircleCI github:

      - aws-ecr/build_and_push_image:
          account-url: "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com"
          repo: "${AWS_RESOURCE_NAME_PREFIX}"
          region: ${AWS_DEFAULT_REGION}
          tag: "${CIRCLE_SHA1}"

There have been a lot of changes to the orb between the 0.0.2 release used in that example and the 8.1.2 release you are currently trying to use.

It would be best if you ignore that example as it is very out of date.

1 Like

You can say that again, thanks @rit1010 !