terranetes-controller
terranetes-controller copied to clipboard
AWS Provider - default tags
Describe the bug
Hello,
When using the AWS provider, the configuration
property doesn't allow setting up a map as value for defining the default_tags.tags
.
To Reproduce
Steps to reproduce the behavior:
- Apply the following provider definition:
apiVersion: terraform.appvia.io/v1alpha1
kind: Provider
metadata:
name: aws
spec:
configuration:
assume_role:
role_arn: "arn:aws:iam::${some_account_id}:role/${some_role}"
default_tags:
tags:
Environment: "dev"
Name: "${some_name}"
Region: "${some_region}"
CostCenter: "${some_cost_center}"
Terraform: true
- Deploy a CloudResource using the provider above, here is the
provider.tf
produced with the controller inside of the secret with all the config:
provider "aws" {
assume_role {
role_arn = "arn:aws:iam::${some_account_id}:role/${some_role}"
}
default_tags {
tags {
CostCenter = "${some_cost_center}"
Environment = "dev"
Name = "${some_name}"
Region = "${some_region}"
Terraform = true
}
}
}
- When the plan runs, it generates the following error:
Error: Unsupported block type
on provider.tf line 8, in provider "aws":
8: tags {
Blocks of type "tags" are not expected here. Did you mean to define argument
"tags"? If so, use the equals sign to assign it a value.
Expected behavior
When the parsing happens, default_tags.tags
should be seen an argument, rather than a block. I think the logic for dealing with it should be implemented in here: https://github.com/appvia/terranetes-controller/blob/master/pkg/utils/terraform/utils.go#L136
I would expect such output for the provider.tf
:
provider "aws" {
assume_role {
role_arn = "arn:aws:iam::${some_account_id}:role/${some_role}"
}
default_tags {
tags = {
CostCenter = "${some_cost_center}"
Environment = "dev"
Name = "${some_name}"
Region = "${some_region}"
Terraform = true
}
}
}