diff --git a/_example/basic_example/example.tf b/_example/basic_example/example.tf index 764fb90..6b6196e 100644 --- a/_example/basic_example/example.tf +++ b/_example/basic_example/example.tf @@ -123,11 +123,11 @@ data "aws_iam_policy_document" "iam-policy" { module "ec2" { source = "./../../" - name = "ec2-instance" + name = "ec2" environment = "test" label_order = ["name", "environment"] - instance_count = 2 + instance_count = 1 ami = "ami-08d658f84a6d84a80" instance_type = "t2.nano" monitoring = false diff --git a/_example/basic_example/outputs.tf b/_example/basic_example/outputs.tf index a9abe3b..d3fdfab 100644 --- a/_example/basic_example/outputs.tf +++ b/_example/basic_example/outputs.tf @@ -2,3 +2,8 @@ output "instance_id" { value = module.ec2.*.instance_id description = "The instance ID." } + +output "tags" { + value = module.ec2.tags + description = "The instance ID." +} diff --git a/_example/secure_example/example.tf b/_example/secure_example/example.tf index babadb0..180673b 100644 --- a/_example/secure_example/example.tf +++ b/_example/secure_example/example.tf @@ -136,9 +136,9 @@ data "aws_iam_policy_document" "kms" { module "ec2" { source = "./../../" - name = "ec2-instance" + name = "ec2" environment = "test" - label_order = ["environment", "name"] + label_order = ["name", "environment"] instance_count = 2 ami = "ami-08d658f84a6d84a80" diff --git a/_test/basic_example/ec2_test.go b/_test/basic_example/ec2_test.go index dc1f3b1..32ead38 100644 --- a/_test/basic_example/ec2_test.go +++ b/_test/basic_example/ec2_test.go @@ -25,8 +25,8 @@ func Test(t *testing.T) { defer terraform.Destroy(t, terraformOptions) // To get the value of an output variable, run 'terraform output' - Id := terraform.Output(t, terraformOptions, "instance_id") + Tags := terraform.OutputMap(t, terraformOptions, "tags") // Check that we get back the outputs that we expect - assert.Contains(t, Id, "i-") + assert.Equal(t, "ec2-test", Tags["Name"]) } diff --git a/_test/basic_example/go.mod b/_test/basic_example/go.mod deleted file mode 100644 index a912351..0000000 --- a/_test/basic_example/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module github.com/clouddrove/terraform-aws-ec2/baisc_example - -go 1.13 - -require ( - github.com/gruntwork-io/terratest v0.30.6 - github.com/stretchr/testify v1.6.1 -) diff --git a/_test/secure_example/ec2_test.go b/_test/secure_example/ec2_test.go index 247a1ec..732dc10 100644 --- a/_test/secure_example/ec2_test.go +++ b/_test/secure_example/ec2_test.go @@ -25,8 +25,8 @@ func Test(t *testing.T) { defer terraform.Destroy(t, terraformOptions) // To get the value of an output variable, run 'terraform output' - Id := terraform.Output(t, terraformOptions, "instance_id") + Tags := terraform.OutputMap(t, terraformOptions, "tags") // Check that we get back the outputs that we expect - assert.Contains(t, Id, "i-") + assert.Equal(t, "ec2-test", Tags["Name"]) } diff --git a/_test/secure_example/go.mod b/_test/secure_example/go.mod deleted file mode 100644 index c328511..0000000 --- a/_test/secure_example/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module github.com/clouddrove/terraform-aws-ec2/secure_example - -go 1.13 - -require ( - github.com/gruntwork-io/terratest v0.30.6 - github.com/stretchr/testify v1.6.1 -) diff --git a/outputs.tf b/outputs.tf index fc0a2cf..ebab533 100644 --- a/outputs.tf +++ b/outputs.tf @@ -58,3 +58,8 @@ output "instance_count" { value = var.instance_count description = "The count of instances." } + +output "tags" { + value = module.labels.tags + description = "The instance ID." +}