Pass Params in ImageBuilder Component ExecutePowerShell Action

0

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.

已提問 10 個月前檢視次數 279 次
1 個回答
0

Hello,

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: https://docs.aws.amazon.com/imagebuilder/latest/userguide/manage-component-parameters.html

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:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-imagerecipe.html#aws-resource-imagebuilder-imagerecipe--examples

AWS
支援工程師
Sonal_A
已回答 10 個月前
  • 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?

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南