Terraform 0.11 had incomplete validation of resource and provider alias
names, which worked only due to the strange way HIL parsed variable names.
Terraform 0.12 (based on HIL) requires valid identifiers, so we'll let
users know about this before they upgrade. It will be easier for users to
deal with this while still on Terraform 0.11 because it won't run into
parse errors trying to work with the invalid name.
// Each element of "items" will be rendered as a task list item using
// GitHub's task list extension.
for_,rc:=rangecfg.Resources{
varblockTypestring
switchrc.Mode{
caseconfig.ManagedResourceMode:
blockType="resource"
caseconfig.DataResourceMode:
blockType="data"
default:// should never happen, because any other type would be a configuration loading error
blockType="???"
}
if!hcl2syntax.ValidIdentifier(rc.Name){
items=append(items,fmt.Sprintf(
"`%s %q %q` has a name that is not a valid identifier.\n\n"+
"In Terraform 0.12, resource names must start with a letter. To fix this, rename the resource in the configuration and then use `terraform state mv` to mirror that name change in the state.",
blockType,rc.Type,rc.Name,
))
}
}
for_,pc:=rangecfg.ProviderConfigs{
ifpc.Alias==""{
continue
}
if!hcl2syntax.ValidIdentifier(pc.Alias){
items=append(items,fmt.Sprintf(
"`provider %q` alias %q is not a valid identifier.\n\n"+
"In Terraform 0.12, provider aliases must start with a letter. To fix this, rename the provider alias and any references to it in the configuration and then run `terraform apply` to re-attach any existing resources to the new alias name.",