<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-run-terraform-in-bitbucket-pipelines-4tlbvbqih" -->

---
title: How to Run Terraform in Bitbucket Pipelines | daily.dev
description: Step-by-step walkthrough for running Terraform in Bitbucket Pipelines using a single `bitbucket-pipelines.yml` file. Covers enabling pipelines, defining...
canonical: https://daily.dev/posts/how-to-run-terraform-in-bitbucket-pipelines-4tlbvbqih
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Run Terraform in Bitbucket Pipelines | daily.dev
og:description: Step-by-step walkthrough for running Terraform in Bitbucket Pipelines using a single `bitbucket-pipelines.yml` file. Covers enabling pipelines, defining...
og:url: https://daily.dev/posts/how-to-run-terraform-in-bitbucket-pipelines-4tlbvbqih
og:image: https://api.daily.dev/og/posts/4TLbvBQIH.png
og:image:alt: How to Run Terraform in Bitbucket Pipelines
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Run Terraform in Bitbucket Pipelines

**[Spacelift](https://daily.dev/sources/spacelift)** · 18 min read · 0 upvotes · 0 comments

## Summary

Step-by-step walkthrough for running Terraform in Bitbucket Pipelines using a single `bitbucket-pipelines.yml` file. Covers enabling pipelines, defining reusable YAML-anchor-based steps for fmt/validate/plan/apply, configuring an AWS S3 remote backend via repository variables, and setting up OIDC workload identity federation to authenticate to AWS without long-lived credentials. Includes a complete final pipeline file, best practices (concurrency groups, deployment environments, secrets management), and a comparison of alternatives like GitHub Actions, GitLab CI/CD, Spacelift, and HCP Terraform.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://spacelift.io/blog/terraform-bitbucket>

## Questions this post answers

### How do I authenticate to AWS from Bitbucket Pipelines without storing long-lived access keys?

Use OpenID Connect workload identity federation: register Bitbucket as an identity provider in AWS IAM, create an IAM role with a trust policy scoped to your workspace or repository UUID, then set oidc: true on the pipeline step so AWS STS exchanges the BITBUCKET_STEP_OIDC_TOKEN for short-lived credentials, avoiding stored access keys entirely.

_Teams wiring up secure cloud auth in CI can compare OIDC setups across providers via daily.dev._

### How do I configure an S3 backend for Terraform state in a Bitbucket Pipelines pipeline?

Define a reusable YAML anchor script that runs terraform init with backend-config flags pulling bucket, key, and region from repository variables (TF_STATE_BUCKET, TF_STATE_KEY, AWS_DEFAULT_REGION), then reference that anchor in both the plan and apply steps so the same backend configuration is applied consistently across the pipeline.

_Anyone standardizing Terraform state backends across CI jobs can track patterns like this on daily.dev._

### How many free build minutes does Bitbucket Pipelines include per month, and what do paid plans offer?

The free tier includes 50 build minutes per workspace per month, enough for light experimentation but not sustained Terraform use. Paid Bitbucket Cloud plans include larger pooled allocations: 2,500 minutes on Standard and 3,500 on Premium, with overage priced at roughly $10 per 1,000 additional minutes.

_Teams budgeting CI minutes for infrastructure pipelines can weigh these tiers using daily.dev._

## Similar posts on daily.dev

- [How Terraform Works](https://daily.dev/posts/how-terraform-works-m4paeflla) · System Design Codex · 35 upvotes · 0 comments
- [Split your pipelines workflows across multiple files](https://daily.dev/posts/split-your-pipelines-workflows-across-multiple-files-oymmal3kg) · Atlassian · 1 upvotes · 0 comments
- [CD with the Terraform and GitHub Actions](https://daily.dev/posts/cd-with-the-terraform-and-github-actions-y4geqjcda) · Auth0 · 0 upvotes · 0 comments
- [How to Get Started with Terraform](https://daily.dev/posts/how-to-get-started-with-terraform-mojbh4put) · freeCodeCamp · 1 upvotes · 0 comments
- [How to Use Atlantis with GitHub Actions for Terraform](https://daily.dev/posts/how-to-use-atlantis-with-github-actions-for-terraform-dild0uulj) · Spacelift · 2 upvotes · 0 comments

---

Tags: [#aws](https://daily.dev/tags/aws), [#authentication](https://daily.dev/tags/authentication), [#terraform](https://daily.dev/tags/terraform), [#iac](https://daily.dev/tags/iac)

[View this post on daily.dev](https://daily.dev/posts/how-to-run-terraform-in-bitbucket-pipelines-4tlbvbqih)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to Run Terraform in Bitbucket Pipelines","url":"https://daily.dev/posts/how-to-run-terraform-in-bitbucket-pipelines-4tlbvbqih","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-run-terraform-in-bitbucket-pipelines-4tlbvbqih"},"datePublished":"2026-08-07T13:53:25.607Z","dateModified":"2026-09-13T21:21:39.876Z","description":"Step-by-step walkthrough for running Terraform in Bitbucket Pipelines using a single `bitbucket-pipelines.yml` file. Covers enabling pipelines, defining...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0fd1048ac75b0ed807c4eab2bdfbb5ef?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0fd1048ac75b0ed807c4eab2bdfbb5ef?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Spacelift","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Spacelift","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/422b4004f7b24dc988e5720eca3accfc","url":"https://daily.dev/sources/spacelift"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-run-terraform-in-bitbucket-pipelines-4tlbvbqih","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"aws,authentication,terraform,iac","timeRequired":"PT18M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Spacelift","item":"https://daily.dev/sources/spacelift"},{"@type":"ListItem","position":3,"name":"How to Run Terraform in Bitbucket Pipelines"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-run-terraform-in-bitbucket-pipelines-4tlbvbqih#faq","mainEntity":[{"@type":"Question","name":"How do I authenticate to AWS from Bitbucket Pipelines without storing long-lived access keys?","acceptedAnswer":{"@type":"Answer","text":"Use OpenID Connect workload identity federation: register Bitbucket as an identity provider in AWS IAM, create an IAM role with a trust policy scoped to your workspace or repository UUID, then set oidc: true on the pipeline step so AWS STS exchanges the BITBUCKET_STEP_OIDC_TOKEN for short-lived credentials, avoiding stored access keys entirely. Teams wiring up secure cloud auth in CI can compare OIDC setups across providers via daily.dev."}},{"@type":"Question","name":"How do I configure an S3 backend for Terraform state in a Bitbucket Pipelines pipeline?","acceptedAnswer":{"@type":"Answer","text":"Define a reusable YAML anchor script that runs terraform init with backend-config flags pulling bucket, key, and region from repository variables (TF_STATE_BUCKET, TF_STATE_KEY, AWS_DEFAULT_REGION), then reference that anchor in both the plan and apply steps so the same backend configuration is applied consistently across the pipeline. Anyone standardizing Terraform state backends across CI jobs can track patterns like this on daily.dev."}},{"@type":"Question","name":"How many free build minutes does Bitbucket Pipelines include per month, and what do paid plans offer?","acceptedAnswer":{"@type":"Answer","text":"The free tier includes 50 build minutes per workspace per month, enough for light experimentation but not sustained Terraform use. Paid Bitbucket Cloud plans include larger pooled allocations: 2,500 minutes on Standard and 3,500 on Premium, with overage priced at roughly $10 per 1,000 additional minutes. Teams budgeting CI minutes for infrastructure pipelines can weigh these tiers using daily.dev."}}]}
```

