CodeDeploy / Client / create_deployment

create_deployment#

CodeDeploy.Client.create_deployment(**kwargs)#

Deploys an application revision through the specified deployment group.

See also: AWS API Documentation

Request Syntax

response = client.create_deployment(
    applicationName='string',
    deploymentGroupName='string',
    revision={
        'revisionType': 'S3'|'GitHub'|'String'|'AppSpecContent',
        's3Location': {
            'bucket': 'string',
            'key': 'string',
            'bundleType': 'tar'|'tgz'|'zip'|'YAML'|'JSON',
            'version': 'string',
            'eTag': 'string'
        },
        'gitHubLocation': {
            'repository': 'string',
            'commitId': 'string'
        },
        'string': {
            'content': 'string',
            'sha256': 'string'
        },
        'appSpecContent': {
            'content': 'string',
            'sha256': 'string'
        }
    },
    deploymentConfigName='string',
    description='string',
    ignoreApplicationStopFailures=True|False,
    targetInstances={
        'tagFilters': [
            {
                'Key': 'string',
                'Value': 'string',
                'Type': 'KEY_ONLY'|'VALUE_ONLY'|'KEY_AND_VALUE'
            },
        ],
        'autoScalingGroups': [
            'string',
        ],
        'ec2TagSet': {
            'ec2TagSetList': [
                [
                    {
                        'Key': 'string',
                        'Value': 'string',
                        'Type': 'KEY_ONLY'|'VALUE_ONLY'|'KEY_AND_VALUE'
                    },
                ],
            ]
        }
    },
    autoRollbackConfiguration={
        'enabled': True|False,
        'events': [
            'DEPLOYMENT_FAILURE'|'DEPLOYMENT_STOP_ON_ALARM'|'DEPLOYMENT_STOP_ON_REQUEST',
        ]
    },
    updateOutdatedInstancesOnly=True|False,
    fileExistsBehavior='DISALLOW'|'OVERWRITE'|'RETAIN',
    overrideAlarmConfiguration={
        'enabled': True|False,
        'ignorePollAlarmFailure': True|False,
        'alarms': [
            {
                'name': 'string'
            },
        ]
    }
)
Parameters:
  • applicationName (string) –

    [REQUIRED]

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

  • deploymentGroupName (string) – The name of the deployment group.

  • revision (dict) –

    The type and location of the revision to deploy.

    • revisionType (string) –

      The type of application revision:

      • S3: An application revision stored in Amazon S3.

      • GitHub: An application revision stored in GitHub (EC2/On-premises deployments only).

      • String: A YAML-formatted or JSON-formatted string (Lambda deployments only).

      • AppSpecContent: An AppSpecContent object that contains the contents of an AppSpec file for an Lambda or Amazon ECS deployment. The content is formatted as JSON or YAML stored as a RawString.

    • s3Location (dict) –

      Information about the location of a revision stored in Amazon S3.

      • bucket (string) –

        The name of the Amazon S3 bucket where the application revision is stored.

      • key (string) –

        The name of the Amazon S3 object that represents the bundled artifacts for the application revision.

      • bundleType (string) –

        The file type of the application revision. Must be one of the following:

        • tar: A tar archive file.

        • tgz: A compressed tar archive file.

        • zip: A zip archive file.

        • YAML: A YAML-formatted file.

        • JSON: A JSON-formatted file.

      • version (string) –

        A specific version of the Amazon S3 object that represents the bundled artifacts for the application revision.

        If the version is not specified, the system uses the most recent version by default.

      • eTag (string) –

        The ETag of the Amazon S3 object that represents the bundled artifacts for the application revision.

        If the ETag is not specified as an input parameter, ETag validation of the object is skipped.

    • gitHubLocation (dict) –

      Information about the location of application artifacts stored in GitHub.

      • repository (string) –

        The GitHub account and repository pair that stores a reference to the commit that represents the bundled artifacts for the application revision.

        Specified as account/repository.

      • commitId (string) –

        The SHA1 commit ID of the GitHub commit that represents the bundled artifacts for the application revision.

    • string (dict) –

      Information about the location of an Lambda deployment revision stored as a RawString.

      • content (string) –

        The YAML-formatted or JSON-formatted revision string. It includes information about which Lambda function to update and optional Lambda functions that validate deployment lifecycle events.

      • sha256 (string) –

        The SHA256 hash value of the revision content.

    • appSpecContent (dict) –

      The content of an AppSpec file for an Lambda or Amazon ECS deployment. The content is formatted as JSON or YAML and stored as a RawString.

      • content (string) –

        The YAML-formatted or JSON-formatted revision string.

        For an Lambda deployment, the content includes a Lambda function name, the alias for its original version, and the alias for its replacement version. The deployment shifts traffic from the original version of the Lambda function to the replacement version.

        For an Amazon ECS deployment, the content includes the task name, information about the load balancer that serves traffic to the container, and more.

        For both types of deployments, the content can specify Lambda functions that run at specified hooks, such as BeforeInstall, during a deployment.

      • sha256 (string) –

        The SHA256 hash value of the revision content.

  • deploymentConfigName (string) –

    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 (string) – A comment about the deployment.

  • ignoreApplicationStopFailures (boolean) –

    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.

  • targetInstances (dict) –

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

    • tagFilters (list) –

      The tag filter key, type, and value used to identify Amazon EC2 instances in a replacement environment for a blue/green deployment. Cannot be used in the same call as ec2TagSet.

      • (dict) –

        Information about an EC2 tag filter.

        • Key (string) –

          The tag filter key.

        • Value (string) –

          The tag filter value.

        • Type (string) –

          The tag filter type:

          • KEY_ONLY: Key only.

          • VALUE_ONLY: Value only.

          • KEY_AND_VALUE: Key and value.

    • autoScalingGroups (list) –

      The names of one or more Auto Scaling groups to identify a replacement environment for a blue/green deployment.

      • (string) –

    • ec2TagSet (dict) –

      Information about the groups of Amazon EC2 instance tags that an instance must be identified by in order for it to be included in the replacement environment for a blue/green deployment. Cannot be used in the same call as tagFilters.

      • ec2TagSetList (list) –

        A list that contains other lists of Amazon EC2 instance tag groups. For an instance to be included in the deployment group, it must be identified by all of the tag groups in the list.

        • (list) –

          • (dict) –

            Information about an EC2 tag filter.

            • Key (string) –

              The tag filter key.

            • Value (string) –

              The tag filter value.

            • Type (string) –

              The tag filter type:

              • KEY_ONLY: Key only.

              • VALUE_ONLY: Value only.

              • KEY_AND_VALUE: Key and value.

  • autoRollbackConfiguration (dict) –

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

    • enabled (boolean) –

      Indicates whether a defined automatic rollback configuration is currently enabled.

    • events (list) –

      The event type or types that trigger a rollback.

      • (string) –

  • updateOutdatedInstancesOnly (boolean) – Indicates whether to deploy to all instances or only to instances that are not running the latest application revision.

  • fileExistsBehavior (string) –

    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.

  • overrideAlarmConfiguration (dict) –

    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.

    Note

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

    • enabled (boolean) –

      Indicates whether the alarm configuration is enabled.

    • ignorePollAlarmFailure (boolean) –

      Indicates whether a deployment should continue if information about the current state of alarms cannot be retrieved from Amazon CloudWatch. The default value is false.

      • true: The deployment proceeds even if alarm status information can’t be retrieved from Amazon CloudWatch.

      • false: The deployment stops if alarm status information can’t be retrieved from Amazon CloudWatch.

    • alarms (list) –

      A list of alarms configured for the deployment or deployment group. A maximum of 10 alarms can be added.

      • (dict) –

        Information about an alarm.

        • name (string) –

          The name of the alarm. Maximum length is 255 characters. Each alarm name can be used only once in a list of alarms.

