Skip to content

create_deployment

create_deployment(
    application_name: ApplicationName,
    *,
    config_overrides: Optional[CodeDeployClientConfig] = None,
    deployment_group_name: Optional[DeploymentGroupName] = None,
    revision: Optional[RevisionLocation] = None,
    deployment_config_name: Optional[DeploymentConfigName] = None,
    description: Optional[Description] = None,
    ignore_application_stop_failures: Optional[Boolean] = None,
    target_instances: Optional[TargetInstances] = None,
    auto_rollback_configuration: Optional[AutoRollbackConfiguration] = None,
    update_outdated_instances_only: Optional[Boolean] = None,
    file_exists_behavior: Optional[FileExistsBehavior] = None,
    deployment_mode: Optional[DeploymentMode] = None,
    override_alarm_configuration: Optional[AlarmConfiguration] = None,
) -> CreateDeploymentOutput

Deploys an application revision through the specified deployment group.

Parameters:

  • application_name (ApplicationName) –

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

  • deployment_group_name (Optional[DeploymentGroupName], default: None ) –

    The name of the deployment group.

  • revision (Optional[RevisionLocation], default: None ) –

    The type and location of the revision to deploy.

  • deployment_config_name (Optional[DeploymentConfigName], default: None ) –

    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.

  • description (Optional[Description], default: None ) –

    A comment about the deployment.

  • ignore_application_stop_failures (Optional[Boolean], default: None ) –

    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.

  • target_instances (Optional[TargetInstances], default: None ) –

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

  • auto_rollback_configuration (Optional[AutoRollbackConfiguration], default: None ) –

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

  • update_outdated_instances_only (Optional[Boolean], default: None ) –

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

  • file_exists_behavior (Optional[FileExistsBehavior], default: None ) –

    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.

  • deployment_mode (Optional[DeploymentMode], default: None ) –

    The type of deployment to create. Valid values are:

    • STANDARD: Deploys the specified revision. This is the default behavior if deploymentMode is not specified.

    • RESTART: Restarts the application on the target instances using the revision from the deployment group's last successful deployment, without downloading a new revision. RESTART is supported only for EC2/On-premises in-place deployments.

      When deploymentMode is RESTART, the following apply:

      • The call is rejected for Amazon ECS and Lambda deployments.

      • The revision parameter (including its s3Location and gitHubLocation) must not be specified, and is rejected if provided. The revision is resolved by the service from the deployment group's last successful deployment.

      • The updateOutdatedInstancesOnly parameter must not be set to true, and is rejected if provided.

  • override_alarm_configuration (Optional[AlarmConfiguration], default: None ) –

    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.

Raises:

