@@ -36,6 +36,202 @@ EC2 Image Builder supports AWS-managed components for common tasks, AWS Marketpl
3636that you create. Components run during specific workflow phases: build and validate phases during the build stage, and
3737test phase during the test stage.
3838
39+ ### Image Recipe
40+
41+ #### Image Recipe Basic Usage
42+
43+ Create an image recipe with the required base image:
44+
45+ ``` ts
46+ const imageRecipe = new imagebuilder .ImageRecipe (this , ' MyImageRecipe' , {
47+ baseImage: imagebuilder .BaseImage .fromSsmParameterName (
48+ ' /aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64'
49+ )
50+ });
51+ ```
52+
53+ #### Image Recipe Base Images
54+
55+ To create a recipe, you have to select a base image to build and customize from. This base image can be referenced from
56+ various sources, such as from SSM parameters, AWS Marketplace products, and AMI IDs directly.
57+
58+ ##### SSM Parameters
59+
60+ Using SSM parameter references:
61+
62+ ``` ts
63+ const imageRecipe = new imagebuilder .ImageRecipe (this , ' SsmImageRecipe' , {
64+ baseImage: imagebuilder .BaseImage .fromSsmParameterName (
65+ ' /aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64'
66+ )
67+ });
68+
69+ // Using an SSM parameter construct
70+ const parameter = ssm .StringParameter .fromStringParameterName (
71+ this ,
72+ ' BaseImageParameter' ,
73+ ' /aws/service/ami-windows-latest/Windows_Server-2022-English-Full-Base'
74+ );
75+ const windowsRecipe = new imagebuilder .ImageRecipe (this , ' WindowsImageRecipe' , {
76+ baseImage: imagebuilder .BaseImage .fromSsmParameter (parameter )
77+ });
78+ ```
79+
80+ ##### AMI IDs
81+
82+ When you have a specific AMI to use:
83+
84+ ``` ts
85+ const imageRecipe = new imagebuilder .ImageRecipe (this , ' AmiImageRecipe' , {
86+ baseImage: imagebuilder .BaseImage .fromAmiId (' ami-12345678' )
87+ });
88+ ```
89+
90+ ##### Marketplace Images
91+
92+ For marketplace base images:
93+
94+ ``` ts
95+ const imageRecipe = new imagebuilder .ImageRecipe (this , ' MarketplaceImageRecipe' , {
96+ baseImage: imagebuilder .BaseImage .fromMarketplaceProductId (' prod-1234567890abcdef0' )
97+ });
98+ ```
99+
100+ #### Image Recipe Components
101+
102+ Components from various sources, such as custom-owned, AWS-owned, or AWS Marketplace-owned, can optionally be included
103+ in recipes. For parameterized components, you are able to provide the parameters to use in the recipe, which will be
104+ applied during the image build when executing components.
105+
106+ ##### Custom Components in Image Recipes
107+
108+ Add your own components to the recipe:
109+
110+ ``` ts
111+ const customComponent = new imagebuilder .Component (this , ' MyComponent' , {
112+ platform: imagebuilder .Platform .LINUX ,
113+ data: imagebuilder .ComponentData .fromJsonObject ({
114+ schemaVersion: imagebuilder .ComponentSchemaVersion .V1_0 ,
115+ phases: [
116+ {
117+ name: imagebuilder .ComponentPhaseName .BUILD ,
118+ steps: [
119+ {
120+ name: ' install-app' ,
121+ action: imagebuilder .ComponentAction .EXECUTE_BASH ,
122+ inputs: {
123+ commands: [' yum install -y my-application' ]
124+ }
125+ }
126+ ]
127+ }
128+ ]
129+ })
130+ });
131+
132+ const imageRecipe = new imagebuilder .ImageRecipe (this , ' ComponentImageRecipe' , {
133+ baseImage: imagebuilder .BaseImage .fromSsmParameterName (
134+ ' /aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64'
135+ ),
136+ components: [
137+ {
138+ component: customComponent
139+ }
140+ ]
141+ });
142+ ```
143+
144+ ##### AWS-Managed Components in Image Recipes
145+
146+ Use pre-built AWS components:
147+
148+ ``` ts
149+ const imageRecipe = new imagebuilder .ImageRecipe (this , ' AwsManagedImageRecipe' , {
150+ baseImage: imagebuilder .BaseImage .fromSsmParameterName (
151+ ' /aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64'
152+ ),
153+ components: [
154+ {
155+ component: imagebuilder .AwsManagedComponent .updateOS (this , ' UpdateOS' , {
156+ platform: imagebuilder .Platform .LINUX
157+ })
158+ },
159+ {
160+ component: imagebuilder .AwsManagedComponent .awsCliV2 (this , ' AwsCli' , {
161+ platform: imagebuilder .Platform .LINUX
162+ })
163+ }
164+ ]
165+ });
166+ ```
167+
168+ ##### Component Parameters in Image Recipes
169+
170+ Pass parameters to components that accept them:
171+
172+ ``` ts
173+ const parameterizedComponent = imagebuilder .Component .fromComponentName (
174+ this ,
175+ ' ParameterizedComponent' ,
176+ ' my-parameterized-component'
177+ );
178+
179+ const imageRecipe = new imagebuilder .ImageRecipe (this , ' ParameterizedImageRecipe' , {
180+ baseImage: imagebuilder .BaseImage .fromSsmParameterName (
181+ ' /aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64'
182+ ),
183+ components: [
184+ {
185+ component: parameterizedComponent ,
186+ parameters: {
187+ environment: imagebuilder .ComponentParameterValue .fromString (' production' ),
188+ version: imagebuilder .ComponentParameterValue .fromString (' 1.0.0' )
189+ }
190+ }
191+ ]
192+ });
193+ ```
194+
195+ #### Image Recipe Configuration
196+
197+ ##### Block Device Configuration
198+
199+ Configure storage for the build instance:
200+
201+ ``` ts
202+ const imageRecipe = new imagebuilder .ImageRecipe (this , ' BlockDeviceImageRecipe' , {
203+ baseImage: imagebuilder .BaseImage .fromSsmParameterName (
204+ ' /aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64'
205+ ),
206+ blockDevices: [
207+ {
208+ deviceName: ' /dev/sda1' ,
209+ volume: ec2 .BlockDeviceVolume .ebs (100 , {
210+ encrypted: true ,
211+ volumeType: ec2 .EbsDeviceVolumeType .GENERAL_PURPOSE_SSD_GP3
212+ })
213+ }
214+ ]
215+ });
216+ ```
217+
218+ ##### AMI Tagging
219+
220+ Tag the output AMI:
221+
222+ ``` ts
223+ const imageRecipe = new imagebuilder .ImageRecipe (this , ' TaggedImageRecipe' , {
224+ baseImage: imagebuilder .BaseImage .fromSsmParameterName (
225+ ' /aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-x86_64'
226+ ),
227+ amiTags: {
228+ Environment: ' Production' ,
229+ Application: ' WebServer' ,
230+ Owner: ' DevOps Team'
231+ }
232+ });
233+ ```
234+
39235### Component
40236
41237A component defines the sequence of steps required to customize an instance during image creation (build component) or
0 commit comments