@aws-cdk/aws-imagebuilder-alpha 2.226.0-alpha.0 → 2.227.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/.warnings.jsii.js CHANGED
@@ -1,3 +1,221 @@
1
+ function _aws_cdk_aws_imagebuilder_alpha_IComponent(p) {
2
+ }
3
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentProps(p) {
4
+ if (p == null)
5
+ return;
6
+ visitedObjects.add(p);
7
+ try {
8
+ if (!visitedObjects.has(p.data))
9
+ _aws_cdk_aws_imagebuilder_alpha_ComponentData(p.data);
10
+ if (!visitedObjects.has(p.platform))
11
+ _aws_cdk_aws_imagebuilder_alpha_Platform(p.platform);
12
+ if (p.supportedOsVersions != null)
13
+ for (const o of p.supportedOsVersions)
14
+ if (!visitedObjects.has(o))
15
+ _aws_cdk_aws_imagebuilder_alpha_OSVersion(o);
16
+ }
17
+ finally {
18
+ visitedObjects.delete(p);
19
+ }
20
+ }
21
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentAttributes(p) {
22
+ }
23
+ function _aws_cdk_aws_imagebuilder_alpha_AwsManagedComponentAttributes(p) {
24
+ if (p == null)
25
+ return;
26
+ visitedObjects.add(p);
27
+ try {
28
+ if (!visitedObjects.has(p.platform))
29
+ _aws_cdk_aws_imagebuilder_alpha_Platform(p.platform);
30
+ }
31
+ finally {
32
+ visitedObjects.delete(p);
33
+ }
34
+ }
35
+ function _aws_cdk_aws_imagebuilder_alpha_AwsMarketplaceComponentAttributes(p) {
36
+ }
37
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentDocument(p) {
38
+ if (p == null)
39
+ return;
40
+ visitedObjects.add(p);
41
+ try {
42
+ if (p.phases != null)
43
+ for (const o of p.phases)
44
+ if (!visitedObjects.has(o))
45
+ _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentPhase(o);
46
+ if (!visitedObjects.has(p.schemaVersion))
47
+ _aws_cdk_aws_imagebuilder_alpha_ComponentSchemaVersion(p.schemaVersion);
48
+ if (p.constants != null)
49
+ for (const o of Object.values(p.constants))
50
+ if (!visitedObjects.has(o))
51
+ _aws_cdk_aws_imagebuilder_alpha_ComponentConstantValue(o);
52
+ if (p.parameters != null)
53
+ for (const o of Object.values(p.parameters))
54
+ if (!visitedObjects.has(o))
55
+ _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentParameterDefinition(o);
56
+ }
57
+ finally {
58
+ visitedObjects.delete(p);
59
+ }
60
+ }
61
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentPhase(p) {
62
+ if (p == null)
63
+ return;
64
+ visitedObjects.add(p);
65
+ try {
66
+ if (!visitedObjects.has(p.name))
67
+ _aws_cdk_aws_imagebuilder_alpha_ComponentPhaseName(p.name);
68
+ if (p.steps != null)
69
+ for (const o of p.steps)
70
+ if (!visitedObjects.has(o))
71
+ _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentStep(o);
72
+ }
73
+ finally {
74
+ visitedObjects.delete(p);
75
+ }
76
+ }
77
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentStep(p) {
78
+ if (p == null)
79
+ return;
80
+ visitedObjects.add(p);
81
+ try {
82
+ if (!visitedObjects.has(p.action))
83
+ _aws_cdk_aws_imagebuilder_alpha_ComponentAction(p.action);
84
+ if (!visitedObjects.has(p.inputs))
85
+ _aws_cdk_aws_imagebuilder_alpha_ComponentStepInputs(p.inputs);
86
+ if (!visitedObjects.has(p.if))
87
+ _aws_cdk_aws_imagebuilder_alpha_ComponentStepIfCondition(p.if);
88
+ if (!visitedObjects.has(p.loop))
89
+ _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentLoop(p.loop);
90
+ if (!visitedObjects.has(p.onFailure))
91
+ _aws_cdk_aws_imagebuilder_alpha_ComponentOnFailure(p.onFailure);
92
+ }
93
+ finally {
94
+ visitedObjects.delete(p);
95
+ }
96
+ }
97
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentLoop(p) {
98
+ if (p == null)
99
+ return;
100
+ visitedObjects.add(p);
101
+ try {
102
+ if (!visitedObjects.has(p.for))
103
+ _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentForLoop(p.for);
104
+ }
105
+ finally {
106
+ visitedObjects.delete(p);
107
+ }
108
+ }
109
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentForLoop(p) {
110
+ }
111
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentConstantValue(p) {
112
+ }
113
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentParameterDefinition(p) {
114
+ if (p == null)
115
+ return;
116
+ visitedObjects.add(p);
117
+ try {
118
+ if (!visitedObjects.has(p.type))
119
+ _aws_cdk_aws_imagebuilder_alpha_ComponentParameterType(p.type);
120
+ }
121
+ finally {
122
+ visitedObjects.delete(p);
123
+ }
124
+ }
125
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentAction(p) {
126
+ }
127
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentOnFailure(p) {
128
+ }
129
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentParameterType(p) {
130
+ }
131
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentPhaseName(p) {
132
+ }
133
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentSchemaVersion(p) {
134
+ }
135
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentStepInputs(p) {
136
+ }
137
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentStepIfCondition(p) {
138
+ }
139
+ function _aws_cdk_aws_imagebuilder_alpha_ComponentData(p) {
140
+ }
141
+ function _aws_cdk_aws_imagebuilder_alpha_S3ComponentData(p) {
142
+ }
143
+ function _aws_cdk_aws_imagebuilder_alpha_AwsManagedComponent(p) {
144
+ }
145
+ function _aws_cdk_aws_imagebuilder_alpha_AwsMarketplaceComponent(p) {
146
+ }
147
+ function _aws_cdk_aws_imagebuilder_alpha_Component(p) {
148
+ }
149
+ function _aws_cdk_aws_imagebuilder_alpha_IDistributionConfiguration(p) {
150
+ }
151
+ function _aws_cdk_aws_imagebuilder_alpha_AmiLaunchPermission(p) {
152
+ }
153
+ function _aws_cdk_aws_imagebuilder_alpha_SSMParameterConfigurations(p) {
154
+ }
155
+ function _aws_cdk_aws_imagebuilder_alpha_LaunchTemplateConfiguration(p) {
156
+ }
157
+ function _aws_cdk_aws_imagebuilder_alpha_FastLaunchConfiguration(p) {
158
+ }
159
+ function _aws_cdk_aws_imagebuilder_alpha_AmiDistribution(p) {
160
+ if (p == null)
161
+ return;
162
+ visitedObjects.add(p);
163
+ try {
164
+ if (!visitedObjects.has(p.amiLaunchPermission))
165
+ _aws_cdk_aws_imagebuilder_alpha_AmiLaunchPermission(p.amiLaunchPermission);
166
+ if (p.fastLaunchConfigurations != null)
167
+ for (const o of p.fastLaunchConfigurations)
168
+ if (!visitedObjects.has(o))
169
+ _aws_cdk_aws_imagebuilder_alpha_FastLaunchConfiguration(o);
170
+ if (p.launchTemplates != null)
171
+ for (const o of p.launchTemplates)
172
+ if (!visitedObjects.has(o))
173
+ _aws_cdk_aws_imagebuilder_alpha_LaunchTemplateConfiguration(o);
174
+ if (p.ssmParameters != null)
175
+ for (const o of p.ssmParameters)
176
+ if (!visitedObjects.has(o))
177
+ _aws_cdk_aws_imagebuilder_alpha_SSMParameterConfigurations(o);
178
+ }
179
+ finally {
180
+ visitedObjects.delete(p);
181
+ }
182
+ }
183
+ function _aws_cdk_aws_imagebuilder_alpha_ContainerDistribution(p) {
184
+ if (p == null)
185
+ return;
186
+ visitedObjects.add(p);
187
+ try {
188
+ if (!visitedObjects.has(p.containerRepository))
189
+ _aws_cdk_aws_imagebuilder_alpha_Repository(p.containerRepository);
190
+ }
191
+ finally {
192
+ visitedObjects.delete(p);
193
+ }
194
+ }
195
+ function _aws_cdk_aws_imagebuilder_alpha_DistributionConfigurationProps(p) {
196
+ if (p == null)
197
+ return;
198
+ visitedObjects.add(p);
199
+ try {
200
+ if (p.amiDistributions != null)
201
+ for (const o of p.amiDistributions)
202
+ if (!visitedObjects.has(o))
203
+ _aws_cdk_aws_imagebuilder_alpha_AmiDistribution(o);
204
+ if (p.containerDistributions != null)
205
+ for (const o of p.containerDistributions)
206
+ if (!visitedObjects.has(o))
207
+ _aws_cdk_aws_imagebuilder_alpha_ContainerDistribution(o);
208
+ }
209
+ finally {
210
+ visitedObjects.delete(p);
211
+ }
212
+ }
213
+ function _aws_cdk_aws_imagebuilder_alpha_RepositoryService(p) {
214
+ }
215
+ function _aws_cdk_aws_imagebuilder_alpha_Repository(p) {
216
+ }
217
+ function _aws_cdk_aws_imagebuilder_alpha_DistributionConfiguration(p) {
218
+ }
1
219
  function _aws_cdk_aws_imagebuilder_alpha_IInfrastructureConfiguration(p) {
2
220
  }