Source code in docs_src/capo_codedeploy/_services/code_deploy.py
def create_deployment(
    self,
    application_name: "capo_codedeploy.types.application_name.ApplicationName",
    *,
    config_overrides: Optional[CodeDeployClientConfig] = None,
    deployment_group_name: Optional[
        "capo_codedeploy.types.deployment_group_name.DeploymentGroupName"
    ] = None,
    revision: Optional[
        "capo_codedeploy.types.revision_location.RevisionLocation"
    ] = None,
    deployment_config_name: Optional[
        "capo_codedeploy.types.deployment_config_name.DeploymentConfigName"
    ] = None,
    description: Optional["capo_codedeploy.types.description.Description"] = None,
    ignore_application_stop_failures: Optional[
        "capo_codedeploy.types.boolean.Boolean"
    ] = None,
    target_instances: Optional[
        "capo_codedeploy.types.target_instances.TargetInstances"
    ] = None,
    auto_rollback_configuration: Optional[
        "capo_codedeploy.types.auto_rollback_configuration.AutoRollbackConfiguration"
    ] = None,
    update_outdated_instances_only: Optional[
        "capo_codedeploy.types.boolean.Boolean"
    ] = None,
    file_exists_behavior: Optional[
        "capo_codedeploy.types.file_exists_behavior.FileExistsBehavior"
    ] = None,
    deployment_mode: Optional[
        "capo_codedeploy.types.deployment_mode.DeploymentMode"
    ] = None,
    override_alarm_configuration: Optional[
        "capo_codedeploy.types.alarm_configuration.AlarmConfiguration"
    ] = None,
) -> "capo_codedeploy.types.create_deployment_output.CreateDeploymentOutput":
    """<p>Deploys an application revision through the specified deployment group.</p>

    Args:
        application_name: <p>The name of an CodeDeploy application associated with the user or Amazon Web Services account.</p>
        deployment_group_name: <p>The name of the deployment group.</p>
        revision: <p> The type and location of the revision to deploy. </p>
        deployment_config_name: <p>The name of a deployment configuration associated with the user or Amazon Web Services account.</p> <p>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, <code>CodeDeployDefault</code>.<code>OneAtATime</code> is used by default.</p>
        description: <p>A comment about the deployment.</p>
        ignore_application_stop_failures: <p> If true, then if an <code>ApplicationStop</code>, <code>BeforeBlockTraffic</code>, or <code>AfterBlockTraffic</code> deployment lifecycle event to an instance fails, then the deployment continues to the next deployment lifecycle event. For example, if <code>ApplicationStop</code> fails, the deployment continues with <code>DownloadBundle</code>. If <code>BeforeBlockTraffic</code> fails, the deployment continues with <code>BlockTraffic</code>. If <code>AfterBlockTraffic</code> fails, the deployment continues with <code>ApplicationStop</code>. </p> <p> 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. </p> <p> During a deployment, the CodeDeploy agent runs the scripts specified for <code>ApplicationStop</code>, <code>BeforeBlockTraffic</code>, and <code>AfterBlockTraffic</code> 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. </p> <p> 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 <code>ignoreApplicationStopFailures</code> to specify that the <code>ApplicationStop</code>, <code>BeforeBlockTraffic</code>, and <code>AfterBlockTraffic</code> failures should be ignored. </p>
        target_instances: <p> Information about the instances that belong to the replacement environment in a blue/green deployment. </p>
        auto_rollback_configuration: <p>Configuration information for an automatic rollback that is added when a deployment is created.</p>
        update_outdated_instances_only: <p> Indicates whether to deploy to all instances or only to instances that are not running the latest application revision. </p>
        file_exists_behavior: <p>Information about how CodeDeploy handles files that already exist in a deployment target location but weren't part of the previous successful deployment.</p> <p>The <code>fileExistsBehavior</code> parameter takes any of the following values:</p> <ul> <li> <p>DISALLOW: The deployment fails. This is also the default behavior if no option is specified.</p> </li> <li> <p>OVERWRITE: The version of the file from the application revision currently being deployed replaces the version already on the instance.</p> </li> <li> <p>RETAIN: The version of the file already on the instance is kept and used as part of the new deployment.</p> </li> </ul>
        deployment_mode: <p>The type of deployment to create. Valid values are:</p> <ul> <li> <p> <code>STANDARD</code>: Deploys the specified revision. This is the default behavior if <code>deploymentMode</code> is not specified.</p> </li> <li> <p> <code>RESTART</code>: Restarts the application on the target instances using the revision from the deployment group's last successful deployment, without downloading a new revision. <code>RESTART</code> is supported only for EC2/On-premises in-place deployments.</p> <p>When <code>deploymentMode</code> is <code>RESTART</code>, the following apply:</p> <ul> <li> <p>The call is rejected for Amazon ECS and Lambda deployments.</p> </li> <li> <p>The <code>revision</code> parameter (including its <code>s3Location</code> and <code>gitHubLocation</code>) must not be specified, and is rejected if provided. The revision is resolved by the service from the deployment group's last successful deployment.</p> </li> <li> <p>The <code>updateOutdatedInstancesOnly</code> parameter must not be set to <code>true</code>, and is rejected if provided.</p> </li> </ul> </li> </ul>
        override_alarm_configuration: <p>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 <code>CreateDeployment</code> 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.</p> <note> <p>If you specify an <code>overrideAlarmConfiguration</code>, you need the <code>UpdateDeploymentGroup</code> IAM permission when calling <code>CreateDeployment</code>.</p> </note>

    Raises:
        capo_codedeploy.errors.alarms_limit_exceeded_exception.AlarmsLimitExceededException: <p>The maximum number of alarms for a deployment group (10) was exceeded.</p>
        capo_codedeploy.errors.application_does_not_exist_exception.ApplicationDoesNotExistException: <p>The application does not exist with the user or Amazon Web Services account.</p>
        capo_codedeploy.errors.application_name_required_exception.ApplicationNameRequiredException: <p>The minimum number of required application names was not specified.</p>
        capo_codedeploy.errors.deployment_config_does_not_exist_exception.DeploymentConfigDoesNotExistException: <p>The deployment configuration does not exist with the user or Amazon Web Services account.</p>
        capo_codedeploy.errors.deployment_group_does_not_exist_exception.DeploymentGroupDoesNotExistException: <p>The named deployment group with the user or Amazon Web Services account does not exist.</p>
        capo_codedeploy.errors.deployment_group_name_required_exception.DeploymentGroupNameRequiredException: <p>The deployment group name was not specified.</p>
        capo_codedeploy.errors.deployment_limit_exceeded_exception.DeploymentLimitExceededException: <p>The number of allowed deployments was exceeded.</p>
        capo_codedeploy.errors.description_too_long_exception.DescriptionTooLongException: <p>The description is too long.</p>
        capo_codedeploy.errors.invalid_alarm_config_exception.InvalidAlarmConfigException: <p>The format of the alarm configuration is invalid. Possible causes include:</p> <ul> <li> <p>The alarm list is null.</p> </li> <li> <p>The alarm object is null.</p> </li> <li> <p>The alarm name is empty or null or exceeds the limit of 255 characters.</p> </li> <li> <p>Two alarms with the same name have been specified.</p> </li> <li> <p>The alarm configuration is enabled, but the alarm list is empty.</p> </li> </ul>
        capo_codedeploy.errors.invalid_application_name_exception.InvalidApplicationNameException: <p>The application name was specified in an invalid format.</p>
        capo_codedeploy.errors.invalid_auto_rollback_config_exception.InvalidAutoRollbackConfigException: <p>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.</p>
        capo_codedeploy.errors.invalid_auto_scaling_group_exception.InvalidAutoScalingGroupException: <p>The Auto Scaling group was specified in an invalid format or does not exist.</p>
        capo_codedeploy.errors.invalid_compute_platform_exception.InvalidComputePlatformException: <p>The computePlatform is invalid. The computePlatform should be <code>Lambda</code>, <code>Server</code>, or <code>ECS</code>.</p>
        capo_codedeploy.errors.invalid_deployment_config_name_exception.InvalidDeploymentConfigNameException: <p>The deployment configuration name was specified in an invalid format.</p>
        capo_codedeploy.errors.invalid_deployment_group_name_exception.InvalidDeploymentGroupNameException: <p>The deployment group name was specified in an invalid format.</p>
        capo_codedeploy.errors.invalid_ecs_service_exception.InvalidECSServiceException: <p> The Amazon ECS service identifier is not valid. </p>
        capo_codedeploy.errors.invalid_file_exists_behavior_exception.InvalidFileExistsBehaviorException: <p>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."</p>
        capo_codedeploy.errors.invalid_git_hub_account_token_exception.InvalidGitHubAccountTokenException: <p>The GitHub token is not valid.</p>
        capo_codedeploy.errors.invalid_ignore_application_stop_failures_value_exception.InvalidIgnoreApplicationStopFailuresValueException: <p>The IgnoreApplicationStopFailures value is invalid. For Lambda deployments, <code>false</code> is expected. For EC2/On-premises deployments, <code>true</code> or <code>false</code> is expected.</p>
        capo_codedeploy.errors.invalid_input_exception.InvalidInputException: <p>The input was specified in an invalid format.</p>
        capo_codedeploy.errors.invalid_load_balancer_info_exception.InvalidLoadBalancerInfoException: <p>An invalid load balancer name, or no load balancer name, was specified.</p>
        capo_codedeploy.errors.invalid_revision_exception.InvalidRevisionException: <p>The revision was specified in an invalid format.</p>
        capo_codedeploy.errors.invalid_role_exception.InvalidRoleException: <p>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.</p>
        capo_codedeploy.errors.invalid_target_instances_exception.InvalidTargetInstancesException: <p>The target instance configuration is invalid. Possible causes include:</p> <ul> <li> <p>Configuration data for target instances was entered for an in-place deployment.</p> </li> <li> <p>The limit of 10 tags for a tag type was exceeded.</p> </li> <li> <p>The combined length of the tag names exceeded the limit. </p> </li> <li> <p>A specified tag is not currently applied to any instances.</p> </li> </ul>
        capo_codedeploy.errors.invalid_traffic_routing_configuration_exception.InvalidTrafficRoutingConfigurationException: <p> The configuration that specifies how traffic is routed during a deployment is invalid.</p>
        capo_codedeploy.errors.invalid_update_outdated_instances_only_value_exception.InvalidUpdateOutdatedInstancesOnlyValueException: <p>The UpdateOutdatedInstancesOnly value is invalid. For Lambda deployments, <code>false</code> is expected. For EC2/On-premises deployments, <code>true</code> or <code>false</code> is expected.</p>
        capo_codedeploy.errors.revision_does_not_exist_exception.RevisionDoesNotExistException: <p>The named revision does not exist with the user or Amazon Web Services account.</p>
        capo_codedeploy.errors.revision_required_exception.RevisionRequiredException: <p>The revision ID was not specified.</p>
        capo_codedeploy.errors.throttling_exception.ThrottlingException: <p>An API function was called too frequently.</p>
        capo_codedeploy.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_codedeploy.types.create_deployment_input.CreateDeploymentInput]",
    ) -> OperationResponse[
        "capo_codedeploy.types.create_deployment_output.CreateDeploymentOutput"
    ]:
        import capo_codedeploy._operations.code_deploy_20141006.create_deployment

        output, http_response = (
            capo_codedeploy._operations.code_deploy_20141006.create_deployment.create_deployment(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateDeployment")
    )
    input_: capo_codedeploy.types.create_deployment_input.CreateDeploymentInput = {
        "application_name": application_name
    }
    if deployment_group_name is not None:
        input_["deployment_group_name"] = deployment_group_name
    if revision is not None:
        input_["revision"] = revision
    if deployment_config_name is not None:
        input_["deployment_config_name"] = deployment_config_name
    if description is not None:
        input_["description"] = description
    if ignore_application_stop_failures is not None:
        input_["ignore_application_stop_failures"] = (
            ignore_application_stop_failures
        )
    if target_instances is not None:
        input_["target_instances"] = target_instances
    if auto_rollback_configuration is not None:
        input_["auto_rollback_configuration"] = auto_rollback_configuration
    if update_outdated_instances_only is not None:
        input_["update_outdated_instances_only"] = update_outdated_instances_only
    if file_exists_behavior is not None:
        input_["file_exists_behavior"] = file_exists_behavior
    if deployment_mode is not None:
        input_["deployment_mode"] = deployment_mode
    if override_alarm_configuration is not None:
        input_["override_alarm_configuration"] = override_alarm_configuration

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output