So you’ve started using terraform
You’ve progressed to creating terraform modules
You’ve put your module in a private bitbucket repo
Now you want to access it from a bitbucket build pipeline and you see the following
Solution
In my case I reached out to one of my friendly devops colleagues @BlnaryMlke who showed me how ssh keys and git hang together, I don’t know if i should be ashamed to say I’ve never used git with ssh keys until today.
Armed with this new knowledge I set off to do the same in my bitbucket pipeline only to discover that Bitbucket has some primary support for this scenario!
What follows are the steps required in a bitbucket pipeline in order to to use a private git bitbucket repo that contains a terraform module
Show me
1) First create a new key in the the project that contains your pipeline (i.e. the project that is including the terraform module), you’ll find this option under project settings, pipelines/ssh keys
Image shows that I’ve added a new Key and then added bitbucket.org (fetch gets the fingerprint)
2) Now add the public key to your bitbucket git repo that contains the terraform module, to do this you go to the project settings and choose access keys then add
3) Lastly, you’ll need to configure your terraform module source with the following format
That’s it, huge thanks again to @BlnaryMlke for setting me on the right path
4) Bonus Step: If you wish to work outside the bitbucket pipeline and don’t want to use ssh keys but rather your OAuth token you can configure git insteadof to automagically redirect ssh to http
|
|
|
|
In this video I show you how to configure multiple origins for a single cloudfront distribution