Skip to content

Boostraps a terraform repo with state remotely hosted on DO spaces.

Notifications You must be signed in to change notification settings

flitz-be/terraform-bootstrap-do

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bootstrap Terraform IaC on Digital Ocean

Based on this Medium post and this repo.

Prerequisites

  • A Digital Ocean account
  • Terraform version 1.0.11

How to use

  1. Clone this repository. (Change bucket region if necessary, both in the variables and backend section.)
  2. Export the needed environment variables:
export TF_VAR_do_token=<YOUR_DO_PERSONAL_ACCESS_TOKEN>
export TF_VAR_spaces_access_key_id=<YOUR_DO_SPACES_ACCESS_KEY_ID>
export TF_VAR_spaces_secret_key=<YOUR_DO_SPACES_SECRET_KEY>
export AWS_ACCESS_KEY_ID=<YOUR_DO_SPACES_ACCESS_KEY_ID>
export AWS_SECRET_ACCESS_KEY=<YOUR_DO_SPACES_SECRET_KEY>
  1. comment out the backend block in the `terraform block

comment out

  1. Run terraform init. The statefile will be generated locally
  2. Run terraform plan. You should see that an DO S3 bucket will be created
  3. Run terraform apply to create the S3 bucket
  4. Add the previously-commented-out backend section again.
  5. Run terraform init again. You will be prompted to ask if you want to copy the local state to the remote bucket. Pick yes.
  6. Run terraform plan. Your plan should come up empty.
  7. Rejoice, you have bootstrapped a terraform with a remote state hosted on Digital Ocean.

How to configure Github Actions

Add the following secrets, either on repository-level or on organization-level:

  • DO_SPACES_ACCESS_KEY_ID
  • DO_SPACES_SECRET_ACCESS_KEY
  • DO_ACCESS_TOKEN

The actions are configured to only run on a manual workflow_dispatch trigger.

About

Boostraps a terraform repo with state remotely hosted on DO spaces.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages