CreateDeploymentCommand

Deploys an application revision through the specified deployment group.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { CodeDeployClient, CreateDeploymentCommand } from "@aws-sdk/client-codedeploy"; // ES Modules import
// const { CodeDeployClient, CreateDeploymentCommand } = require("@aws-sdk/client-codedeploy"); // CommonJS import
const client = new CodeDeployClient(config);
const input = { // CreateDeploymentInput
  applicationName: "STRING_VALUE", // required
  deploymentGroupName: "STRING_VALUE",
  revision: { // RevisionLocation
    revisionType: "S3" || "GitHub" || "String" || "AppSpecContent",
    s3Location: { // S3Location
      bucket: "STRING_VALUE",
      key: "STRING_VALUE",
      bundleType: "tar" || "tgz" || "zip" || "YAML" || "JSON",
      version: "STRING_VALUE",
      eTag: "STRING_VALUE",
    },
    gitHubLocation: { // GitHubLocation
      repository: "STRING_VALUE",
      commitId: "STRING_VALUE",
    },
    string: { // RawString
      content: "STRING_VALUE",
      sha256: "STRING_VALUE",
    },
    appSpecContent: { // AppSpecContent
      content: "STRING_VALUE",
      sha256: "STRING_VALUE",
    },
  },
  deploymentConfigName: "STRING_VALUE",
  description: "STRING_VALUE",
  ignoreApplicationStopFailures: true || false,
  targetInstances: { // TargetInstances
    tagFilters: [ // EC2TagFilterList
      { // EC2TagFilter
        Key: "STRING_VALUE",
        Value: "STRING_VALUE",
        Type: "KEY_ONLY" || "VALUE_ONLY" || "KEY_AND_VALUE",
      },
    ],
    autoScalingGroups: [ // AutoScalingGroupNameList
      "STRING_VALUE",
    ],
    ec2TagSet: { // EC2TagSet
      ec2TagSetList: [ // EC2TagSetList
        [
          {
            Key: "STRING_VALUE",
            Value: "STRING_VALUE",
            Type: "KEY_ONLY" || "VALUE_ONLY" || "KEY_AND_VALUE",
          },
        ],
      ],
    },
  },
  autoRollbackConfiguration: { // AutoRollbackConfiguration
    enabled: true || false,
    events: [ // AutoRollbackEventsList
      "DEPLOYMENT_FAILURE" || "DEPLOYMENT_STOP_ON_ALARM" || "DEPLOYMENT_STOP_ON_REQUEST",
    ],
  },
  updateOutdatedInstancesOnly: true || false,
  fileExistsBehavior: "DISALLOW" || "OVERWRITE" || "RETAIN",
  overrideAlarmConfiguration: { // AlarmConfiguration
    enabled: true || false,
    ignorePollAlarmFailure: true || false,
    alarms: [ // AlarmList
      { // Alarm
        name: "STRING_VALUE",
      },
    ],
  },
};
const command = new CreateDeploymentCommand(input);
const response = await client.send(command);
// { // CreateDeploymentOutput
//   deploymentId: "STRING_VALUE",
// };

CreateDeploymentCommand Input

See CreateDeploymentCommandInput for more details

Parameter
Type
Description
applicationName
Required
string | undefined

The name of an CodeDeploy application associated with the user or Amazon Web Services account.

autoRollbackConfiguration
AutoRollbackConfiguration | undefined

Configuration information for an automatic rollback that is added when a deployment is created.

deploymentConfigName
string | undefined

The name of a deployment configuration associated with the user or Amazon Web Services account.

If not specified, the value configured in the deployment group is used as the default. If the deployment group does not have a deployment configuration associated with it, CodeDeployDefault.OneAtATime is used by default.

deploymentGroupName
string | undefined

The name of the deployment group.

description
string | undefined

A comment about the deployment.

fileExistsBehavior
FileExistsBehavior | undefined

Information about how CodeDeploy handles files that already exist in a deployment target location but weren't part of the previous successful deployment.

The fileExistsBehavior parameter takes any of the following values:

  • DISALLOW: The deployment fails. This is also the default behavior if no option is specified.

  • OVERWRITE: The version of the file from the application revision currently being deployed replaces the version already on the instance.

  • RETAIN: The version of the file already on the instance is kept and used as part of the new deployment.

ignoreApplicationStopFailures
boolean | undefined

If true, then if an ApplicationStop, BeforeBlockTraffic, or AfterBlockTraffic deployment lifecycle event to an instance fails, then the deployment continues to the next deployment lifecycle event. For example, if ApplicationStop fails, the deployment continues with DownloadBundle. If BeforeBlockTraffic fails, the deployment continues with BlockTraffic. If AfterBlockTraffic fails, the deployment continues with ApplicationStop.

If false or not specified, then if a lifecycle event fails during a deployment to an instance, that deployment fails. If deployment to that instance is part of an overall deployment and the number of healthy hosts is not less than the minimum number of healthy hosts, then a deployment to the next instance is attempted.

