Skip to content

Commit 689ad05

Browse files
authored
revert(imagebuilder-alpha): add support for Component Construct (#36104)
Reverts #36006 as it caused JSII errors that is coming from https://github.com/cdklabs/cdk-generate-synthetic-examples ``` @aws-cdk.aws-imagebuilder-alpha.ComponentDocumentPhase-example.ts:9:1 - error TS7005: Variable 'declare' implicitly has an 'any' type. --   9 declare const inputs: any; ~~~~~~~ @aws-cdk.aws-imagebuilder-alpha.ComponentDocumentPhase-example.ts:9:9 - error TS1005: ',' expected.   9 declare const inputs: any; ~~~~~ @aws-cdk.aws-imagebuilder-alpha.ComponentDocumentPhase-example.ts:18:4 - error TS1005: '(' expected.   18 if: any; ~ @aws-cdk.aws-imagebuilder-alpha.ComponentDocumentPhase-example.ts:18:6 - error TS2693: 'any' only refers to a type, but is being used as a value here.   18 if: any; ~~~ @aws-cdk.aws-imagebuilder-alpha.ComponentDocumentPhase-example.ts:27:9 - error TS1109: Expression expected.   27 if: if, ~~ @aws-cdk.aws-imagebuilder-alpha.ComponentDocumentPhase-example.ts:27:11 - error TS1005: ':' expected.   27 if: if, ~ @aws-cdk.aws-imagebuilder-alpha.ComponentDocumentStep-example.ts:9:1 - error TS7005: Variable 'declare' implicitly has an 'any' type.   9 declare const inputs: any; ~~~~~~~ @aws-cdk.aws-imagebuilder-alpha.ComponentDocumentStep-example.ts:9:9 - error TS1005: ',' expected.   9 declare const inputs: any; ~~~~~ @aws-cdk.aws-imagebuilder-alpha.ComponentDocumentStep-example.ts:18:4 - error TS1005: '(' expected.   18 if: any; ~ @aws-cdk.aws-imagebuilder-alpha.ComponentDocumentStep-example.ts:18:6 - error TS2693: 'any' only refers to a type, but is being used as a value here.   18 if: any; ~~~ @aws-cdk.aws-imagebuilder-alpha.ComponentDocumentStep-example.ts:25:7 - error TS1109: Expression expected.   25 if: if, ~~ @aws-cdk.aws-imagebuilder-alpha.ComponentDocumentStep-example.ts:25:9 - error TS1005: ':' expected.   25 if: if, ~ ```
1 parent 8d6867a commit 689ad05

File tree

45 files changed

+0
-5971
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+0
-5971
lines changed

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

Lines changed: 0 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -36,210 +36,6 @@ 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-
#### 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-
const component = new imagebuilder.Component(this, 'JsonComponent', {
106-
platform: imagebuilder.Platform.LINUX,
107-
data: imagebuilder.ComponentData.fromJsonObject({
108-
schemaVersion: imagebuilder.ComponentSchemaVersion.V1_0,
109-
phases: [
110-
{
111-
name: imagebuilder.ComponentPhaseName.BUILD,
112-
steps: [
113-
{
114-
name: 'configure-app',
115-
action: imagebuilder.ComponentAction.CREATE_FILE,
116-
inputs: {
117-
path: '/etc/myapp/config.json',
118-
content: '{"env": "production"}',
119-
},
120-
},
121-
],
122-
},
123-
],
124-
}),
125-
});
126-
```
127-
128-
##### Structured Component Document
129-
130-
For type-safe, CDK-native definitions with enhanced properties like `timeout` and `onFailure`:
131-
132-
```ts
133-
const component = new imagebuilder.Component(this, 'StructuredComponent', {
134-
platform: imagebuilder.Platform.LINUX,
135-
data: imagebuilder.ComponentData.fromComponentDocumentJsonObject({
136-
schemaVersion: imagebuilder.ComponentSchemaVersion.V1_0,
137-
phases: [
138-
{
139-
name: imagebuilder.ComponentPhaseName.BUILD,
140-
steps: [
141-
{
142-
name: 'install-with-timeout',
143-
action: imagebuilder.ComponentAction.EXECUTE_BASH,
144-
timeout: Duration.minutes(10),
145-
onFailure: imagebuilder.ComponentOnFailure.CONTINUE,
146-
inputs: {
147-
commands: ['./install-script.sh'],
148-
},
149-
},
150-
],
151-
},
152-
],
153-
}),
154-
});
155-
```
156-
157-
##### S3 Component Data
158-
159-
For those components you want to upload or have uploaded to S3:
160-
161-
```ts
162-
// Upload a local file
163-
const componentFromAsset = new imagebuilder.Component(this, 'AssetComponent', {
164-
platform: imagebuilder.Platform.LINUX,
165-
data: imagebuilder.ComponentData.fromAsset(this, 'ComponentAsset', './my-component.yml'),
166-
});
167-
168-
// Reference an existing S3 object
169-
const bucket = s3.Bucket.fromBucketName(this, 'ComponentBucket', 'my-components-bucket');
170-
const componentFromS3 = new imagebuilder.Component(this, 'S3Component', {
171-
platform: imagebuilder.Platform.LINUX,
172-
data: imagebuilder.ComponentData.fromS3(bucket, 'components/my-component.yml'),
173-
});
174-
```
175-
176-
#### Encrypt component data with a KMS key
177-
178-
You can encrypt component data with a KMS key, so that only principals with access to decrypt with the key are able to
179-
access the component data.
180-
181-
```ts
182-
const component = new imagebuilder.Component(this, 'EncryptedComponent', {
183-
platform: imagebuilder.Platform.LINUX,
184-
kmsKey: new kms.Key(this, 'ComponentKey'),
185-
data: imagebuilder.ComponentData.fromJsonObject({
186-
schemaVersion: imagebuilder.ComponentSchemaVersion.V1_0,
187-
phases: [
188-
{
189-
name: imagebuilder.ComponentPhaseName.BUILD,
190-
steps: [
191-
{
192-
name: 'secure-setup',
193-
action: imagebuilder.ComponentAction.EXECUTE_BASH,
194-
inputs: {
195-
commands: ['echo "This component data is encrypted with KMS"'],
196-
},
197-
},
198-
],
199-
},
200-
],
201-
}),
202-
});
203-
```
204-
205-
#### AWS-Managed Components
206-
207-
AWS provides a collection of managed components for common tasks:
208-
209-
```ts
210-
// Install AWS CLI v2
211-
const awsCliComponent = imagebuilder.AwsManagedComponent.awsCliV2(this, 'AwsCli', {
212-
platform: imagebuilder.Platform.LINUX
213-
});
214-
215-
// Update the operating system
216-
const updateComponent = imagebuilder.AwsManagedComponent.updateOS(this, 'UpdateOS', {
217-
platform: imagebuilder.Platform.LINUX
218-
});
219-
220-
// Reference any AWS-managed component by name
221-
const customAwsComponent = imagebuilder.AwsManagedComponent.fromAwsManagedComponentName(
222-
this,
223-
'CloudWatchAgent',
224-
'amazon-cloudwatch-agent-linux'
225-
);
226-
```
227-
228-
#### AWS Marketplace Components
229-
230-
You can reference AWS Marketplace components using the marketplace component name and its product ID:
231-
232-
```ts
233-
const marketplaceComponent = imagebuilder.AwsMarketplaceComponent.fromAwsMarketplaceComponentAttributes(
234-
this,
235-
'MarketplaceComponent',
236-
{
237-
componentName: 'my-marketplace-component',
238-
marketplaceProductId: 'prod-1234567890abcdef0',
239-
}
240-
);
241-
```
242-
24339
### Infrastructure Configuration
24440

24541
Infrastructure configuration defines the compute resources and environment settings used during the image building

0 commit comments

Comments
 (0)