Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use HCP provider metadata to track module usage #13

Merged
merged 2 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions examples/hcp-ec2-demo/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ terraform {
}
hcp = {
source = "hashicorp/hcp"
version = ">= 0.15.0"
version = ">= 0.18.0"
}
}

provider_meta "hcp" {
module_name = "hcp-consul"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be even more fine grained? Like hcp-consul-ec2 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like source channel would be terraform-module/hcp-consul-ec2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! I think for now using just hcp-consul is good enough, and is more consistent with the actual name of the module. If we wanted to track EC2-specific usage, I think a better way would be instrumenting the hcp-ec2-client submodule somehow.

}
}

provider "aws" {
region = var.region
}
}
6 changes: 5 additions & 1 deletion examples/hcp-eks-demo/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
hcp = {
source = "hashicorp/hcp"
version = ">= 0.15.0"
version = ">= 0.18.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand All @@ -21,6 +21,10 @@ terraform {
version = ">= 1.11.3"
}
}

provider_meta "hcp" {
module_name = "hcp-consul"
}
}

provider "aws" {
Expand Down
8 changes: 6 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.43"
version = ">= 3.43.0"
}
hcp = {
source = "hashicorp/hcp"
version = ">= 0.15.0"
version = ">= 0.18.0"
}
}

provider_meta "hcp" {
module_name = "hcp-consul"
}
}

locals {
Expand Down
8 changes: 0 additions & 8 deletions test/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ func TestTerraform_EC2DemoExample(t *testing.T) {
})

t.Cleanup(func() {
// Set Vars to nil because the destroy can fail validation based on
// variables provided, such as length of an identifier, and the variables
// are not necessary for a destroy operation.
terraformOptions.Vars = nil
terraform.Destroy(t, terraformOptions)
})

Expand Down Expand Up @@ -102,10 +98,6 @@ func TestTerraform_EKSDemoExample(t *testing.T) {
})

t.Cleanup(func() {
// Set Vars to nil because the destroy can fail validation based on
// variables provided, such as length of an identifier, and the variables
// are not necessary for a destroy operation.
terraformOptions.Vars = nil
terraform.Destroy(t, terraformOptions)
})

Expand Down