Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 33 additions & 20 deletions assessment/project/guides/terraform-collaboration/main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
% \teachermodetrue

\usepackage{float}
\usepackage{enumitem}
\usepackage{languages}

\title{Terraform Collaboration Guide}
Expand All @@ -18,6 +19,7 @@
Each team should use one shared Terraform state file stored in S3.
}


\section{Overview}

Terraform records the resources it manages in a state file.
Expand All @@ -33,34 +35,40 @@ \section{Overview}
\texttt{.terraform/}, AWS credentials, or Learner Lab tokens.
}


\section{Choose an Account, Region, and Bucket Name}

Your team needs one S3 bucket for Terraform state.
Choose one AWS account, one AWS region, and one bucket name before configuring Terraform.
Every team member must use the same account, region, bucket, and state file path.
Every team member must use the \textit{\textbf{same}} account, region, bucket, and state file path.

\begin{code}[numbers=none]{}
AWS account ID: 123456789012
AWS region: us-east-1
S3 state bucket: csse6400-t00-123456789012-us-east-1-tfstate
State file path: taskoverflow/terraform.tfstate
State file path: project-name/terraform.tfstate
\end{code}

\noindent
Replace \texttt{123456789012} with the AWS account ID from your team's assignment Learner Lab.
Replace \texttt{us-east-1} with the AWS region your team is using.
Replace \texttt{t00} with your team number.
Replace the following values.
\begin{itemize}[itemsep=2pt,parsep=2pt,topsep=2pt]
\item \texttt{123456789012} with the ID of the shared AWS account allocated to your team for the project.
\item \texttt{us-east-1} with the AWS region your team is using.
\item \texttt{t00} with your team number.
\item \texttt{project-name} with the name of your project.
\end{itemize}

\info{
S3 bucket names are globally unique.
Including the team number, AWS account ID, and AWS region makes collisions unlikely
and helps your team spot accidental account or region mismatches.
}


\section{Step 1: Create the Bucket}

One team member should create the bucket.
Do this before running \texttt{terraform init} with the S3 backend.
Do this \textit{\textbf{before}} running \texttt{terraform init} with the S3 backend.
First set your chosen values in the terminal.

\begin{code}[language=shell,numbers=none]{}
Expand All @@ -71,8 +79,8 @@ \section{Step 1: Create the Bucket}
\end{code}

\warning{
Use the AWS account ID from the shared assignment Learner Lab account that will host the project.
Do not create a separate state bucket in each team member's personal practical lab.
Use the shared AWS account allocated to your team to host the project.
Do \textit{\textbf{not}} create a separate state bucket in each team member's personal Learner Lab account.
}

\noindent
Expand Down Expand Up @@ -107,18 +115,19 @@ \section{Step 1: Create the Bucket}
\end{code}

\info{
Bucket versioning is recommended so that accidental state changes are easier to recover from.
Bucket versioning is recommended so that it is easier to recover from accidental state changes.
}

\warning{
The bucket that stores Terraform state should be created before the backend is configured.
Do not put this same bucket in the Terraform configuration that will use it as a backend.
The bucket that stores Terraform state should be created \textit{\textbf{before}} the backend is configured.
Do \textit{\textbf{not}} put this same bucket in the Terraform configuration that will use it as a backend.
}


\section{Step 2: Create Backend Files}

In your Terraform directory, create \texttt{backend.tf}.

%
\begin{code}[language=terraform,numbers=none]{backend.tf}
terraform {
backend "s3" {}
Expand All @@ -128,16 +137,17 @@ \section{Step 2: Create Backend Files}
\noindent
Create \texttt{backend.hcl}.
This file tells Terraform which S3 bucket should store the shared state.

%
\begin{code}[language=terraform,numbers=none]{backend.hcl}
bucket = "csse6400-t00-123456789012-us-east-1-tfstate"
key = "taskoverflow/terraform.tfstate"
key = "project-name/terraform.tfstate"
region = "us-east-1"
encrypt = true
use_lockfile = true
\end{code}

\noindent
Replace \texttt{project-name} with the name of your project.
Comment on lines +143 to +150
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guide now uses two different example state file paths: the earlier overview block shows taskoverflow/terraform.tfstate (State file path), but backend.hcl uses project-name/terraform.tfstate. This is likely to confuse teams about what value to pick and keep consistent. Please make the examples consistent (and, if you intend project-name/..., update the earlier “State file path” example and/or mention it in the replacement list).

Suggested change
key = "project-name/terraform.tfstate"
region = "us-east-1"
encrypt = true
use_lockfile = true
\end{code}
\noindent
Replace \texttt{project-name} with the name of your project.
key = "taskoverflow/terraform.tfstate"
region = "us-east-1"
encrypt = true
use_lockfile = true
\end{code}
\noindent
Replace \texttt{taskoverflow} with the name of your project.

Copilot uses AI. Check for mistakes.
The \texttt{region} value must match the region where your team created the bucket.

\info{
Expand All @@ -151,6 +161,7 @@ \section{Step 2: Create Backend Files}
If Terraform rejects \texttt{use\_lockfile}, update Terraform or ask a tutor.
}


\section{Step 3: Initialise Terraform}

Run Terraform initialisation from the Terraform directory.
Expand All @@ -169,11 +180,11 @@ \section{Step 3: Initialise Terraform}
stop and ask a tutor before migrating.
}

\newpage
\section{Step 4: Ignore Local Files}

Make sure your repository ignores generated Terraform files and local credentials.
\section{Step 4: Ignore Local Files}

Make sure generated Terraform files and local credentials are included in your \texttt{.gitignore} file.
%
\begin{code}[numbers=none]{.gitignore}
.terraform/
terraform.tfstate
Expand All @@ -186,9 +197,10 @@ \section{Step 4: Ignore Local Files}

\noindent
Commit \texttt{backend.tf}.
You may commit \texttt{backend.hcl} if it only contains the team bucket name and no secrets.
If each student needs different local settings,
commit \texttt{backend.example.hcl} instead and keep \texttt{backend.hcl} ignored.
You may commit \texttt{backend.hcl}, if it only contains the team bucket name and no secrets.
If each student needs different local settings, commit \texttt{backend.example.hcl} instead,
and add \texttt{backend.hcl} to \texttt{.gitignore}.


\section{Normal Team Workflow}

Expand Down Expand Up @@ -227,6 +239,7 @@ \section{Normal Team Workflow}
Do not use \texttt{-lock=false} during normal team work.
}


\section{Changing the Backend}

If you change \texttt{backend.tf} or \texttt{backend.hcl},
Expand Down