0

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?

Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191

1 Answers1

0

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)

Juan Fuentes
  • 1,743
  • 2
  • 20
  • 33
  • 1
    Than you, but I realised it was a bad practice doing it. Because it does not delete files that should not be there. Thus, instead of overwriting, I delete everything and copy only a new set of files. It is longer, but it covers the deletion issue. – Yevgeniy Afanasyev Aug 08 '19 at 03:50
  • 1
    @YevgeniyAfanasyev I hadn't thought of that... You just saved me a lot of future trouble <3 – Juan Fuentes Aug 08 '19 at 15:04