amazon-web-servicesbitbucketaws-code-deploybitbucket-aws-code-deploy

How to set params for file-exists-behavior for AWS CodeDeploy on Bitbucket


Atlassian Bitbucket Support for AWS CodeDeploy was announced long time ago in 2015.

AWS CodeDeploy User Guide is explaining what exactly is executed on the instance to generate codeDeploy deployment.

my question is how do we set a param for

--file-exists-behavior

I wan it to be OVERWRITE, but it feels like it is DISALLOW by default.

I know it is possible, because this is how it worked on elstic-beanstalk (Amazon Linux) on another project, however now I'm using Ubuntu and I don't have access to previous settings. It cannot be possible only for Amazon Linux, right?


Solution

  • I know this was asked a long time ago, but I ran into this issue myself, so here's a fix for those still struggling with bitbucket and aws codedeploy:

    Go to the file: codedeploy_deploy.py and change the call to the create_deployment and add the option fileExistsBehavior='OVERWRITE'. It should end up like this:

    response = client.create_deployment(
        applicationName=str(os.getenv('APPLICATION_NAME')),
        deploymentGroupName=str(os.getenv('DEPLOYMENT_GROUP_NAME')),
        revision={
            'revisionType': 'S3',
            's3Location': {
                'bucket': os.getenv('S3_BUCKET'),
                'key': BUCKET_KEY,
                'bundleType': 'zip'
            }
        },
        deploymentConfigName=str(os.getenv('DEPLOYMENT_CONFIG')),
        description='New deployment from BitBucket',
        ignoreApplicationStopFailures=True,
        fileExistsBehavior='OVERWRITE'
    )
    

    I had to upgrade boto3 from 1.3.0 to the current one (1.9.201)