-
Notifications
You must be signed in to change notification settings - Fork 57
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
SUMO-245309 Add the terraform support for Azure metric sources #710
base: master
Are you sure you want to change the base?
Conversation
f59c28c
to
68ade3d
Compare
68ade3d
to
5397700
Compare
de76dfc
to
9ccf1a2
Compare
2a5c0b5
to
a10c426
Compare
a10c426
to
df9b4b0
Compare
9606f54
to
c0deeeb
Compare
environment = "Azure" | ||
limit_to_namespaces = ["Microsoft.ClassicStorage/storageAccounts"] | ||
azure_tag_filters { | ||
type = "AzureTagFilters" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we require this type inside azure_tag_filters
? since you created this azure_tag_filters
field specifically for Azure source, it means azure_tag_filters
field should only be of type AzureTagFilters
, there wouldn't be other types of azure_tag_filters
. for this one-to-one mapping, we still require user to specify this type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we require user to specify type = "AzureTagFilters"
explicitly is due to the reason that it will make it easier for the conversion from API json back to terraform resource.
When type
is defined in api, the responses body of the CREATE/UPDATE API will also include the type of tag filters. Otherwise, type
will also won't display in responses. Thus, by checking the type
from the response body, we can easily know that we should convert TagFilters
filed to azure_tag_filters
or tag_filters
. Thus, it's not required for user clarification, it's for backend conversion convenience.
name = "test-name-2" | ||
values = ["value2"] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the array representation here looks very different that the API layer, in the API layer if I want to specify tags for two different namespaces where each namespace there are two tag names, it would look like this
{
"tagFilters":[
{
"type":"AzureTagFilters",
"namespace":"Microsoft.Web/namespace1",
"tags":[
{
"name":"name1",
"values":["value1", "value2"]
},
{
"name":"name2",
"values":["value1", "value2"]
}
]
},
{
"type":"AzureTagFilters",
"namespace":"Microsoft.Web/namespace2",
"tags":[
{
"name":"name1",
"values":["value1", "value2"]
},
{
"name":"name2",
"values":["value1", "value2"]
}
]
}
]
}
but it seems based on your example here, the above API config translated to TF config would look like this:
azure_tag_filters {
type = "AzureTagFilters"
namespace = "Microsoft.Web/namespace1"
tags {
name = "name1"
values = ["value1", "value2"]
}
tags {
name = "name2"
values = ["value1", "value2"]
}
}
azure_tag_filters {
type = "AzureTagFilters"
namespace = "Microsoft.Web/namespace1"
tags {
name = "test-name-1"
values = ["value1", "value2"]
}
tags {
name = "test-name-1"
values = ["value1", "value2"]
}
}
azure_tag_filters
keyword is repeated for each array element and same goes for tags
, which is not the same in API layer. Is that expected and ideal for what we should use here? I notice that values = ["value1", "value2"]
is still following the normal array representation, so you have two different array representation in the same section and I'm not sure if that's a good thing.
also if we keep this, then the naming needs to change, basically these two fields should both change from plural to singular because each represents a single array element. In the normal array representation like values = ["value1", "value2"]
you have plural values
because all the array elements are under this name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the cloudwatch tagFilters
field is what I expected the azure_tag_filters
to look like https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs/resources/polling_source#example-usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed the way kinesis metric source defined the tag_filters
: https://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs/resources/kinesis_metrics_source:
path {
type = "KinesisMetricPath"
tag_filters {
type = "TagFilters"
namespace = "All"
tags = ["k3=v3"]
}
tag_filters {
type = "TagFilters"
namespace = "AWS/Route53"
tags = ["k1=v1"]
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'm currently suspecting if these two forms are equivalent in terraform world. I can do some experiments around this.
In this PR, we added the terraform support for Azure metrics sources.
Changes
One thing to mention here for
TagFilters
field in Azure metrics sources, we added a newazure_tag_filters
instead of using the sametag_filters
as CloudWatch sources and kinesis metrics sources. The major reason is that fortags
, the schemas are different and it requires to have a detailed schema definition in terraform world, which is why we added this new field. And forazure_tag_filters
, we requiredtype = "AzureTagFilters"
to be required.Test
Tests / Matrix Test (1.0.3) (pull_request)
are not passing with the following error:The reason is that we need to ask the terraform team to help us to configure the following secrets for the test to run:
I'll work with the team on fixing it: slack: #terraform-team