> **Experimental**
>
> `@aws-cdk/aws-imagebuilder-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# ComponentData

Helper class for referencing and uploading component data.

Superclass of: [S3ComponentData](/cdk/api/v2/docs/@aws-cdk_aws-imagebuilder-alpha.S3ComponentData.html)
Obtainable from: ComponentData.fromComponentDocumentJsonObject, ComponentData.fromInline, ComponentData.fromJsonObject

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/component.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/aws-imagebuilder-alpha/lib/component.ts#L691)

## Example

TypeScript:

```ts
const component = new imagebuilder.Component(this, 'EncryptedComponent', {
  platform: imagebuilder.Platform.LINUX,
  kmsKey: new kms.Key(this, 'ComponentKey'),
  data: imagebuilder.ComponentData.fromJsonObject({
    schemaVersion: imagebuilder.ComponentSchemaVersion.V1_0,
    phases: [
      {
        name: imagebuilder.ComponentPhaseName.BUILD,
        steps: [
          {
            name: 'secure-setup',
            action: imagebuilder.ComponentAction.EXECUTE_BASH,
            inputs: {
              commands: ['echo "This component data is encrypted with KMS"']
            }
          }
        ]
      }
    ]
  })
});
```

Python:

```python
component = imagebuilder.Component(self, "EncryptedComponent",
    platform=imagebuilder.Platform.LINUX,
    kms_key=kms.Key(self, "ComponentKey"),
    data=imagebuilder.ComponentData.from_json_object({
        "schema_version": imagebuilder.ComponentSchemaVersion.V1_0,
        "phases": [{
            "name": imagebuilder.ComponentPhaseName.BUILD,
            "steps": [{
                "name": "secure-setup",
                "action": imagebuilder.ComponentAction.EXECUTE_BASH,
                "inputs": {
                    "commands": ["echo \"This component data is encrypted with KMS\""]
                }
            }
            ]
        }
        ]
    })
)
```

Java:

```java
Component component = Component.Builder.create(this, "EncryptedComponent")
        .platform(Platform.LINUX)
        .kmsKey(new Key(this, "ComponentKey"))
        .data(ComponentData.fromJsonObject(Map.of(
                "schemaVersion", ComponentSchemaVersion.V1_0,
                "phases", List.of(Map.of(
                        "name", ComponentPhaseName.BUILD,
                        "steps", List.of(Map.of(
                                "name", "secure-setup",
                                "action", ComponentAction.EXECUTE_BASH,
                                "inputs", Map.of(
                                        "commands", List.of("echo \"This component data is encrypted with KMS\"")))))))))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.ImageBuilder.Alpha
var component = new Component(this, "EncryptedComponent", new ComponentProps {
    Platform = Platform.LINUX,
    KmsKey = new Key(this, "ComponentKey"),
    Data = ComponentData.FromJsonObject(new Dictionary<string, object> {
        { "schemaVersion", ComponentSchemaVersion.V1_0 },
        { "phases", new [] { new Dictionary<string, object> {
            { "name", ComponentPhaseName.BUILD },
            { "steps", new [] { new Struct {
                Name = "secure-setup",
                Action = ComponentAction.EXECUTE_BASH,
                Inputs = new Struct {
                    Commands = new [] { "echo \"This component data is encrypted with KMS\"" }
                }
            } } }
        } } }
    })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2
component := imagebuilder.NewComponent(this, jsii.String("EncryptedComponent"), &ComponentProps{
	Platform: imagebuilder.Platform_LINUX,
	KmsKey: kms.NewKey(this, jsii.String("ComponentKey")),
	Data: imagebuilder.ComponentData_FromJsonObject(map[string]interface{}{
		"schemaVersion": imagebuilder.ComponentSchemaVersion_V1_0,
		"phases": []interface{}{
			map[string]interface{}{
				"name": imagebuilder.ComponentPhaseName_BUILD,
				"steps": []map[string]interface{}{
					map[string]interface{}{
						"name": jsii.String("secure-setup"),
						"action": imagebuilder.ComponentAction_EXECUTE_BASH,
						"inputs": map[string][]*string{
							"commands": []*string{
								jsii.String("echo \"This component data is encrypted with KMS\""),
							},
						},
					},
				},
			},
		},
	}),
})
```

## Initializer

TypeScript:

```ts
new ComponentData()
```

Python:

```python
ComponentData()
```

Java:

```java
new ComponentData()
```

C# / .NET:

```csharp
new ComponentData()
```

Golang:

```go
NewComponentData()
```

## Methods

- `fromAsset(scope: Construct, id: string, path: string, options?: AssetOptions): S3ComponentData` (static) — Uploads component data from a local file to S3 to use as the component data.

  **Parameters**

  - `scope` — The construct scope.
  - `id` — Identifier of the construct.
  - `path` — The local path to the component data file.
  - `options` — S3 asset upload options.

- `fromComponentDocumentJsonObject(data: ComponentDocument): ComponentData // chainable` (static) — Uses an inline JSON object as the component data, using the ComponentDocument interface.

  **Parameters**

  - `data` — An inline JSON object representing the component data.

- `fromInline(data: string): ComponentData // chainable` (static) — Uses an inline JSON/YAML string as the component data.

  **Parameters**

  - `data` — An inline JSON/YAML string representing the component data.

- `fromJsonObject(data: { [key: string]: any }): ComponentData // chainable` (static) — Uses an inline JSON object as the component data.

  **Parameters**

  - `data` — An inline JSON object representing the component data.

- `fromS3(bucket: IBucket, key: string): S3ComponentData` (static) — References component data from a pre-existing S3 object.

  **Parameters**

  - `bucket` — The S3 bucket where the component data is stored.
  - `key` — The S3 key of the component data file.

- `render(): ComponentDataConfig` — The rendered component data value, for use in CloudFormation.

  - For inline components, data is the component text
  - For S3-backed components, uri is the S3 URL