3
221
  function _aws_cdk_aws_imagebuilder_alpha_HttpTokens(p) {
@@ -32,6 +250,10 @@ function _aws_cdk_aws_imagebuilder_alpha_InfrastructureConfigurationProps(p) {
32
250
  }
33
251
  function _aws_cdk_aws_imagebuilder_alpha_InfrastructureConfiguration(p) {
34
252
  }
253
+ function _aws_cdk_aws_imagebuilder_alpha_Platform(p) {
254
+ }
255
+ function _aws_cdk_aws_imagebuilder_alpha_OSVersion(p) {
256
+ }
35
257
  function print(name, deprecationMessage) {
36
258
  const deprecated = process.env.JSII_DEPRECATED;
37
259
  const deprecationMode = ["warn", "fail", "quiet"].includes(deprecated) ? deprecated : "warn";
@@ -68,4 +290,4 @@ class DeprecationError extends Error {
68
290
  });
69
291
  }
70
292
  }
71
- module.exports = { print, getPropertyDescriptor, DeprecationError, _aws_cdk_aws_imagebuilder_alpha_IInfrastructureConfiguration, _aws_cdk_aws_imagebuilder_alpha_HttpTokens, _aws_cdk_aws_imagebuilder_alpha_Tenancy, _aws_cdk_aws_imagebuilder_alpha_InfrastructureConfigurationLogging, _aws_cdk_aws_imagebuilder_alpha_InfrastructureConfigurationProps, _aws_cdk_aws_imagebuilder_alpha_InfrastructureConfiguration };
293
+ module.exports = { print, getPropertyDescriptor, DeprecationError, _aws_cdk_aws_imagebuilder_alpha_IComponent, _aws_cdk_aws_imagebuilder_alpha_ComponentProps, _aws_cdk_aws_imagebuilder_alpha_ComponentAttributes, _aws_cdk_aws_imagebuilder_alpha_AwsManagedComponentAttributes, _aws_cdk_aws_imagebuilder_alpha_AwsMarketplaceComponentAttributes, _aws_cdk_aws_imagebuilder_alpha_ComponentDocument, _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentPhase, _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentStep, _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentLoop, _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentForLoop, _aws_cdk_aws_imagebuilder_alpha_ComponentConstantValue, _aws_cdk_aws_imagebuilder_alpha_ComponentDocumentParameterDefinition, _aws_cdk_aws_imagebuilder_alpha_ComponentAction, _aws_cdk_aws_imagebuilder_alpha_ComponentOnFailure, _aws_cdk_aws_imagebuilder_alpha_ComponentParameterType, _aws_cdk_aws_imagebuilder_alpha_ComponentPhaseName, _aws_cdk_aws_imagebuilder_alpha_ComponentSchemaVersion, _aws_cdk_aws_imagebuilder_alpha_ComponentStepInputs, _aws_cdk_aws_imagebuilder_alpha_ComponentStepIfCondition, _aws_cdk_aws_imagebuilder_alpha_ComponentData, _aws_cdk_aws_imagebuilder_alpha_S3ComponentData, _aws_cdk_aws_imagebuilder_alpha_AwsManagedComponent, _aws_cdk_aws_imagebuilder_alpha_AwsMarketplaceComponent, _aws_cdk_aws_imagebuilder_alpha_Component, _aws_cdk_aws_imagebuilder_alpha_IDistributionConfiguration, _aws_cdk_aws_imagebuilder_alpha_AmiLaunchPermission, _aws_cdk_aws_imagebuilder_alpha_SSMParameterConfigurations, _aws_cdk_aws_imagebuilder_alpha_LaunchTemplateConfiguration, _aws_cdk_aws_imagebuilder_alpha_FastLaunchConfiguration, _aws_cdk_aws_imagebuilder_alpha_AmiDistribution, _aws_cdk_aws_imagebuilder_alpha_ContainerDistribution, _aws_cdk_aws_imagebuilder_alpha_DistributionConfigurationProps, _aws_cdk_aws_imagebuilder_alpha_RepositoryService, _aws_cdk_aws_imagebuilder_alpha_Repository, _aws_cdk_aws_imagebuilder_alpha_DistributionConfiguration, _aws_cdk_aws_imagebuilder_alpha_IInfrastructureConfiguration, _aws_cdk_aws_imagebuilder_alpha_HttpTokens, _aws_cdk_aws_imagebuilder_alpha_Tenancy, _aws_cdk_aws_imagebuilder_alpha_InfrastructureConfigurationLogging, _aws_cdk_aws_imagebuilder_alpha_InfrastructureConfigurationProps, _aws_cdk_aws_imagebuilder_alpha_InfrastructureConfiguration, _aws_cdk_aws_imagebuilder_alpha_Platform, _aws_cdk_aws_imagebuilder_alpha_OSVersion };
package/README.md CHANGED
@@ -36,6 +36,250 @@ EC2 Image Builder supports AWS-managed components for common tasks, AWS Marketpl
36
36
  that you create. Components run during specific workflow phases: build and validate phases during the build stage, and
