Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Terraform prod GitHub Actions workflows #30

Open
4 of 8 tasks
briancaffey opened this issue Jan 14, 2023 · 0 comments
Open
4 of 8 tasks

Refactor Terraform prod GitHub Actions workflows #30

briancaffey opened this issue Jan 14, 2023 · 0 comments
Assignees
Milestone

Comments

@briancaffey
Copy link
Owner

briancaffey commented Jan 14, 2023

The GitHub Actions for Terraform and other IaC tools should use the following pattern:

  • terraform init + plan
  • manual review (using environment set on the job)
  • terraform apply

We can use artifacts to pass the terraform plan file available from the init + plan job to the apply job

This has already been successfully implemented for the Terraform prod base create/update and prod base destroy workflows. Here's an example:

Screenshot 2023-01-14 at 3 56 28 PM

The other Terraform workflows need to be updated using the same pattern:

  • prod base create/update

  • prod base destroy

  • prod app create/update

  • prod app destroy

  • ad hoc base create/update

  • ad hoc base destroy

  • ad hoc app create/update

  • ad hoc app destroy

Some links and issues:

  • the actions/upload-artifact / actions/download-artifact actions do not preserve the permissions of the files, so executable permissions need to be set manually using chmod
  • I set the working-directory default for run, but this does not apply to the artifact jobs, so artifacts need to be set relative to the root of the repo (not relative to the root of the default working directory) see this issue for more
  • I'm following the recommendations from the document Running Terraform in Automation from the Terraform docs, which recommends artifacting not only the tfplan file, but also the .terraform directory. This allows us to run terraform init only once in our workflow.

cc @codyfletcher

@briancaffey briancaffey self-assigned this Jan 14, 2023
@briancaffey briancaffey added this to the terraform milestone Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant