Skip to content
v2.278.0

Ec2DeployActionProps Struct ​

Construction properties of Ec2DeployAction.

Example ​

ts
const sourceOutput = new codepipeline.Artifact();

const pipeline = new codepipeline.Pipeline(this, 'MyPipeline', {
  pipelineType: codepipeline.PipelineType.V2,
});
const deployAction = new codepipeline_actions.Ec2DeployAction({
  actionName: 'Ec2Deploy',
  input: sourceOutput,
  instanceType: codepipeline_actions.Ec2InstanceType.EC2,
  instanceTagKey: 'Name',
  instanceTagValue: 'MyInstance',
  deploySpecifications: codepipeline_actions.Ec2DeploySpecifications.inline({
    targetDirectory: '/home/ec2-user/deploy',
    preScript: 'scripts/pre-deploy.sh',
    postScript: 'scripts/post-deploy.sh',
  }),
});
const deployStage = pipeline.addStage({
  stageName: 'Deploy',
  actions: [deployAction],
});
python
source_output = codepipeline.Artifact()

pipeline = codepipeline.Pipeline(self, "MyPipeline",
    pipeline_type=codepipeline.PipelineType.V2
)
deploy_action = codepipeline_actions.Ec2DeployAction(
    action_name="Ec2Deploy",
    input=source_output,
    instance_type=codepipeline_actions.Ec2InstanceType.EC2,
    instance_tag_key="Name",
    instance_tag_value="MyInstance",
    deploy_specifications=codepipeline_actions.Ec2DeploySpecifications.inline(
        target_directory="/home/ec2-user/deploy",
        pre_script="scripts/pre-deploy.sh",
        post_script="scripts/post-deploy.sh"
    )
)
deploy_stage = pipeline.add_stage(
    stage_name="Deploy",
    actions=[deploy_action]
)
java
Artifact sourceOutput = new Artifact();

Pipeline pipeline = Pipeline.Builder.create(this, "MyPipeline")
        .pipelineType(PipelineType.V2)
        .build();
Ec2DeployAction deployAction = Ec2DeployAction.Builder.create()
        .actionName("Ec2Deploy")
        .input(sourceOutput)
        .instanceType(Ec2InstanceType.EC2)
        .instanceTagKey("Name")
        .instanceTagValue("MyInstance")
        .deploySpecifications(Ec2DeploySpecifications.inline(Ec2DeploySpecificationsInlineProps.builder()
                .targetDirectory("/home/ec2-user/deploy")
                .preScript("scripts/pre-deploy.sh")
                .postScript("scripts/post-deploy.sh")
                .build()))
        .build();
