How to optimize blue/green AWS deployments?
bitbucket deploy: 45 seconds


This seems correct. Not sure of your repo size, but if it is hosted outside of your region, that's not out of the ordinary.


  bitbucket deploy: 45 seconds


Again, seems correct. Not much room for optimization here. 


  provisioning a new ec2 instance: 3:40 minutes 


What size of instance are you provisioning? Are you provisioning one or more instances? The obvious solution would be to use in place deployment vs blue-green, but I think the extra time is well worth it. If this is for production/staging, I think you are fine. If this is in a testing environment, and you are aiming for quick feed back, you could consider provisioning new instances after a successful blue-green so that, if there is no AMI change, they are ready to go for installation immediately. 


  installing application on replacement instance: 40 seconds


Nothing to optimize here 


  2 minutes rerouting traffic from old instance to new one *this one is extremely long, if it were done manually it would literally take 10 seconds)


My guess is that step is performing extra steps that you do not perform when you manually reroute traffic. It's possible that CodeDeploy is performing extra checks to make sure that connections are draining, new connections are established before old ones are closed, and other test/checks. This is probably your best area to optimize, but not at the sacrifice of checks and balances. 


  17 seconds terminating second instance


Nothing to optimize here.

Summary:
I don't think it is feasible or worthwhile to attempt to optimize your deployment further. The amount of effort it would take and sacrifices you would need to make in your test and checks far out ways the potential minute or two you would save in my opinion. I also don't think it is possible to achieve a &lt;1 minute deployment. That would average ~15-20 seconds a step, which would require a lot of sacrifices in your deployment strategy.

If your goal is for quick iterations for QA, code testing, integration testing, etc., and you absolutely want sub 1 minute deployments, I recommend creating a Cloud Formation stack with your exact deployment except skipping the blue/green deployment model for an in place deployment model. This way, you can quickly see the results of your code. You should then later run your full suite blue/green deployment after your testing in either another testing environment or your staging environment.