Experimental
@aws-cdk/aws-imagebuilder-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
WorkflowAction Enum
The action for a step within the workflow document.
Example
ts
const workflow = new imagebuilder.Workflow(this, 'MyWorkflow', {
workflowType: imagebuilder.WorkflowType.BUILD,
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: 'ExecuteComponents',
action: imagebuilder.WorkflowAction.EXECUTE_COMPONENTS,
onFailure: imagebuilder.WorkflowOnFailure.ABORT,
inputs: {
'instanceId': 'i-123',
},
},
{
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
workflow = imagebuilder.Workflow(self, "MyWorkflow",
workflow_type=imagebuilder.WorkflowType.BUILD,
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": "ExecuteComponents",
"action": imagebuilder.WorkflowAction.EXECUTE_COMPONENTS,
"on_failure": imagebuilder.WorkflowOnFailure.ABORT,
"inputs": {
"instance_id": "i-123"
}
}, {
"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
Workflow workflow = Workflow.Builder.create(this, "MyWorkflow")
.workflowType(WorkflowType.BUILD)
.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", "ExecuteComponents",
"action", WorkflowAction.EXECUTE_COMPONENTS,
"onFailure", WorkflowOnFailure.ABORT,
"inputs", Map.of(
"instanceId", "i-123")), 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();
csharp
// Install: dotnet add package Amazon.CDK.AWS.ImageBuilder.Alpha
var workflow = new Workflow(this, "MyWorkflow", new WorkflowProps {
WorkflowType = WorkflowType.BUILD,
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", "ExecuteComponents" },
{ "action", WorkflowAction.EXECUTE_COMPONENTS },
{ "onFailure", WorkflowOnFailure.ABORT },
{ "inputs", new Struct {
InstanceId = "i-123"
} }
}, 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" }
} } }
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2
workflow := imagebuilder.NewWorkflow(this, jsii.String("MyWorkflow"), &WorkflowProps{
WorkflowType: imagebuilder.WorkflowType_BUILD,
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("ExecuteComponents"),
"action": imagebuilder.WorkflowAction_EXECUTE_COMPONENTS,
"onFailure": imagebuilder.WorkflowOnFailure_ABORT,
"inputs": map[string]*string{
"instanceId": jsii.String("i-123"),
},
},
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"),
},
},
}),
})
Members
| Member | Description |
|---|---|
APPLY_IMAGE_CONFIGURATIONS | Applies customizations and configurations to the input AMIs, such as publishing the AMI to SSM Parameter Store, or creating launch template versions with the AMI IDs provided in the input. |
BOOTSTRAP_INSTANCE_FOR_CONTAINER | The BootstrapInstanceForContainer action runs a service script to bootstrap the instance with minimum requirements to run container workflows. |
COLLECT_IMAGE_METADATA | The CollectImageMetadata action collects additional information about the instance, such as the list of packages and their respective versions. |
COLLECT_IMAGE_SCAN_FINDINGS | The CollectImageScanFindings action collects findings reported by Amazon Inspector for the provided instance. |
CREATE_IMAGE | The CreateImage action creates an AMI from a running instance with the ec2:CreateImage API. |
DISTRIBUTE_IMAGE | The DistributeImage action copies an AMI using the image's distribution configuration, or using the distribution settings in the step input. |
EXECUTE_COMPONENTS | The ExecuteComponents action runs components that are specified in the recipe for the current image being built. |
EXECUTE_STATE_MACHINE | The ExecuteStateMachine action executes the state machine provided and waits for completion as part of the workflow. |
LAUNCH_INSTANCE | The LaunchInstance action launches an instance using the settings from your recipe and infrastructure configuration resources. |
MODIFY_IMAGE_ATTRIBUTES | Applies attribute updates to the provided set of distributed images, such as launch permission updates. |
RUN_COMMAND | The RunCommand action runs a command document against the provided instance. |
REGISTER_IMAGE | The RegisterImage action creates an AMI from a set of snapshots with the ec2:RegisterImage API. |
RUN_SYS_PREP | The RunSysprep action runs the Sysprep document on the provided Windows instance. |
SANITIZE_INSTANCE | The SanitizeInstance action runs a recommended sanitization script on Linux instances. |
TERMINATE_INSTANCE | The TerminateInstance action terminates the provided instance. |
WAIT_FOR_ACTION | The WaitForAction action pauses the workflow and waits to receive an external signal from the imagebuilder:SendWorkflowStepAction API. |
WAIT_FOR_SSM_AGENT | The WaitForSSMAgent action waits for the given instance to have connectivity with SSM before proceeding. |