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

Helper class for referencing and uploading workflow data.

Superclass of: [S3WorkflowData](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-imagebuilder-alpha.S3WorkflowData.html)
Obtainable from: WorkflowData.fromInline, WorkflowData.fromJsonObject

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

## Example

TypeScript:

```ts
const workflow = new imagebuilder.Workflow(this, 'EncryptedWorkflow', {
  workflowType: imagebuilder.WorkflowType.BUILD,
  kmsKey: new kms.Key(this, 'WorkflowKey'),
  data: imagebuilder.WorkflowData.fromJsonObject({
    schemaVersion: imagebuilder.WorkflowSchemaVersion.V1_0,
    steps: [
      {
        name: 'LaunchBuildInstance',
        action: imagebuilder.WorkflowAction.LAUNCH_INSTANCE,
        onFailure: imagebuilder.WorkflowOnFailure.ABORT,
        inputs: {
          waitFor: 'ssmAgent',
        },
      },
      {
        name: 'CreateImage',
        action: imagebuilder.WorkflowAction.CREATE_IMAGE,
        onFailure: imagebuilder.WorkflowOnFailure.ABORT,
        inputs: {
          'instanceId': 'i-123',
        },
      },
      {
        name: 'TerminateInstance',
        action: imagebuilder.WorkflowAction.TERMINATE_INSTANCE,
        onFailure: imagebuilder.WorkflowOnFailure.CONTINUE,
        inputs: {
          'instanceId': 'i-123',
        },
      },
    ],
    outputs: [
      {
        name: 'ImageId',
        value: '$.stepOutputs.CreateImage.imageId',
      },
    ],
  }),
});
```

Python:

```python
workflow = imagebuilder.Workflow(self, "EncryptedWorkflow",
    workflow_type=imagebuilder.WorkflowType.BUILD,
    kms_key=kms.Key(self, "WorkflowKey"),
    data=imagebuilder.WorkflowData.from_json_object({
        "schema_version": imagebuilder.WorkflowSchemaVersion.V1_0,
        "steps": [{
            "name": "LaunchBuildInstance",
            "action": imagebuilder.WorkflowAction.LAUNCH_INSTANCE,
            "on_failure": imagebuilder.WorkflowOnFailure.ABORT,
            "inputs": {
                "wait_for": "ssmAgent"
            }
        }, {
            "name": "CreateImage",
            "action": imagebuilder.WorkflowAction.CREATE_IMAGE,
            "on_failure": imagebuilder.WorkflowOnFailure.ABORT,
            "inputs": {
                "instance_id": "i-123"
            }
        }, {
            "name": "TerminateInstance",
            "action": imagebuilder.WorkflowAction.TERMINATE_INSTANCE,
            "on_failure": imagebuilder.WorkflowOnFailure.CONTINUE,
            "inputs": {
                "instance_id": "i-123"
            }
        }
        ],
        "outputs": [{
            "name": "ImageId",
            "value": "$.stepOutputs.CreateImage.imageId"
        }
        ]
    })
)
```

Java:

