# Ec2DeployAction

CodePipeline Action to deploy EC2 instances.

Extends: Action › Action › Ec2DeployAction
Implements: IAction

- Source: [`aws-codepipeline-actions/lib/ec2/deploy-action.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-codepipeline-actions/lib/ec2/deploy-action.ts#L178)
- Type last changed: v2.201.0 · 13 Jun 2025

## 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],
});
```

## Initializer

```ts
new Ec2DeployAction(props: Ec2DeployActionProps)
```

## Properties

- `actionProperties`: [ActionProperties](/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline.ActionProperties.html) — 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): ActionConfig` — The callback invoked when this Action is added to a Pipeline.

- `onStateChange(name: string, target?: IRuleTarget, options?: RuleProps): Rule` — Creates an Event that will be triggered whenever the state of this Action changes.
