Skip to content

Commit b9d17a0

Browse files
author
Tarun Belani
committed
feat(imagebuilder): add support for EC2 Image Builder L2 Constructs - Component
1 parent 0d773b1 commit b9d17a0

28 files changed

+3943
-1
lines changed

packages/@aws-cdk/aws-imagebuilder-alpha/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,83 @@ EC2 Image Builder supports AWS-managed components for common tasks, AWS Marketpl
3636
that you create. Components run during specific workflow phases: build and validate phases during the build stage, and
3737
test phase during the test stage.
3838

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+
```ts
51+
const component = new imagebuilder.Component(this, 'Component', {
52+
componentName: 'build-and-test-component',
53+
componentVersion: '1.0.0',
54+
description: 'A build and test component',
55+
changeDescription: 'Initial version',
56+
// Encrypt component data with a KMS key
57+
kmsKey: kms.Key.fromKeyArn(
58+
this,
59+
'ComponentKey',
60+
this.formatArn({ service: 'kms', resource: 'key', resourceName: '1234abcd-12ab-34cd-56ef-1234567890ab' })
61+
),
62+
platform: imagebuilder.Platform.LINUX,
63+
// Include the OS versions this component supports
64+
supportedOsVersions: [
65+
imagebuilder.OSVersion.AMAZON_LINUX,
66+
imagebuilder.OSVersion.RHEL_10,
67+
imagebuilder.OSVersion.SLES_15,
68+
imagebuilder.OSVersion.UBUNTU
69+
],
70+
// Hello world component data
71+
data: imagebuilder.ComponentData.fromJsonObject({
72+
name: 'build-and-test-component',
73+
schemaVersion: imagebuilder.ComponentSchemaVersion.V1_0,
74+
phases: [
75+
{
76+
name: imagebuilder.ComponentPhaseName.BUILD,
77+
steps: [
78+
{
79+
action: imagebuilder.ComponentAction.EXECUTE_BASH,
80+
name: 'hello-world-build',
81+
inputs: {
82+
commands: ['echo "Hello build!"']
83+
}
84+
}
85+
]
86+
},
87+
{
88+
name: imagebuilder.ComponentPhaseName.VALIDATE,
89+
steps: [
90+
{
91+
action: imagebuilder.ComponentAction.EXECUTE_BASH,
92+
name: 'hello-world-validate',
93+
inputs: {
94+
commands: ['echo "Hello validate!"']
95+
}
96+
}
97+
]
98+
},
99+
{
100+
name: imagebuilder.ComponentPhaseName.TEST,
101+
steps: [
102+
{
103+
action: imagebuilder.ComponentAction.EXECUTE_BASH,
104+
name: 'hello-world-test',
105+
inputs: {
106+
commands: ['echo "Hello test!"']
107+
}
108+
}
109+
]
110+
}
111+
]
112+
})
113+
});
114+
```
115+
39116
### Infrastructure Configuration
40117

41118
Infrastructure configuration defines the compute resources and environment settings used during the image building
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"exclude": [
3-
"props-no-arn-refs:@aws-cdk/aws-imagebuilder-alpha.InfrastructureConfigurationProps.ec2InstanceHostResourceGroupArn"
3+
"props-no-arn-refs:@aws-cdk/aws-imagebuilder-alpha.InfrastructureConfigurationProps.ec2InstanceHostResourceGroupArn",
4+
"no-unused-type:@aws-cdk/aws-imagebuilder-alpha.ComponentAction",
5+
"no-unused-type:@aws-cdk/aws-imagebuilder-alpha.ComponentConfiguration",
6+
"no-unused-type:@aws-cdk/aws-imagebuilder-alpha.ComponentPhaseName",
7+
"no-unused-type:@aws-cdk/aws-imagebuilder-alpha.ComponentSchemaVersion"
48
]
59
}

0 commit comments

Comments
 (0)