Tutorial: Create a custom component with input parameters
You can manage Image Builder components, including creating and setting component parameters, directly from the EC2 Image Builder console, from the AWS CLI, or from the Image Builder API or SDKs. In this section, we'll cover creating and using parameters in your component, and setting component parameters through the Image Builder console and AWS CLI commands at runtime.
Important
Component parameters are plain text values, and are logged in AWS CloudTrail. We recommend that you use AWS Secrets Manager or the AWS Systems Manager Parameter Store to store your secrets. For more information about Secrets Manager, see What is Secrets Manager? in the AWS Secrets Manager User Guide. For more information about AWS Systems Manager Parameter Store, see AWS Systems Manager Parameter Store in the AWS Systems Manager User Guide.
Use parameters in your YAML component document
To build a component, you must provide a YAML or JSON application component document. The document contains the code that runs during the phases and steps that you define to provide customization for your image. The recipe that references the component can set the parameters to customize the values at runtime, with default values that take effect if the parameter is not set to a specific value.
Create a component document with input parameters
This section shows you how to define and use input parameters in your YAML component document.
To create a YAML application component document that uses parameters and runs commands in your Image Builder build or test instances, follow the steps that match your image operating system:
For more information about the phases, steps, and syntax for AWSTOE application component documents, see Use documents in AWSTOE. For more information about parameters and their requirements, see the Parameters section of the Define and reference variables in AWSTOE page.
Create a component from the YAML component document
Whatever method you use to create an AWSTOE component, the YAML application component document is always required as a baseline.
-
To create a component directly from your YAML document with the Image Builder console, see Create a custom component from the console.
-
To create a component from the command line with the Image Builder create-component command, see Create a custom component from the AWS CLI. Replace the YAML document name in those examples with the name of your Hello World YAML document (
).hello-world-test.yaml
Set component parameters in an Image Builder recipe from the console
Setting component parameters works the same for image recipes and container recipes. When you create a new recipe, or a new version of a recipe, you choose which components to include from the Build components and Test components lists. The component lists include components that are applicable for the base operating system you chose for your image.
After you select a component, it is displayed in the Selected components section, directly under the component lists. Configuration options are shown for each component that is selected. If your component has input parameters defined, they are displayed as an expandable section called Input parameters.
The following parameter settings are shown for each parameter that's defined for your component:
Parameter name (not editable) – The name of the parameter.
Description (not editable) – The parameter description
Type (not editable) – The data type for the parameter value.
Value – The value for the parameter. If you are using this component for the first time in this recipe, and a default value was defined for the input parameter, the default value appears in the Value box with greyed-out text. If no other value is entered, Image Builder uses the default value.