Pass Params in ImageBuilder Component ExecutePowerShell Action


I am referring to the link aws-resource-imagebuilder-component--examples

I am trying to create a Component for ImageBuilder for executing a PowerShell script. However, I am not sure how to pass parameters or arguments to this. Please help with examples / steps.

Although, I saw this link image-builder-supports-parameters-components-creating-custom-images, there are no details.

asked 10 months ago269 views
1 Answer


Using Resource type "AWS::ImageBuilder::Component" you can create a new component that can be used to build, validate, test, and assess your image. The component is based on a YAML document that you can specify either inline using "Data" property or specify a URL that points to a YAML document file stored in Amazon S3, using the "Uri" property. Within the YAML document, you can specify your component parameters. Please refer the following document for more details on the YAML document of the ImageBuilder Component:

Within the YAML document, in the ExecutePowerShell action module you can specify either "commands" or "file" to execute a list of inline PowerShell commands or PowerShell script.

Now, once you have defined the ImageBuilder component with parameters, you can pass the parameters along with their value when creating the ImageRecipe resource using ComponentArn and Parameters property of Components. Please refer the examples of ImageRecipe resource in the following document:

answered 10 months ago
  • Thank you. I found the above documentation links just a while ago and was about to edit / remove my question. Anyways, I have a few more questions regarding Image Builder. Please help with those also.

    1. In AWS::ImageBuilder::Recipe, there is a ParentImage property (as per documentation), taking either an Image ARN or an AMI ID. How can I get the ARN of My AMI, if I have built a custom one. Else, can I use a wildcard card AMI name?
    2. How to pass sensitive information like passwords, keys etc as component parameters so that they don't get output anywhere (including CloudWatch or S3 logs)?
    3. Also, how to pass parameters to a script file? Is the below syntax valid?
    • name: ExecuteScript action: ExecutePowerShell onFailure: Abort maxAttempts: 3 inputs: commands: - cd c:\temp - .\run_myscript.ps1 -param1 {{ param1}} -password {{ password }}
    1. Component Parameters support only string type and not others like number, boolean etc?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions