namusyaka / terraform-google-vm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

terraform-google-vm

This is a collection of opinionated submodules that can be used as building blocks to provision VMs in GCP:

Examples

Examples of how to use these modules can be found in the examples folder.

Project APIs

The following APIs must be enabled on your project:

  • compute.googleapis.com
  • iam.googleapis.com

See also the project_services module (optional).

Test Configuration

  1. Create a terraform.tfvars file, using terraform.tfvars.example as an example
cp test/fixtures/shared/terraform.tfvars.example test/fixtures/shared/terraform.tfvars

The terraform.tfvars in each fixture directory is already symlinked to this one shared file.

  1. Populate the variables with values appropriate for your test environment (i.e. project_id, service_account.email)
  2. Download a Service Account key with the necessary permissions and put it in the module's root directory with the name credentials.json.

Running Tests

From the root of the module, run

make test_integration_docker

to build the container and run through all the test suites. Note that this will take some time (> 20 minutes).

You can also run each test case individually and interactively in the Docker container:

make docker_run

The root directory of the module will be mounted to /cft/workdir in the container. For example, to run the mig-autoscaler test suite:

bundle exec kitchen test mig-autosaler

or

bundle exec kitchen create mig-autoscaler
bundle exec kitchen converge mig-autoscaler
bundle exec kitchen verify mig-autoscaler
bundle exec kitchen destroy mig-autoscaler

Permissions

The service account used to execute tests for this module should have the following roles:

About

License:Apache License 2.0


Languages

Language:Ruby 36.2%Language:HCL 30.8%Language:Python 19.9%Language:Shell 6.4%Language:Makefile 5.8%Language:Dockerfile 1.0%