Skip to content

Commit

Permalink
Update module versions. Update terratest (#26)
Browse files Browse the repository at this point in the history
* Update module versions. Update terratest

* Update module versions. Update terratest
  • Loading branch information
aknysh authored Feb 4, 2021
1 parent 19ef683 commit d70e308
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2019 Cloud Posse, LLC
Copyright 2019-2021 Cloud Posse, LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
10 changes: 6 additions & 4 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ provider "aws" {
}

module "vpc" {
source = "cloudposse/vpc/aws"
version = "0.18.1"
source = "cloudposse/vpc/aws"
version = "0.20.1"

cidr_block = var.vpc_cidr_block

context = module.this.context
}

module "subnets" {
source = "cloudposse/dynamic-subnets/aws"
version = "0.33.0"
source = "cloudposse/dynamic-subnets/aws"
version = "0.37.0"

availability_zones = var.availability_zones
vpc_id = module.vpc.vpc_id
igw_id = module.vpc.igw_id
Expand Down
12 changes: 7 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ resource "aws_docdb_cluster_instance" "default" {
cluster_identifier = join("", aws_docdb_cluster.default.*.id)
apply_immediately = var.apply_immediately
instance_class = var.instance_class
tags = module.this.tags
engine = var.engine
auto_minor_version_upgrade = var.auto_minor_version_upgrade
tags = module.this.tags
}

resource "aws_docdb_subnet_group" "default" {
Expand Down Expand Up @@ -109,8 +109,9 @@ locals {
}

module "dns_master" {
source = "cloudposse/route53-cluster-hostname/aws"
version = "0.8.0"
source = "cloudposse/route53-cluster-hostname/aws"
version = "0.11.0"

enabled = module.this.enabled && var.zone_id != "" ? true : false
dns_name = local.cluster_dns_name
zone_id = var.zone_id
Expand All @@ -120,8 +121,9 @@ module "dns_master" {
}

module "dns_replicas" {
source = "cloudposse/route53-cluster-hostname/aws"
version = "0.8.0"
source = "cloudposse/route53-cluster-hostname/aws"
version = "0.11.0"

enabled = module.this.enabled && var.zone_id != "" ? true : false
dns_name = local.replicas_dns_name
zone_id = var.zone_id
Expand Down
19 changes: 15 additions & 4 deletions test/src/examples_complete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package test

import (
"fmt"
"math/rand"
"strconv"
"testing"
"time"

"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
Expand All @@ -12,13 +15,21 @@ import (
func TestExamplesComplete(t *testing.T) {
t.Parallel()

rand.Seed(time.Now().UnixNano())

randId := strconv.Itoa(rand.Intn(100000))
attributes := []string{randId}

// We need to create the ALB first because terraform does not wwait for it to be in the ready state before creating ECS target group
terraformOptions := &terraform.Options{
// The path to where our Terraform code is located
TerraformDir: "../../examples/complete",
Upgrade: true,
// Variables to pass to our Terraform code using -var-file options
VarFiles: []string{"fixtures.us-east-2.tfvars"},
Vars: map[string]interface{}{
"attributes": attributes,
},
}

// At the end of the test, run `terraform destroy` to clean up any resources that were created
Expand Down Expand Up @@ -52,20 +63,20 @@ func TestExamplesComplete(t *testing.T) {
// Run `terraform output` to get the value of an output variable
securityGroupName := terraform.Output(t, terraformOptions, "security_group_name")
// Verify we're getting back the outputs we expect
assert.Equal(t, "eg-test-documentdb-cluster", securityGroupName)
assert.Equal(t, "eg-test-documentdb-cluster-"+randId, securityGroupName)

// Run `terraform output` to get the value of an output variable
clusterName := terraform.Output(t, terraformOptions, "cluster_name")
// Verify we're getting back the outputs we expect
assert.Equal(t, "eg-test-documentdb-cluster", clusterName)
assert.Equal(t, "eg-test-documentdb-cluster-"+randId, clusterName)

// Run `terraform output` to get the value of an output variable
endpoint := terraform.Output(t, terraformOptions, "endpoint")
// Verify we're getting back the outputs we expect
assert.Contains(t, endpoint, "eg-test-documentdb-cluster.cluster")
assert.Contains(t, endpoint, "eg-test-documentdb-cluster-"+randId+".cluster")

// Run `terraform output` to get the value of an output variable
readerEndpoint := terraform.Output(t, terraformOptions, "reader_endpoint")
// Verify we're getting back the outputs we expect
assert.Contains(t, readerEndpoint, "eg-test-documentdb-cluster.cluster-ro")
assert.Contains(t, readerEndpoint, "eg-test-documentdb-cluster-"+randId+".cluster-ro")
}

0 comments on commit d70e308

Please sign in to comment.