Ec2DeployAction Class
CodePipeline Action to deploy EC2 instances.
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,
},
})
Initializer
ts
new Ec2DeployAction(props: Ec2DeployActionProps)
python
Ec2DeployAction(props: Ec2DeployActionProps)
java
new Ec2DeployAction(Ec2DeployActionProps props)
csharp
new Ec2DeployAction(Ec2DeployActionProps props)
go
NewEc2DeployAction(Props Ec2DeployActionProps)
Properties
actionPropertiesActionPropertiesaction_propertiesActionPropertiesactionPropertiesActionPropertiesActionPropertiesActionPropertiesActionPropertiesActionProperties#The simple properties of the Action, like its Owner, name, etc.
Note that this accessor will be called before the bind callback.
Methods
bind(scope: Construct, stage: IStage, options: ActionBindOptions): ActionConfigdef bind(self, scope: Construct, stage: IStage, options: ActionBindOptions) -> ActionConfigpublic ActionConfig bind(Construct scope, IStage stage, ActionBindOptions options)public ActionConfig Bind(Construct scope, IStage stage, ActionBindOptions options)func Bind(Scope Construct, Stage IStage, Options ActionBindOptions) ActionConfig#The callback invoked when this Action is added to a Pipeline.
onStateChange(name: string, target?: IRuleTarget, options?: RuleProps): Ruledef on_state_change(self, name: str, target: typing.Optional[IRuleTarget] = None, options: typing.Optional[RuleProps] = None) -> Rulepublic Rule onStateChange(String name, IRuleTarget target, RuleProps options)public Rule OnStateChange(string name, IRuleTarget? target = null, RuleProps? options = null)func OnStateChange(Name *string, Target IRuleTarget, Options RuleProps) Rule#Creates an Event that will be triggered whenever the state of this Action changes.