37
37
  test phase during the test stage.
38
38
 
39
+ ### Component
40
+
41
+ A component defines the sequence of steps required to customize an instance during image creation (build component) or
42
+ test an instance launched from the created image (test component). Components are created from declarative YAML or JSON
43
+ documents that describe runtime configuration for building, validating, or testing instances. Components are included
44
+ when added to the image recipe or container recipe for an image build.
45
+
46
+ EC2 Image Builder supports AWS-managed components for common tasks, AWS Marketplace components, and custom components
47
+ that you create. Components run during specific workflow phases: build and validate phases during the build stage, and
48
+ test phase during the test stage.
49
+
50
+ #### Basic Usage
51
+
52
+ Create a component with the required properties: platform and component data.
53
+
54
+ ```ts
55
+ const component = new imagebuilder.Component(this, 'MyComponent', {
56
+ platform: imagebuilder.Platform.LINUX,
57
+ data: imagebuilder.ComponentData.fromJsonObject({
58
+ schemaVersion: imagebuilder.ComponentSchemaVersion.V1_0,
59
+ phases: [
60
+ {
61
+ name: imagebuilder.ComponentPhaseName.BUILD,
62
+ steps: [
63
+ {
64
+ name: 'install-app',
65
+ action: imagebuilder.ComponentAction.EXECUTE_BASH,
66
+ inputs: {
67
+ commands: ['echo "Installing my application..."', 'yum update -y'],
68
+ },
69
+ },
70
+ ],
71
+ },
72
+ ],
73
+ }),
74
+ });
75
+ ```
76
+
77
+ #### Component Data Sources
78
+
79
+ ##### Inline Component Data
80
+
81
+ Use `ComponentData.fromInline()` for existing YAML/JSON definitions:
82
+
83
+ ```ts
84
+ const component = new imagebuilder.Component(this, 'InlineComponent', {
85
+ platform: imagebuilder.Platform.LINUX,
86
+ data: imagebuilder.ComponentData.fromInline(`
87
+ name: my-component
88
+ schemaVersion: 1.0
89
+ phases:
90
+ - name: build
91
+ steps:
92
+ - name: update-os
93
+ action: ExecuteBash
94
+ inputs:
95
+ commands: ['yum update -y']
96
+ `)
97
+ });
98
+ ```
99
+
100
+ ##### JSON Object Component Data
101
+
102
+ Most developer-friendly approach using objects:
103
+
104
+ ```ts
105
+
106
+ const component = new imagebuilder.Component(this, 'JsonComponent', {
107
+ platform: imagebuilder.Platform.LINUX,
108
+ data: imagebuilder.ComponentData.fromJsonObject({
109
+ schemaVersion: imagebuilder.ComponentSchemaVersion.V1_0,
110
+ phases: [
111
+ {
112
+ name: imagebuilder.ComponentPhaseName.BUILD,
113
+ steps: [
114
+ {
115
+ name: 'configure-app',
116
+ action: imagebuilder.ComponentAction.CREATE_FILE,
117
+ inputs: {
118
+ path: '/etc/myapp/config.json',
119
+ content: '{"env": "production"}'
120
+ }
121
+ }
122
+ ]
123
+ }
124
+ ]
125
+ })
126
+ });
127
+ ```
128
+
129
+ ##### Structured Component Document
130
+
131
+ For type-safe, CDK-native definitions with enhanced properties like `timeout` and `onFailure`.
132
+
133
+ ###### Defining a component step
134
+
135
+ You can define steps in the component which will be executed in order when the component is applied:
136
+
137
+ ```ts
138
+ const step: imagebuilder.ComponentDocumentStep = {
139
+ name: 'configure-app',
140
+ action: imagebuilder.ComponentAction.CREATE_FILE,
141
+ inputs: imagebuilder.ComponentStepInputs.fromObject({
142
+ path: '/etc/myapp/config.json',
143
+ content: '{"env": "production"}'
144
+ })
145
+ };
146
+ ```
147
+
148
+ ###### Defining a component phase
149
+
150
+ Phases group steps together, which run in sequence when building, validating or testing in the component:
151
+
152
+ ```ts
153
+ const phase: imagebuilder.ComponentDocumentPhase = {
154
+ name: imagebuilder.ComponentPhaseName.BUILD,
155
+ steps: [
156
+ {
157
+ name: 'configure-app',
158
+ action: imagebuilder.ComponentAction.CREATE_FILE,
159
+ inputs: imagebuilder.ComponentStepInputs.fromObject({
160
+ path: '/etc/myapp/config.json',
161
+ content: '{"env": "production"}'
162
+ })
163
+ }
164
+ ]
165
+ };
166
+ ```
167
+
168
+ ###### Defining a component
169
+
170
+ The component data defines all steps across the provided phases to execute during the build:
171
+
172
+ ```ts
173
+ const component = new imagebuilder.Component(this, 'StructuredComponent', {
174
+ platform: imagebuilder.Platform.LINUX,
175
+ data: imagebuilder.ComponentData.fromComponentDocumentJsonObject({
176
+ schemaVersion: imagebuilder.ComponentSchemaVersion.V1_0,
177
+ phases: [
178
+ {
179
+ name: imagebuilder.ComponentPhaseName.BUILD,
180
+ steps: [
181
+ {
182
+ name: 'install-with-timeout',
183
+ action: imagebuilder.ComponentAction.EXECUTE_BASH,
184
+ timeout: Duration.minutes(10),
185
+ onFailure: imagebuilder.ComponentOnFailure.CONTINUE,
186
+ inputs: imagebuilder.ComponentStepInputs.fromObject({
187
+ commands: ['./install-script.sh']
188
+ })
189
+ }
190
+ ]
191
+ }
192
+ ]
193
+ })
194
+ });
195
+ ```
196
+
197
+ ##### S3 Component Data
198
+
199
+ For those components you want to upload or have uploaded to S3:
200
+
201
+ ```ts
202
+ // Upload a local file
203
+ const componentFromAsset = new imagebuilder.Component(this, 'AssetComponent', {
204
+ platform: imagebuilder.Platform.LINUX,
205
+ data: imagebuilder.ComponentData.fromAsset(this, 'ComponentAsset', './my-component.yml'),
206
+ });
207
+
208
+ // Reference an existing S3 object
209
+ const bucket = s3.Bucket.fromBucketName(this, 'ComponentBucket', 'my-components-bucket');
210
+ const componentFromS3 = new imagebuilder.Component(this, 'S3Component', {
211
+ platform: imagebuilder.Platform.LINUX,
212
+ data: imagebuilder.ComponentData.fromS3(bucket, 'components/my-component.yml'),
213
+ });
214
+ ```
215
+
216
+ #### Encrypt component data with a KMS key
217
+
218
+ You can encrypt component data with a KMS key, so that only principals with access to decrypt with the key are able to
219
+ access the component data.
220
+
221
+ ```ts
222
+ const component = new imagebuilder.Component(this, 'EncryptedComponent', {
223
+ platform: imagebuilder.Platform.LINUX,
224
+ kmsKey: new kms.Key(this, 'ComponentKey'),
225
+ data: imagebuilder.ComponentData.fromJsonObject({
226
+ schemaVersion: imagebuilder.ComponentSchemaVersion.V1_0,
227
+ phases: [
228
+ {
229
+ name: imagebuilder.ComponentPhaseName.BUILD,
230
+ steps: [
231
+ {
232
+ name: 'secure-setup',
233
+ action: imagebuilder.ComponentAction.EXECUTE_BASH,
234
+ inputs: {
235
+ commands: ['echo "This component data is encrypted with KMS"'],
236
+ },
237
+ },
238
+ ],
239
+ },
240
+ ],
241
+ }),
242
+ });
243
+ ```
244
+
245
+ #### AWS-Managed Components
246
+
247
+ AWS provides a collection of managed components for common tasks:
248
+
249
+ ```ts
250
+ // Install AWS CLI v2
251
+ const awsCliComponent = imagebuilder.AwsManagedComponent.awsCliV2(this, 'AwsCli', {
252
+ platform: imagebuilder.Platform.LINUX
253
+ });
254
+
255
+ // Update the operating system
256
+ const updateComponent = imagebuilder.AwsManagedComponent.updateOS(this, 'UpdateOS', {
257
+ platform: imagebuilder.Platform.LINUX
258
+ });
259
+
260
+ // Reference any AWS-managed component by name
261
+ const customAwsComponent = imagebuilder.AwsManagedComponent.fromAwsManagedComponentName(
262
+ this,
263
+ 'CloudWatchAgent',
264
+ 'amazon-cloudwatch-agent-linux'
265
+ );
266
+ ```
267
+
268
+ #### AWS Marketplace Components
269
+
270
+ You can reference AWS Marketplace components using the marketplace component name and its product ID:
271
+
272
+ ```ts
273
+ const marketplaceComponent = imagebuilder.AwsMarketplaceComponent.fromAwsMarketplaceComponentAttributes(
274
+ this,
275
+ 'MarketplaceComponent',
276
+ {
277
+ componentName: 'my-marketplace-component',
278
+ marketplaceProductId: 'prod-1234567890abcdef0',
279
+ }
280
+ );
281
+ ```
282
+
39
283
  ### Infrastructure Configuration