```java
Workflow workflow = Workflow.Builder.create(this, "EncryptedWorkflow")
        .workflowType(WorkflowType.BUILD)
        .kmsKey(new Key(this, "WorkflowKey"))
        .data(WorkflowData.fromJsonObject(Map.of(
                "schemaVersion", WorkflowSchemaVersion.V1_0,
                "steps", List.of(Map.of(
                        "name", "LaunchBuildInstance",
                        "action", WorkflowAction.LAUNCH_INSTANCE,
                        "onFailure", WorkflowOnFailure.ABORT,
                        "inputs", Map.of(
                                "waitFor", "ssmAgent")), Map.of(
                        "name", "CreateImage",
                        "action", WorkflowAction.CREATE_IMAGE,
                        "onFailure", WorkflowOnFailure.ABORT,
                        "inputs", Map.of(
                                "instanceId", "i-123")), Map.of(
                        "name", "TerminateInstance",
                        "action", WorkflowAction.TERMINATE_INSTANCE,
                        "onFailure", WorkflowOnFailure.CONTINUE,
                        "inputs", Map.of(
                                "instanceId", "i-123"))),
                "outputs", List.of(Map.of(
                        "name", "ImageId",
                        "value", "$.stepOutputs.CreateImage.imageId")))))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.ImageBuilder.Alpha
var workflow = new Workflow(this, "EncryptedWorkflow", new WorkflowProps {
    WorkflowType = WorkflowType.BUILD,
    KmsKey = new Key(this, "WorkflowKey"),
    Data = WorkflowData.FromJsonObject(new Dictionary<string, object> {
        { "schemaVersion", WorkflowSchemaVersion.V1_0 },
        { "steps", new [] { new Dictionary<string, object> {
            { "name", "LaunchBuildInstance" },
            { "action", WorkflowAction.LAUNCH_INSTANCE },
            { "onFailure", WorkflowOnFailure.ABORT },
            { "inputs", new Struct {
                WaitFor = "ssmAgent"
            } }
        }, new Dictionary<string, object> {
            { "name", "CreateImage" },
            { "action", WorkflowAction.CREATE_IMAGE },
            { "onFailure", WorkflowOnFailure.ABORT },
            { "inputs", new Struct {
                InstanceId = "i-123"
            } }
        }, new Dictionary<string, object> {
            { "name", "TerminateInstance" },
            { "action", WorkflowAction.TERMINATE_INSTANCE },
            { "onFailure", WorkflowOnFailure.CONTINUE },
            { "inputs", new Struct {
                InstanceId = "i-123"
            } }
        } } },
        { "outputs", new [] { new Dictionary<string, string> {
            { "name", "ImageId" },
            { "value", "$.stepOutputs.CreateImage.imageId" }
        } } }
    })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2
workflow := imagebuilder.NewWorkflow(this, jsii.String("EncryptedWorkflow"), &WorkflowProps{
	WorkflowType: imagebuilder.WorkflowType_BUILD,
	KmsKey: kms.NewKey(this, jsii.String("WorkflowKey")),
	Data: imagebuilder.WorkflowData_FromJsonObject(map[string]interface{}{
		"schemaVersion": imagebuilder.WorkflowSchemaVersion_V1_0,
		"steps": []interface{}{
			map[string]interface{}{
				"name": jsii.String("LaunchBuildInstance"),
				"action": imagebuilder.WorkflowAction_LAUNCH_INSTANCE,
				"onFailure": imagebuilder.WorkflowOnFailure_ABORT,
				"inputs": map[string]*string{
					"waitFor": jsii.String("ssmAgent"),
				},
			},
			map[string]interface{}{
				"name": jsii.String("CreateImage"),
				"action": imagebuilder.WorkflowAction_CREATE_IMAGE,
				"onFailure": imagebuilder.WorkflowOnFailure_ABORT,
				"inputs": map[string]*string{
					"instanceId": jsii.String("i-123"),
				},
			},
			map[string]interface{}{
				"name": jsii.String("TerminateInstance"),
				"action": imagebuilder.WorkflowAction_TERMINATE_INSTANCE,
				"onFailure": imagebuilder.WorkflowOnFailure_CONTINUE,
				"inputs": map[string]*string{
					"instanceId": jsii.String("i-123"),
				},
			},
		},
		"outputs": []interface{}{
			map[string]*string{
				"name": jsii.String("ImageId"),
				"value": jsii.String("$.stepOutputs.CreateImage.imageId"),
			},
		},
	}),
})
```

## Initializer

TypeScript:

```ts
new WorkflowData()
```

Python:

```python
WorkflowData()
```

Java:

```java
new WorkflowData()
```

C# / .NET:

```csharp
new WorkflowData()
```

Golang:

```go
NewWorkflowData()
```

## Methods

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

  **Parameters**

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

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

  **Parameters**

  - `data` — An inline JSON or YAML string representing the workflow data.

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

  **Parameters**

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

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

  **Parameters**

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

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

  - For inline workflows, data is the workflow text
  - For S3-backed workflows, uri is the S3 URL
