Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from yupwei68/feature-terra
Browse files Browse the repository at this point in the history
Terraform version upgrade to v0.12.10
  • Loading branch information
yupwei68 authored Feb 6, 2020
2 parents 9343fa8 + 327b6cd commit cf82493
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions generators/build/templates/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pull the base image with given version.
ARG BUILD_TERRAFORM_VERSION="0.11.7"
FROM microsoft/terraform-test:${BUILD_TERRAFORM_VERSION}
ARG BUILD_TERRAFORM_VERSION="0.12.10"
FROM mcr.microsoft.com/terraform-test:${BUILD_TERRAFORM_VERSION}

ARG MODULE_NAME="terraform-azurerm-template"

Expand Down
2 changes: 1 addition & 1 deletion generators/build/templates/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ source 'https://rubygems.org/'

group :test do
git 'https://github.com/Azure/terramodtest.git' do
gem 'terramodtest', :tag => 'v0.2.0'
gem 'terramodtest', :tag => 'v0.3.0'
end
end
4 changes: 4 additions & 0 deletions generators/build/templates/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ namespace :static do
style_tf
end
task :lint do
success = system ("terraform init")
if not success
raise "ERROR: terraform init failed!\n".red
end
lint_tf
end
task :format do
Expand Down
2 changes: 1 addition & 1 deletion generators/build/templates/env_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ else
fi

# Version, OS and Arch for Terraform.
TERRAFORM_VERSION="0.11.7"
TERRAFORM_VERSION="0.12.10"
# Version for Ruby SDK.
RUBY_VERSION="2.3.3"
RUBY_INSTALLED_VERSION_REGEX="^(ruby) ([0-9].[0-9].[0-9]p[0-9]+)"
Expand Down
4 changes: 2 additions & 2 deletions generators/module/templates/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource "random_shuffle" "rs" {
input = ["${var.raw_string_list}"]
result_count = "${var.permutation_count}"
input = var.raw_string_list
result_count = var.permutation_count
}
2 changes: 1 addition & 1 deletion generators/module/templates/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "permutation_string_list" {
description = ""
value = ["${random_shuffle.rs.result}"]
value = random_shuffle.rs.result
}
1 change: 1 addition & 0 deletions generators/module/templates/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
variable "raw_string_list" {
type = list(string)
description = ""
default = ["us-west-1a", "us-west-1b", "us-west-1c"]
}
Expand Down
4 changes: 2 additions & 2 deletions generators/test/templates/fixture/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "template" {
source = "../../"
raw_string_list = ["${var.raw_string_list_test}"]
permutation_count = "${var.permutation_count_test}"
raw_string_list = var.raw_string_list_test
permutation_count = var.permutation_count_test
}
2 changes: 1 addition & 1 deletion generators/test/templates/fixture/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "permutation_string_list_test" {
description = ""
value = ["${module.template.permutation_string_list}"]
value = module.template.permutation_string_list
}
2 changes: 1 addition & 1 deletion generators/test/templates/fixture/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
raw_string_list_test = ["us-west-1a", "us-west-1b", "us-west-1c", "us-west-1d"]
raw_string_list_test = ["us-west-1a", "us-west-1b", "us-west-1c", "us-west-1d"]
permutation_count_test = 2
1 change: 1 addition & 0 deletions generators/test/templates/fixture/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
variable "raw_string_list_test" {
type = list(string)
description = ""
default = []
}
Expand Down
15 changes: 7 additions & 8 deletions generators/test/templates/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ func TestTerraformTemplate(t *testing.T) {

fixtureFolder := "./fixture"

// At the end of the test, clean up any resources that were created
defer test_structure.RunTestStage(t, "teardown", func() {
terraformOptions := test_structure.LoadTerraformOptions(t, fixtureFolder)
terraform.Destroy(t, terraformOptions)
})

// Deploy the example
test_structure.RunTestStage(t, "setup", func() {
terraformOptions := configureTerraformOptions(t, fixtureFolder)
Expand All @@ -29,19 +35,12 @@ func TestTerraformTemplate(t *testing.T) {
terraformOptions := test_structure.LoadTerraformOptions(t, fixtureFolder)

stringList := terraform.Output(t, terraformOptions, "permutation_string_list_test")
const LENGTH int = 22
fmt.Println(stringList)
if len(stringList) != LENGTH {
if len(stringList) <= 0 {
t.Fatal("Wrong output")
}
})

// At the end of the test, clean up any resources that were created
test_structure.RunTestStage(t, "teardown", func() {
terraformOptions := test_structure.LoadTerraformOptions(t, fixtureFolder)
terraform.Destroy(t, terraformOptions)
})

}

func configureTerraformOptions(t *testing.T, fixtureFolder string) *terraform.Options {
Expand Down

0 comments on commit cf82493

Please sign in to comment.