IStage deployStage = pipeline.addStage(StageOptions.builder()
        .stageName("Deploy")
        .actions(List.of(deployAction))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var sourceOutput = new Artifact();

var pipeline = new Pipeline(this, "MyPipeline", new PipelineProps {
    PipelineType = PipelineType.V2
});
var deployAction = new Ec2DeployAction(new Ec2DeployActionProps {
    ActionName = "Ec2Deploy",
    Input = sourceOutput,
    InstanceType = Ec2InstanceType.EC2,
    InstanceTagKey = "Name",
    InstanceTagValue = "MyInstance",
    DeploySpecifications = Ec2DeploySpecifications.Inline(new Ec2DeploySpecificationsInlineProps {
        TargetDirectory = "/home/ec2-user/deploy",
        PreScript = "scripts/pre-deploy.sh",
        PostScript = "scripts/post-deploy.sh"
    })
});
var deployStage = pipeline.AddStage(new StageOptions {
    StageName = "Deploy",
    Actions = new [] { deployAction }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
sourceOutput := codepipeline.NewArtifact()

pipeline := codepipeline.NewPipeline(this, jsii.String("MyPipeline"), &PipelineProps{
	PipelineType: codepipeline.PipelineType_V2,
})
deployAction := codepipeline_actions.NewEc2DeployAction(&Ec2DeployActionProps{
	ActionName: jsii.String("Ec2Deploy"),
	Input: sourceOutput,
	InstanceType: codepipeline_actions.Ec2InstanceType_EC2,
	InstanceTagKey: jsii.String("Name"),
	InstanceTagValue: jsii.String("MyInstance"),
	DeploySpecifications: codepipeline_actions.Ec2DeploySpecifications_Inline(&Ec2DeploySpecificationsInlineProps{
		TargetDirectory: jsii.String("/home/ec2-user/deploy"),
		PreScript: jsii.String("scripts/pre-deploy.sh"),
		PostScript: jsii.String("scripts/post-deploy.sh"),
	}),
})
deployStage := pipeline.AddStage(&StageOptions{
	StageName: jsii.String("Deploy"),
	Actions: []IAction{
		deployAction,
	},
})

Properties ​

actionNamestringaction_namestractionNameStringActionNamestringActionName*string required #
The physical, human-readable name of the Action.

Note that Action names must be unique within a single Stage.

deploySpecificationsEc2DeploySpecificationsdeploy_specificationsEc2DeploySpecificationsdeploySpecificationsEc2DeploySpecificationsDeploySpecificationsEc2DeploySpecificationsDeploySpecificationsEc2DeploySpecifications required #
The deploy specifications.
inputArtifactinputArtifactinputArtifactInputArtifactInputArtifact required #
The input artifact to deploy to EC2 instances.
instanceTagKeystringinstance_tag_keystrinstanceTagKeyStringInstanceTagKeystringInstanceTagKey*string required #
The tag key of the instances that you created in Amazon EC2.
instanceTagValueoptionalstringinstance_tag_valueoptionalstrinstanceTagValueoptionalStringInstanceTagValueoptionalstringInstanceTagValueoptional*string #
The tag value of the instances that you created in Amazon EC2.

Default: all instances with instanceTagKey will be matched

instanceTypeEc2InstanceTypeinstance_typeEc2InstanceTypeinstanceTypeEc2InstanceTypeInstanceTypeEc2InstanceTypeInstanceTypeEc2InstanceType required #
The type of instances or SSM nodes created in Amazon EC2.

You must have already created, tagged, and installed the SSM agent on all instances.

maxBatchoptionalEc2MaxInstancesmax_batchoptionalEc2MaxInstancesmaxBatchoptionalEc2MaxInstancesMaxBatchoptionalEc2MaxInstancesMaxBatchoptionalEc2MaxInstances #
The number or percentage of instances that can deploy in parallel.

Default: No configuration

maxErroroptionalEc2MaxInstancesmax_erroroptionalEc2MaxInstancesmaxErroroptionalEc2MaxInstancesMaxErroroptionalEc2MaxInstancesMaxErroroptionalEc2MaxInstances #
Stop the task after the task fails on the specified number or percentage of instances.

Default: No configuration

roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole #
The Role in which context's this Action will be executing in.

Default: a new Role will be generated

notes

The Pipeline's Role will assume this Role (the required permissions for that will be granted automatically) right before executing this Action. This Action will be passed into your IAction.bind method in the ActionBindOptions.role property.

runOrderoptionalnumberrun_orderoptionalint | floatrunOrderoptionalNumberRunOrderoptionaldoubleRunOrderoptional*float64 = 1 #
The runOrder property for this Action.

RunOrder determines the relative order in which multiple Actions in the same Stage execute.

targetGroupsoptionalITargetGroup[]target_groupsoptionaltyping.List[ITargetGroup]targetGroupsoptionalList<ITargetGroup>TargetGroupsoptionalITargetGroup[]TargetGroupsoptional*[]ITargetGroup #
The list of target groups for deployment. You must have already created the target groups.

Default: No target groups

Target groups provide a set of instances to process specific requests. If the target group is specified, instances will be removed from the target group before deployment and added back to the target group after deployment.

variablesNamespaceoptionalstringvariables_namespaceoptionalstrvariablesNamespaceoptionalStringVariablesNamespaceoptionalstringVariablesNamespaceoptional*string #
The name of the namespace to use for variables emitted by this action.

Default: a name will be generated, based on the stage and action names, if any of the action's variables were referenced - otherwise, no namespace will be set