Return type:

dict

Returns:

Response Syntax

{
    'deploymentId': 'string'
}

Response Structure

  • (dict) –

    Represents the output of a CreateDeployment operation.

    • deploymentId (string) –

      The unique ID of a deployment.

Exceptions

  • CodeDeploy.Client.exceptions.ApplicationNameRequiredException

  • CodeDeploy.Client.exceptions.InvalidApplicationNameException

  • CodeDeploy.Client.exceptions.ApplicationDoesNotExistException

  • CodeDeploy.Client.exceptions.DeploymentGroupNameRequiredException

  • CodeDeploy.Client.exceptions.InvalidDeploymentGroupNameException

  • CodeDeploy.Client.exceptions.DeploymentGroupDoesNotExistException

  • CodeDeploy.Client.exceptions.RevisionRequiredException

  • CodeDeploy.Client.exceptions.RevisionDoesNotExistException

  • CodeDeploy.Client.exceptions.InvalidRevisionException

  • CodeDeploy.Client.exceptions.InvalidDeploymentConfigNameException

  • CodeDeploy.Client.exceptions.DeploymentConfigDoesNotExistException

  • CodeDeploy.Client.exceptions.DescriptionTooLongException

  • CodeDeploy.Client.exceptions.DeploymentLimitExceededException

  • CodeDeploy.Client.exceptions.InvalidTargetInstancesException

  • CodeDeploy.Client.exceptions.InvalidAlarmConfigException

  • CodeDeploy.Client.exceptions.AlarmsLimitExceededException

  • CodeDeploy.Client.exceptions.InvalidAutoRollbackConfigException

  • CodeDeploy.Client.exceptions.InvalidLoadBalancerInfoException

  • CodeDeploy.Client.exceptions.InvalidFileExistsBehaviorException

  • CodeDeploy.Client.exceptions.InvalidRoleException

  • CodeDeploy.Client.exceptions.InvalidAutoScalingGroupException

  • CodeDeploy.Client.exceptions.ThrottlingException

  • CodeDeploy.Client.exceptions.InvalidUpdateOutdatedInstancesOnlyValueException

  • CodeDeploy.Client.exceptions.InvalidIgnoreApplicationStopFailuresValueException

  • CodeDeploy.Client.exceptions.InvalidGitHubAccountTokenException

  • CodeDeploy.Client.exceptions.InvalidTrafficRoutingConfigurationException