Configure image pipeline workflows in Image Builder
With image workflows, you can customize the workflows that your pipeline runs to build, test, and distribute images according to your needs. The workflows that you define run within the context of the Image Builder workflow framework. For more information about the stages that make up the workflow framework, see Manage build, test, and distribution workflows for Image Builder images.
- Build workflow
-
Build workflows run during the
Buildstage of the workflow framework. You can specify only one build workflow for your pipeline. Or you can skip the build entirely to configure a test-only pipeline. - Test workflow
-
Test workflows run during the
Teststage of the workflow framework. You can add one or more test workflows to your pipeline, up to the limit of ten workflows total, which also counts your build and distribution workflows. Test workflows can run in parallel or one at a time, depending on how you define your test groups. You can also skip tests entirely if you only want your pipeline to build. - Distribution workflow
-
Distribution workflows run during the
Distributionstage of the workflow framework. A distribution workflow is optional. If you do not specify one, Image Builder still distributes your AMI by running the distribution configuration that you attach to the pipeline or image. Specify a distribution workflow when you want to override that distribution configuration with different distribution settings, or to gain more visibility into the distribution process. You can specify one distribution workflow for your pipeline. If you build container images and do not specify a distribution workflow, Image Builder adds the Amazon managed container-distribution workflow for you.
Define test groups for test workflows
You define test workflows within test groups. You can run multiple test workflows for your pipeline. The combined limit is ten workflows total, which includes your build and distribution workflows. You decide whether to run the test workflows in a specific order or to run as many as possible at the same time. How they run depends on how you define your test groups. The following scenarios demonstrate several ways that you can define your test workflows.
Note
The parallelGroup and onFailure settings apply only to test
workflows. Image Builder rejects them on a build or distribution workflow with an
InvalidParameterCombinationException.
How test groups run
Image Builder runs your test workflows in test groups. It runs the groups one at a time. The test workflows within a single group run at the same time (in parallel). Image Builder runs up to five test workflows at the same time; if a group has more than five, Image Builder starts the next test workflow as each one finishes. A test workflow that isn't part of a group runs on its own.
How you define test groups depends on whether you use the console or the AWS CLI and API. Select the tab that matches the method you use.
Scenario 1: Run one test workflow at a time
To run all of your test workflows one at a time, configure a separate test group for each test workflow, up to the combined limit of ten workflows total (which includes your build and distribution workflows). Image Builder runs the test groups one at a time. This is one way to ensure that your test workflows run one at a time in a specific order.
Scenario 2: Run multiple test workflows at the same time
If the order doesn't matter, and you want to run as many test workflows as possible at the same time, you can configure a single test group and put the maximum number of test workflows in it. Image Builder starts up to five test workflows at the same time, and starts additional test workflows as others complete. If your goal is to run your test workflows as fast as possible, this is one way to do it.
Scenario 3: Mix and match
If you have a mixed scenario, with some test workflows that can run at the same time and some that should run one at a time, you can configure your test groups to accomplish this goal. The only limit to how you configure your test groups is the maximum number of test workflows that can run for your pipeline
Set workflow parameters in an Image Builder pipeline from the console
Workflow parameters function the same way for build, test, and distribution workflows. When you create or update a pipeline, you select the build, test, and distribution workflows that you want to include. If you defined parameters in the workflow document for a workflow that you selected, Image Builder displays them in the Parameters panel. The panel is hidden for workflows that do not have parameters defined.
Each parameter displays the following attributes that your workflow document defined:
Name (not editable) – The name of the parameter.
Type (not editable) – The data type for the parameter value.
-
Value – The value for the parameter. You can edit the parameter value to set it for your pipeline.
Specify the IAM service role that Image Builder uses to run workflow actions
When you attach custom image workflows to your pipeline, or when you set a logging configuration, you must also specify an execution role. This is the IAM role that Image Builder assumes to run your workflow actions. The role must trust the Image Builder service principal. For the required permissions, see the workflow service access information that follows.
To run image workflows, Image Builder needs permission to perform workflow actions. You grant this permission with an execution role that Image Builder assumes on your behalf. You assign the execution role as follows.
Important
We recommend that you don't pass the AWSServiceRoleForImageBuilder service-linked role as your execution role. Instead, create a custom IAM role and attach the EC2ImageBuilderExecutionPolicy AWS managed policy. This policy grants the same permissions that Image Builder needs to call AWS services on your behalf. Using a custom role gives you full control over the permissions that Image Builder uses. It also keeps your service control policies (SCPs) and resource control policies (RCPs) in effect for operations that Image Builder performs on your behalf.
-
Console – In the pipeline wizard Step 3 Define image creation process, select your custom role from the IAM role list in the Service access panel.
-
Image Builder API – In the CreateImage action request, specify your custom role as the value for the
executionRoleparameter.
To create a custom execution role, see Creating a role to delegate permissions to an AWS service in the AWS Identity and Access Management User Guide.
Associate workflows with a pipeline
To associate custom build, test, and distribution image workflows with your pipeline, select the tab that matches the method you want to use.