ec2-image-builder-roadmap icon indicating copy to clipboard operation
ec2-image-builder-roadmap copied to clipboard

[Image Builder] [AWSTOE]: Add conditional operators for recipes

Open tiilikainen opened this issue 5 months ago • 0 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Tell us about your request I would like conditional operators to be added to recipes (similar, perhaps, to how if statements work in the new Image Workflow resource).

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard? I am trying to reduce the amount of ExecuteBash module calls being used in our AWSTOE documents. Currently, any time there is any sort of conditional logic required in our component, we have to resort to implementing that block of code as pure Bash instead of AWSTOE module calls.

Unless this feature is implemented, we are largely blocked from reimplementing our components in AWSTOE, and we are unable to modularize our code (e.g. extract and reuse common functionality).

Unfortunately, the new Image Workflow functionality is not usable for this use case because it will only execute an entire recipe as written (i.e. you cannot inject conditional logic into the middle of recipe execution).

Are you currently working around this issue? Right now, every single one of our component documents contains only one step. The rest of the logic is expressed in an external Bash script.

Below is an example of a complete component that we are currently using.

name: LinuxServices
description: Install linux services
schemaVersion: 1.0

phases:
  - name: build
    steps:
      - name: ExecuteServicesScript
        action: ExecuteBash
        inputs:
         commands:
          - |
            . ./set-environment-variables.sh
            sudo -E bash setup-services.sh

Our first component downloads our bash scripts, and the subsequent components just execute them in sequence.

Additional context We build over 60 different images, and our pre-Image Builder code base consists of these Bash scripts that are being called by the newer components. We would eventually like to do away with these Bash scripts without increasing the amount of time it takes to maintain the actual code.

tiilikainen avatar Jan 09 '24 18:01 tiilikainen