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