I am trying to deploy aws resources by using terraform, but the challenge is it should auto detect in which directory commit is happened and take safe ref in the pipeline to run terraform command.
currently i am giving manually by cd Preformatted text
stages:
- init&plan
- apply
- upload
init&plan:
stage: init&plan
script:
- ls -ll
- cd s3
- terraform init
- terraform plan -out=$CI_PROJECT_DIR/tfplan
artifacts:
paths:
- $CI_PROJECT_DIR/tfplan
apply:
stage: apply
script:
- cd s3
- terraform apply -auto-approve tfplan