Skip to content
v2.274.0

EcsDeployAction Class ​

CodePipeline Action to deploy an ECS Service.

Example ​

ts
import * as ecs from 'aws-cdk-lib/aws-ecs';

declare const service: ecs.FargateService;
const pipeline = new codepipeline.Pipeline(this, 'MyPipeline');
const buildOutput = new codepipeline.Artifact();
const deployStage = pipeline.addStage({
  stageName: 'Deploy',
  actions: [
    new codepipeline_actions.EcsDeployAction({
      actionName: 'DeployAction',
      service,
      // if your file is called imagedefinitions.json,
      // use the `input` property,
      // and leave out the `imageFile` property
      input: buildOutput,
      // if your file name is _not_ imagedefinitions.json,
      // use the `imageFile` property,
      // and leave out the `input` property
      imageFile: buildOutput.atPath('imageDef.json'),
      deploymentTimeout: Duration.minutes(60), // optional, default is 60 minutes
    }),
  ],
});
python
import aws_cdk.aws_ecs as ecs

# service: ecs.FargateService

pipeline = codepipeline.Pipeline(self, "MyPipeline")
build_output = codepipeline.Artifact()
deploy_stage = pipeline.add_stage(
    stage_name="Deploy",
    actions=[
        codepipeline_actions.EcsDeployAction(
            action_name="DeployAction",
            service=service,
            # if your file is called imagedefinitions.json,
            # use the `input` property,
            # and leave out the `imageFile` property
            input=build_output,
            # if your file name is _not_ imagedefinitions.json,
            # use the `imageFile` property,
            # and leave out the `input` property
            image_file=build_output.at_path("imageDef.json"),
            deployment_timeout=Duration.minutes(60)
        )
    ]
)
java
import software.amazon.awscdk.services.ecs.*;

FargateService service;

Pipeline pipeline = new Pipeline(this, "MyPipeline");
Artifact buildOutput = new Artifact();
IStage deployStage = pipeline.addStage(StageOptions.builder()
        .stageName("Deploy")
        .actions(List.of(
            EcsDeployAction.Builder.create()
                    .actionName("DeployAction")
                    .service(service)
                    // if your file is called imagedefinitions.json,
                    // use the `input` property,
                    // and leave out the `imageFile` property
                    .input(buildOutput)
                    // if your file name is _not_ imagedefinitions.json,
                    // use the `imageFile` property,
                    // and leave out the `input` property
                    .imageFile(buildOutput.atPath("imageDef.json"))
                    .deploymentTimeout(Duration.minutes(60))
                    .build()))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.ECS;

FargateService service;

var pipeline = new Pipeline(this, "MyPipeline");
var buildOutput = new Artifact();
var deployStage = pipeline.AddStage(new StageOptions {
    StageName = "Deploy",
    Actions = new [] {
        new EcsDeployAction(new EcsDeployActionProps {
            ActionName = "DeployAction",
            Service = service,
            // if your file is called imagedefinitions.json,
            // use the `input` property,
            // and leave out the `imageFile` property
            Input = buildOutput,
            // if your file name is _not_ imagedefinitions.json,
            // use the `imageFile` property,
            // and leave out the `input` property
            ImageFile = buildOutput.AtPath("imageDef.json"),
            DeploymentTimeout = Duration.Minutes(60)
        }) }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import ecs "github.com/aws/aws-cdk-go/awscdk"

var service FargateService

pipeline := codepipeline.NewPipeline(this, jsii.String("MyPipeline"))
buildOutput := codepipeline.NewArtifact()
deployStage := pipeline.AddStage(&StageOptions{
	StageName: jsii.String("Deploy"),
	Actions: []IAction{
		codepipeline_actions.NewEcsDeployAction(&EcsDeployActionProps{
			ActionName: jsii.String("DeployAction"),
			Service: *Service,
			// if your file is called imagedefinitions.json,
			// use the `input` property,
			// and leave out the `imageFile` property
			Input: buildOutput,
			// if your file name is _not_ imagedefinitions.json,
			// use the `imageFile` property,
			// and leave out the `input` property
			ImageFile: buildOutput.AtPath(jsii.String("imageDef.json")),
			DeploymentTimeout: awscdk.Duration_Minutes(jsii.Number(60)),
		}),
	},
})

Initializer ​

ts
new EcsDeployAction(props: EcsDeployActionProps)
python
EcsDeployAction(props: EcsDeployActionProps)
java
new EcsDeployAction(EcsDeployActionProps props)
csharp
new EcsDeployAction(EcsDeployActionProps props)
go
NewEcsDeployAction(Props EcsDeployActionProps)

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.