During a deployment, the CodeDeploy agent runs the scripts specified for ApplicationStop, BeforeBlockTraffic, and AfterBlockTraffic in the AppSpec file from the previous successful deployment. (All other scripts are run from the AppSpec file in the current deployment.) If one of these scripts contains an error and does not run successfully, the deployment can fail.

If the cause of the failure is a script from the last successful deployment that will never run successfully, create a new deployment and use ignoreApplicationStopFailures to specify that the ApplicationStop, BeforeBlockTraffic, and AfterBlockTraffic failures should be ignored.

overrideAlarmConfiguration
AlarmConfiguration | undefined

Allows you to specify information about alarms associated with a deployment. The alarm configuration that you specify here will override the alarm configuration at the deployment group level. Consider overriding the alarm configuration if you have set up alarms at the deployment group level that are causing deployment failures. In this case, you would call CreateDeployment to create a new deployment that uses a previous application revision that is known to work, and set its alarm configuration to turn off alarm polling. Turning off alarm polling ensures that the new deployment proceeds without being blocked by the alarm that was generated by the previous, failed, deployment.

If you specify an overrideAlarmConfiguration, you need the UpdateDeploymentGroup IAM permission when calling CreateDeployment.

revision
RevisionLocation | undefined

The type and location of the revision to deploy.

targetInstances
TargetInstances | undefined

Information about the instances that belong to the replacement environment in a blue/green deployment.

updateOutdatedInstancesOnly
boolean | undefined

Indicates whether to deploy to all instances or only to instances that are not running the latest application revision.

CreateDeploymentCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
deploymentId
string | undefined

The unique ID of a deployment.

Throws

Name
Fault
Details
AlarmsLimitExceededException
client

The maximum number of alarms for a deployment group (10) was exceeded.

ApplicationDoesNotExistException
client

The application does not exist with the user or Amazon Web Services account.

ApplicationNameRequiredException
client

The minimum number of required application names was not specified.

DeploymentConfigDoesNotExistException
client

The deployment configuration does not exist with the user or Amazon Web Services account.

DeploymentGroupDoesNotExistException
client

The named deployment group with the user or Amazon Web Services account does not exist.

DeploymentGroupNameRequiredException
client

The deployment group name was not specified.

DeploymentLimitExceededException
client

The number of allowed deployments was exceeded.

DescriptionTooLongException
client

The description is too long.

InvalidAlarmConfigException
client

The format of the alarm configuration is invalid. Possible causes include:

  • The alarm list is null.

  • The alarm object is null.

  • The alarm name is empty or null or exceeds the limit of 255 characters.

  • Two alarms with the same name have been specified.

  • The alarm configuration is enabled, but the alarm list is empty.

InvalidApplicationNameException
client

The application name was specified in an invalid format.

InvalidAutoRollbackConfigException
client

The automatic rollback configuration was specified in an invalid format. For example, automatic rollback is enabled, but an invalid triggering event type or no event types were listed.

InvalidAutoScalingGroupException
client

The Auto Scaling group was specified in an invalid format or does not exist.

InvalidDeploymentConfigNameException
client

The deployment configuration name was specified in an invalid format.

InvalidDeploymentGroupNameException
client

The deployment group name was specified in an invalid format.

InvalidFileExistsBehaviorException
client

An invalid fileExistsBehavior option was specified to determine how CodeDeploy handles files or directories that already exist in a deployment target location, but weren't part of the previous successful deployment. Valid values include "DISALLOW," "OVERWRITE," and "RETAIN."

InvalidGitHubAccountTokenException
client

The GitHub token is not valid.

InvalidIgnoreApplicationStopFailuresValueException
client

The IgnoreApplicationStopFailures value is invalid. For Lambda deployments, false is expected. For EC2/On-premises deployments, true or false is expected.

InvalidLoadBalancerInfoException
client

An invalid load balancer name, or no load balancer name, was specified.

InvalidRevisionException
client

The revision was specified in an invalid format.

InvalidRoleException
client

The service role ARN was specified in an invalid format. Or, if an Auto Scaling group was specified, the specified service role does not grant the appropriate permissions to Amazon EC2 Auto Scaling.

InvalidTargetInstancesException
client

The target instance configuration is invalid. Possible causes include:

  • Configuration data for target instances was entered for an in-place deployment.

  • The limit of 10 tags for a tag type was exceeded.

  • The combined length of the tag names exceeded the limit.

  • A specified tag is not currently applied to any instances.

InvalidTrafficRoutingConfigurationException
client

The configuration that specifies how traffic is routed during a deployment is invalid.

InvalidUpdateOutdatedInstancesOnlyValueException
client

The UpdateOutdatedInstancesOnly value is invalid. For Lambda deployments, false is expected. For EC2/On-premises deployments, true or false is expected.

RevisionDoesNotExistException
client

The named revision does not exist with the user or Amazon Web Services account.

RevisionRequiredException
client

The revision ID was not specified.

ThrottlingException
client

An API function was called too frequently.

CodeDeployServiceException
Base exception class for all service exceptions from CodeDeploy service.