40
284
 
41
285
  Infrastructure configuration defines the compute resources and environment settings used during the image building
@@ -92,3 +336,146 @@ const infrastructureConfiguration = new imagebuilder.InfrastructureConfiguration
92
336
  }
93
337
  });
94
338
  ```
339
+
340
+ ### Distribution Configuration
341
+
342
+ Distribution configuration defines how and where your built images are distributed after successful creation. For AMIs,
343
+ this includes target AWS Regions, KMS encryption keys, account sharing permissions, License Manager associations, and
344
+ launch template configurations. For container images, it specifies the target Amazon ECR repositories across regions.
345
+ A distribution configuration can be associated with an image or an image pipeline to define these distribution settings
346
+ for image builds.
347
+
348
+ #### AMI Distributions
349
+
350
+ AMI distributions can be defined to copy and modify AMIs in different accounts and regions, and apply them to launch
351
+ templates, SSM parameters, etc.:
352
+
353
+ ```ts
354
+ const distributionConfiguration = new imagebuilder.DistributionConfiguration(this, 'DistributionConfiguration', {
355
+ distributionConfigurationName: 'test-distribution-configuration',
356
+ description: 'A Distribution Configuration',
357
+ amiDistributions: [
358
+ {
359
+ // Distribute AMI to us-east-2 and publish the AMI ID to an SSM parameter
360
+ region: 'us-east-2',
361
+ ssmParameters: [
362
+ {
363
+ parameter: ssm.StringParameter.fromStringParameterAttributes(this, 'CrossRegionParameter', {
364
+ parameterName: '/imagebuilder/ami',
365
+ forceDynamicReference: true
366
+ })
367
+ }
368
+ ]
369
+ }
370
+ ]
371
+ });
372
+
373
+ // For AMI-based image builds - add an AMI distribution in the current region
374
+ distributionConfiguration.addAmiDistributions({
375
+ amiName: 'imagebuilder-{{ imagebuilder:buildDate }}',
376
+ amiDescription: 'Build AMI',
377
+ amiKmsKey: kms.Key.fromLookup(this, 'ComponentKey', { aliasName: 'alias/distribution-encryption-key' }),
378
+ // Copy the AMI to different accounts
379
+ amiTargetAccountIds: ['123456789012', '098765432109'],
380
+ // Add launch permissions on the AMI
381
+ amiLaunchPermission: {
382
+ organizationArns: [
383
+ this.formatArn({ region: '', service: 'organizations', resource: 'organization', resourceName: 'o-1234567abc' })
384
+ ],
385
+ organizationalUnitArns: [
386
+ this.formatArn({
387
+ region: '',
388
+ service: 'organizations',
389
+ resource: 'ou',
390
+ resourceName: 'o-1234567abc/ou-a123-b4567890'
391
+ })
392
+ ],
393
+ isPublicUserGroup: true,
394
+ accountIds: ['234567890123']
395
+ },
396
+ // Attach tags to the AMI
397
+ amiTags: {
398
+ Environment: 'production',
399
+ Version: '{{ imagebuilder:buildVersion }}'
400
+ },
401
+ // Optional - publish the distributed AMI ID to an SSM parameter
402
+ ssmParameters: [
403
+ {
404
+ parameter: ssm.StringParameter.fromStringParameterAttributes(this, 'Parameter', {
405
+ parameterName: '/imagebuilder/ami',
406
+ forceDynamicReference: true
407
+ })
408
+ },
409
+ {
410
+ amiAccount: '098765432109',
411
+ dataType: ssm.ParameterDataType.TEXT,
412
+ parameter: ssm.StringParameter.fromStringParameterAttributes(this, 'CrossAccountParameter', {
413
+ parameterName: 'imagebuilder-prod-ami',
414
+ forceDynamicReference: true
415
+ })
416
+ }
417
+ ],
418
+ // Optional - create a new launch template version with the distributed AMI ID
419
+ launchTemplates: [
420
+ {
421
+ launchTemplate: ec2.LaunchTemplate.fromLaunchTemplateAttributes(this, 'LaunchTemplate', {
422
+ launchTemplateId: 'lt-1234'
423
+ }),
424
+ setDefaultVersion: true
425
+ },
426
+ {
427
+ accountId: '123456789012',
428
+ launchTemplate: ec2.LaunchTemplate.fromLaunchTemplateAttributes(this, 'CrossAccountLaunchTemplate', {
429
+ launchTemplateId: 'lt-5678'
430
+ }),
431
+ setDefaultVersion: true
432
+ }
433
+ ],
434
+ // Optional - enable Fast Launch on an imported launch template
435
+ fastLaunchConfigurations: [
436
+ {
437
+ enabled: true,
438
+ launchTemplate: ec2.LaunchTemplate.fromLaunchTemplateAttributes(this, 'FastLaunchLT', {
439
+ launchTemplateName: 'fast-launch-lt'
440
+ }),
441
+ maxParallelLaunches: 10,
442
+ targetSnapshotCount: 2
443
+ }
444
+ ],
445
+ // Optional - license configurations to apply to the AMI
446
+ licenseConfigurationArns: [
447
+ 'arn:aws:license-manager:us-west-2:123456789012:license-configuration:lic-abcdefghijklmnopqrstuvwxyz'
448
+ ]
449
+ });
450
+ ```
451
+
452
+ #### Container Distributions
453
+
454
+ ##### Container repositories
455
+
456
+ Container distributions can be configured to distribute to ECR repositories:
457
+
458
+ ```ts
459
+ const ecrRepository = ecr.Repository.fromRepositoryName(this, 'ECRRepository', 'my-repo');
460
+ const imageBuilderRepository = imagebuilder.Repository.fromEcr(ecrRepository);
461
+ ```
462
+
463
+ ##### Defining a container distribution
464
+
465
+ You can configure the container repositories as well as the description and tags applied to the distributed container
466
+ images:
467
+
468
+ ```ts
469
+ const ecrRepository = ecr.Repository.fromRepositoryName(this, 'ECRRepository', 'my-repo');
470
+ const containerRepository = imagebuilder.Repository.fromEcr(ecrRepository);
471
+ const containerDistributionConfiguration = new imagebuilder.DistributionConfiguration(
472
+ this,
473
+ 'ContainerDistributionConfiguration'
474
+ );
475
+
476
+ containerDistributionConfiguration.addContainerDistributions({
477
+ containerRepository,
478
+ containerDescription: 'Test container image',
479
+ containerTags: ['latest', 'latest-1.0']
480
+ });
481
+ ```