@@ -36,6 +36,83 @@ 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+ ### 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
41118Infrastructure configuration defines the compute resources and environment settings used during the image building
0 commit comments