Skip to content

Commit

Permalink
added notes/comments about Terraform 0.12 migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBuchs committed Aug 7, 2019
1 parent 8a043bc commit b4f4293
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.terraform
.terraform/
.kitchen/
terraform.tfstate.d/
terraform.tfstate*
Expand All @@ -7,5 +7,5 @@ credentials.json
ubuntu*
.vscode
ci.tar.gz
vendor
vendor/
.bundle
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org/' do
gem 'inspec', '~> 2.2.35'
gem 'inspec', '~> 2.2.35' # for Terraform 0.12+, make: ~> 4.0.0
gem 'kitchen-google', '~> 1.5'
gem 'kitchen-terraform', '~> 4.0.0'
gem 'kitchen-terraform', '~> 4.0.0' # for Terraform 0.12+, make: >= 4.0.0
end
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ GEM
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
aws-eventstream (1.0.3)
aws-sdk (2.11.326)
aws-sdk-resources (= 2.11.326)
aws-sdk-core (2.11.326)
aws-sdk (2.11.327)
aws-sdk-resources (= 2.11.327)
aws-sdk-core (2.11.327)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.11.326)
aws-sdk-core (= 2.11.326)
aws-sdk-resources (2.11.327)
aws-sdk-core (= 2.11.327)
aws-sigv4 (1.1.0)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_graph_rbac (0.17.1)
Expand Down Expand Up @@ -60,7 +60,7 @@ GEM
dry-types (~> 0.14.0)
equatable (0.6.1)
erubis (2.7.0)
excon (0.65.0)
excon (0.66.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
faraday-cookie_jar (0.0.6)
Expand Down
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,44 @@ module "terraform-google-instance" {
}
```

## Requirements

Terraform version must be less than 0.12. (See below for tips on migrating to 0.12)

## Development

Feel free to submit pull requests to make changes to the module.

To begin developing on this module please have a Google Compute Project.

### Install Terraform (options below)
### Required Setup
- See the script bin/example-setup-ubuntu.sh for the complete setup. However, the steps are listed below.

#### Install Terraform (options below)

- [https://github.com/kamatama41/tfenv](https://github.com/kamatama41/tfenv)
- brew install terraform
- [https://www.terraform.io/downloads.html](https://www.terraform.io/downloads.html)

### Install Ruby (options below)
#### Install Ruby (options below)

- [https://github.com/rbenv/rbenv](https://github.com/rbenv/rbenv)
- brew install ruby # or other package managers
- [http://ruby-lang.org/](http://ruby-lang.org/)

### Install JQ
#### Install JQ

- brew install jq # or other package managers
- [https://stedolan.github.io/jq/](https://stedolan.github.io/jq/)

### Google IAM Console
#### Google IAM Console

Download a credentials JSON file from a user with proper permissions.
[https://console.cloud.google.com/iam-admin/iam](https://console.cloud.google.com/iam-admin/iam)

Save the file to the root of the repository directory called: `credentials.json`

### Install gcloud CLI
#### Install gcloud CLI

- [https://cloud.google.com/sdk/gcloud/](https://cloud.google.com/sdk/gcloud/)

Expand All @@ -60,14 +67,14 @@ gcloud config set project $(jq -r '.project_id' credentials.json)
gcloud config set compute/zone us-west1-a
```

### Install Kitchen-Terraform and many other required Ruby Gems.
#### Install Kitchen-Terraform and many other required Ruby Gems.

```sh
gem install bundler --no-rdoc --no-ri
bundle install
```

### Create an environment variables file
#### Create an environment variables file

Create a file in the repository directory called: `.env`
It will have environment variables that Terraform uses to run.
Expand All @@ -85,7 +92,7 @@ HEREDOC

```

### Run Terraform and Tests
#### Run Terraform and Tests

Common setup to be run once before any number of the rest of the following:

Expand Down Expand Up @@ -118,6 +125,15 @@ To destroy everything via Test-Kitchen:
bundle exec kitchen destroy
```

## Migration to Terraform 0.12+

This repository does not support Terraform 0.12+ out of the box.
Here are **some** of the things necessary to migrate.
1. Edit Gemfile to change version requirements to be this:
- gem 'inspec', '~> 4.0'
- gem 'kitchen-terraform', '>= 4.0.0'
1. Edit main.tf to change syntax of metadata, at the bottom. See the comment.

## Authors

Module managed by [Nick Willever](https://github.com/nictrix).
Expand Down
Binary file removed ci.tar.gz.enc
Binary file not shown.
6 changes: 5 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ resource "google_compute_instance" "database" {
}
}

metadata {

# uncomment this next code line and comment the following to enable Terraform 0.12+ functionality
metadata = {
# metadata {
sshKeys = "ubuntu:${file(var.ssh_public_key_filepath)}"
}

}

0 comments on commit b4f4293

Please sign in to comment.