Experimental
@aws-cdk/aws-imagebuilder-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
Workflow L2 construct
Represents an EC2 Image Builder Workflow.
Example
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',
},
],
}),
});
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"
}
]
})
)
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();
// 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" }
} } }
})
});
// 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
new Workflow(scope: Construct, id: string, props: WorkflowProps)
Workflow(scope: Construct, id: str, props: WorkflowProps)
new Workflow(Construct scope, String id, WorkflowProps props)
new Workflow(Construct scope, string id, WorkflowProps props)
NewWorkflow(Scope Construct, Id *string, Props WorkflowProps)
Construct Props
changeDescriptionstringchange_descriptionstrchangeDescriptionStringChangeDescriptionstringChangeDescription*string= None#Describes what change has been made in this version of the workflow, or what makes this version different from other versions.
default
Default: an Image Builder owned key will be used to encrypt the workflow.
tags{ [key: string]: string }tagstyping.Mapping[str, str]tagsMap<String, String>TagsIDictionary<string, string>Tags*map[string]*string= None#workflowNamestringworkflow_namestrworkflowNameStringWorkflowNamestringWorkflowName*string= a name is generated#workflowTypeWorkflowTypeworkflow_typeWorkflowTypeworkflowTypeWorkflowTypeWorkflowTypeWorkflowTypeWorkflowTypeWorkflowTyperequired#workflowVersionstringworkflow_versionstrworkflowVersionStringWorkflowVersionstringWorkflowVersion*string= 1.0.0#Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#workflowVersionstringworkflow_versionstrworkflowVersionStringWorkflowVersionstringWorkflowVersion*stringrequired#Methods
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).
fromWorkflowArn(scope: Construct, id: string, workflowArn: string): IWorkflow@staticmethod def from_workflow_arn(scope: Construct, id: str, workflow_arn: str) -> IWorkflowpublic static IWorkflow fromWorkflowArn(Construct scope, String id, String workflowArn)public static IWorkflow FromWorkflowArn(Construct scope, string id, string workflowArn)func FromWorkflowArn(Scope Construct, Id *string, WorkflowArn *string) IWorkflowstatic#fromWorkflowAttributes(scope: Construct, id: string, attrs: WorkflowAttributes): IWorkflow@staticmethod def from_workflow_attributes(scope: Construct, id: str, attrs: WorkflowAttributes) -> IWorkflowpublic static IWorkflow fromWorkflowAttributes(Construct scope, String id, WorkflowAttributes attrs)public static IWorkflow FromWorkflowAttributes(Construct scope, string id, WorkflowAttributes attrs)func FromWorkflowAttributes(Scope Construct, Id *string, Attrs WorkflowAttributes) IWorkflowstatic#The provided name must be normalized by converting all alphabetical characters to lowercase, and replacing all spaces and underscores with hyphens. You may not provide a dynamic expression for the workflowArn or workflowType
grant(grantee: IGrantable, ...actions: string[]): Grantdef grant(self, grantee: IGrantable, actions: str) -> Grantpublic Grant grant(IGrantable grantee, String actions)public Grant Grant(IGrantable grantee, string actions)func Grant(Grantee IGrantable, Actions *string) Grant#2 parameters
Parameters
granteegranteegranteegranteeGrantee— The principal.actionsactionsactionsactionsActions— The list of actions.
grantRead(grantee: IGrantable): Grantdef grant_read(self, grantee: IGrantable) -> Grantpublic Grant grantRead(IGrantable grantee)public Grant GrantRead(IGrantable grantee)func GrantRead(Grantee IGrantable) Grant#1 parameter
Parameters
granteegranteegranteegranteeGrantee— The principal.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#isWorkflow(x: any): boolean@staticmethod def is_workflow(x: Any) -> boolpublic static Boolean isWorkflow(Object x)public static bool IsWorkflow(object x)func IsWorkflow(X interface{}) *boolstatic#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.