Skip to content

Example of using Terraform with DigitalOcean provider and GitHub actions.

Notifications You must be signed in to change notification settings

gabrielgiordan/github-actions-digitalocean

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deploy

GitHub Actions DigitalOcean

GitHub actions workflows for DigitalOcean droplets, using DigitalOcean Spaces as the Terraform backend for .tfstate storage, domain name via DigitalOcean DNS and DigitalOcean Images for the snapshot image creation.

Architecture overview

Prerequisites

Usage

Vagrant

Vagrant is used to provision a VM locally using the VirtualBox to be used as the development environment. Start your VM with:

vagrant up

Ansible

Ansible is used to configure the environment and its entry point playbook main.yml is provisioned with Vagrant or Packer workflow.

The default forwarded port on both environments is 8080.

Packer

Packer is used to create the OS image once for time savings on provisioning into different environments.

Packer at this project uses HCL2 syntax.

To run Packer at your local machine, create a file named variables.pkvars.hcl at the packer folder in order to store the Packer variables.

Then you can build your snapshot at packer folder:

packer build -var-file=variables.pkrvars.hcl .

Terraform

Terraform is used to provision the infrastructure.

In order to use Terraform at a local machine, you must create a terraform.tfvars file within the terraform directory. Also you will need a file named backend.tfvars for the backend configuration with DigitalOcean Spaces as the provider.

Then you can init Terraform with:

terraform init --backend-config=backend.tfvars

Frequently Asked Questions

How do I import an existing DigitalOcean droplet?

Retrieve your DigitalOcean droplets then copy the droplet ID you wish to import:

doctl compute droplet list

Then import it into your Terraform state:

terraform import digitalocean_droplet.app_instance droplet_id

How do I import an existing DigitalOcean domain?

Retrieve your DigitalOcean domains and copy the one you wish to import:

doctl compute domain list

Then import it into your Terraform state:

terraform import digitalocean_domain.app_domain domain

How do I support hcl2 for Terraform >= 0.12?

In order to support the Terraform version 0.12 at or greater with hcl2 syntax support, install the Terraform Language Server

Why using a separate file for backend variables on Terraform?

Because Terraform does not allow variables inside a backend scope as seen on issue #13022

Why there is not a validate step at packer job?

Validation with Packer using HCL2 syntax is currently unsupported from Hashicorp

About

Example of using Terraform with DigitalOcean provider and GitHub actions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages