1

Looking to get pointed in the right direction:

I am trying to build a pipeline that will recognize changes in a remote terraform template that will recognize changes compared to the previous git command before mine and have it only apply those changes by using specified commands:

terraform get -update
terraform plan

I also want it to display to the user and have user confirmation to proceed and have 2 min for total user response

Still green with Jenkins but so far:

I have the git fetch stage to grab the branch on the remote repository

A terraform init stage to initialize terraform

Can anyone point me to the right direction to detect the changes and apply them with the commands?

1 Answer 1

0

Your question is really vague and depends a lot of information that you didn't supply.

Some of things you didn't mention were what git branching strategy you are using.

Typically you are not going to run terraform apply on every single commit. Instead you are going to have people open a PR and on that PR you will run linting and other static code checks like tfsec, terraform validate etc.

Then once that PR is merged to the master/main branch of your repo, you will run terraform apply.

This is still a beginners pipeline though because it has lots of problems still, like what happens when you merge to master but your deployment fails.

You need to talk to your team about how they want to build and test there software so that you can pick a branching strat and then design the pipeline around that.

1
  • Hi Levi, thank you for the response. Since posting this I’ve gotten a lot more clarification, from both my team and Microsoft engineers. But thank you for pointing out that git branching strategy is/was key to understanding their expectations. Ended up making a Build/release pipeline with a script to iterate through and collect changes from the terraform plan json file and output into a PR that triggers a release pipeline. Still working out some kinks and adding features like basing it off a template and checks to ensure backend is configured correctly. Thanks again Apr 4 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.