wooden-mechanic-96546
07/17/2024, 2:56 PMName Monthly Qty Unit Monthly Cost
OVERALL TOTAL $0.00
ββββββββββββββββββββββββββββββββββ
1 cloud resource was detected:
β 1 was estimated, 1 includes usage-based costs, see <https://infracost.io/usage-file>
No matter what I do to the cost component when I run my tests the comparison and golden look like this:
Name Monthly Qty Unit Monthly Cost
OVERALL TOTAL $0.00
*Usage costs can be estimated by updating Infracost Cloud settings, see docs for other options.
ββββββββββββββββββββββββββββββββββ
1 cloud resource was detected:
β 0 were estimated
β 1 is not supported yet, see <https://infracost.io/requested-resources>:
β 1 x aws_athena_named_query
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ³ββββββββββββββββ³ββββββββββββββ³βββββββββββββ
β Project β Baseline cost β Usage cost* β Total cost β
β£ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ«
β main β $0.00 β - β $0.00 β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ»ββββββββββββββββ»ββββββββββββββ»βββββββββββββ
It always says it is unsupported. Is there an approve list somewhere in source that dictates what services are/are not supported? I tried manipulating the registry.go, but that doesn't seem to do anything.
I know a Git Issue is requested to be created, but I a not allowed to contribute back, at least right now.
Thank you πcrooked-daybreak-55253
07/17/2024, 2:59 PMinternal/providers/terraform/aws/registry.go
would be the right place. What change did you make there?wooden-mechanic-96546
07/17/2024, 3:04 PMpackage aws
import "github.com/infracost/infracost/internal/schema"
var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{
getAthenaRegistryItem(),
And this for good measure:
// FreeResources grouped alphabetically
var FreeResources = []string{
// AWS Athena
"aws_athena",
I also tried adding it here before and it didn't help:
var UsageOnlyResources = []string{
"aws_data_transfer",
}
I think these are okay too but I'll add below because of the ref to getAthenaRegistryItem()
My /terraform/aws/testdata/athena_test.go looks like this:
package aws_test
import (
"testing"
"github.com/infracost/infracost/internal/providers/terraform/tftest"
)
func TestAthena(t *testing.T) {
t.Parallel()
if testing.Short() {
t.Skip("skipping test in short mode")
}
tftest.GoldenFileResourceTests(t, "athena_test")
}
And my /terraform/aws/testdata/athena.go looks like this:
package aws
import (
"github.com/infracost/infracost/internal/resources/aws"
"github.com/infracost/infracost/internal/schema"
)
func getAthenaRegistryItem() *schema.RegistryItem {
return &schema.RegistryItem{
Name: "aws_athena",
CoreRFunc: newAthena,
}
}
func newAthena(d *schema.ResourceData) schema.CoreResource {
region := d.Get("region").String()
return &aws.Athena{
Address: d.Address,
Region: region,
}
}
And my output:
INFRACOST_LOG_LEVEL=warn go test -timeout 30m -ldflags="-X 'github.com/infracost/infracost/internal/version.Version=v0.10.38+8-ef324706-dirty'" ./internal/providers/terraform/aws --run TestAthena -v -update
{"level":"debug","time":"2024-07-17T11:05:07-04:00","message":"Running command: /opt/homebrew/bin/terraform init -no-color"}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:07-04:00"}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:07-04:00","message":"Initializing the backend..."}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:07-04:00"}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:07-04:00","message":"Initializing provider plugins..."}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:07-04:00","message":"- Reusing previous version of hashicorp/aws from the dependency lock file"}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:07-04:00","message":"- Reusing previous version of hashicorp/google from the dependency lock file"}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:07-04:00","message":"- Reusing previous version of hashicorp/azurerm from the dependency lock file"}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:08-04:00","message":"- Reusing previous version of hashicorp/google-beta from the dependency lock file"}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:08-04:00","message":"- Using previously-installed hashicorp/google-beta v5.34.0"}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:08-04:00","message":"- Using previously-installed hashicorp/aws v5.54.1"}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:08-04:00","message":"- Using previously-installed hashicorp/google v5.34.0"}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:08-04:00","message":"- Using previously-installed hashicorp/azurerm v3.108.0"}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:08-04:00"}
{"level":"debug","binary":"terraform","time":"2024-07-17T11:05:08-04:00","message":"Terraform has been successfully initialized!"}
=== RUN TestAthena
=== PAUSE TestAthena
=== CONT TestAthena
=== RUN TestAthena/HCL
=== RUN TestAthena/HCL_Graph
=== RUN TestAthena/Terraform_CLI
--- PASS: TestAthena (2.60s)
--- PASS: TestAthena/HCL (0.02s)
--- PASS: TestAthena/HCL_Graph (0.02s)
--- PASS: TestAthena/Terraform_CLI (2.56s)
PASS
ok github.com/infracost/infracost/internal/providers/terraform/aws 4.964s
crooked-daybreak-55253
07/17/2024, 3:07 PMName: "aws_athena_named_query"
wooden-mechanic-96546
07/17/2024, 3:14 PMresource "aws_athena_workgroup" "test" {
name = "example"
configuration {
result_configuration {
encryption_configuration {
encryption_option = "SSE_KMS"
kms_key_arn = aws_kms_key.test.arn
}
}
}
}
resource "aws_athena_database" "hoge" {
name = "users"
bucket = aws_s3_bucket.hoge.id
}
In what file to I implement the logic to handle all of them? It seems like /terraform/aws/testdata is split up by services, not resources. I also see that for the big services there is a lot of logic in various files so I guess I assumed all athena terraform resources had to have the same athena.go, and shove all the cost components and logic in there for all.
Is that right? wrong? Best way to do it? I read the naming conventions page but unsure on structure. (I have no go experience too)crooked-daybreak-55253
07/17/2024, 3:20 PM