Hey Atlassian Team,
Need some help here. I am trying to terraform Deploy to Production Env. My definition in the pipeline.yaml file looks like this below
terraform-plan-prd: &terraform-plan-prd step: name: Terraform_Plan_Prd deployment: Prd image: hashicorp/terraform:1.1.5 script: - cd mwaa/infrastructure - ./plan.sh prd
terraform-apply-prd: &terraform-apply-prd step: name: Terraform_Apply_prd image: hashicorp/terraform:1.1.5 deployment: Prd trigger: manual script: - cd mwaa/infrastructure - ./apply.sh prd
branches: mwaa-prd-*: - <<: *terraform-plan-prd - <<: *terraform-apply-prd
Now both the steps are using deployment env Prd. I think I read in some Community Chats that Atlassian have deployed multi step deployments somewhere. Please help how to fix this ?
Thanks - Arun Kumar D
Hi Arun Kumar,
A stage can be used so that multiple steps can share the same deployment environment:
Please keep in mind though that stages can't contain manually triggered steps, this is one of the stages' limitations at the moment:
If you remove the manual trigger from the second step, you could use a yml like the following:
definitions:
terraform-plan-prd: &terraform-plan-prd
step:
name: Terraform_Plan_Prd
image: hashicorp/terraform:1.1.5
script:
- cd mwaa/infrastructure
- ./plan.sh prd
terraform-apply-prd: &terraform-apply-prd
step:
name: Terraform_Apply_prd
image: hashicorp/terraform:1.1.5
script:
- cd mwaa/infrastructure
- ./apply.sh prd
pipelines:
branches:
mwaa-prd-*:
- stage:
deployment: Prd
steps:
- <<: *terraform-plan-prd
- <<: *terraform-apply-prd
If you'd like to keep the manual trigger on the second step, then the only workaround would be creating a second deployment environment for production with the same variables as the environment named Prd and using that for the second step.
We have a feature request for supporting manual steps in a stage:
You can add your vote to that feature request (by selecting the link Vote for this issue) to increase the chances of this being implemented. You are more than welcome to leave feedback, and you can also add yourself as a watcher (by selecting the link Start watching this issue) if you'd like to be notified via email on updates.
Implementation of features is done as per our policy here and any updates will be posted in the feature request.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arun Kumar,
As I mentioned above, multi-step deployments are possible, but without manual steps in the stage. If you are asking for the manual steps in a stage, I'm afraid I don't have an ETA to share. Updates will be provided in the feature request I shared in my previous reply.
However, we recently released some new features, so another workaround exists, that doesn't involve deployments. These features are:
Environments allow you to access environment-specific variables in multiple steps of the same pipeline. Environments use the deployment environments created in the Deployments section of the repo's Repository settings. However, they don't offer concurrency control (meaning that two steps of the same environment can run at the same time).
If you use concurrency-group along with environments, then the steps will also have concurrency control. The concurrency-group can be an arbitrary string, but you can use the same string as the environment, to avoid confusion.
This is a sample yml file using these features:
definitions:
steps:
- step: &terraform-plan-prd
name: Terraform_Plan_Prd
image: hashicorp/terraform:1.1.5
concurrency-group: Prd
environment: Prd
script:
- echo "Terraform_Plan_Prd"
- step: &terraform-apply-prd
name: Terraform_Apply_prd
image: hashicorp/terraform:1.1.5
trigger: manual
concurrency-group: Prd
environment: Prd
script:
- echo "Hello there"
pipelines:
branches:
main:
- step: *terraform-plan-prd
- step: *terraform-apply-prd
This way you can reuse variables from deployment environments, have concurrency control, and a manual step.
Please keep in mind though that this solution does not use deployments, so you won't be able to track deployments in the Deployments page of the repo.
Please feel free to let me know if you have any questions.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.