Sanitize tf SSH keypair name

Fix #299
This commit is contained in:
Justin Santa Barbara 2016-08-14 23:16:05 -04:00
parent 004d08d1a6
commit 37199e4849
1 changed files with 5 additions and 3 deletions

View File

@ -230,7 +230,8 @@ type terraformSSHKey struct {
}
func (_ *SSHKey) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *SSHKey) error {
publicKey, err := t.AddFile("aws_key_pair", *e.Name, "public_key", e.PublicKey)
tfName := strings.Replace(*e.Name, ":", "", -1)
publicKey, err := t.AddFile("aws_key_pair", tfName, "public_key", e.PublicKey)
if err != nil {
return fmt.Errorf("error rendering PublicKey: %v", err)
}
@ -240,9 +241,10 @@ func (_ *SSHKey) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *SS
PublicKey: publicKey,
}
return t.RenderResource("aws_key_pair", *e.Name, tf)
return t.RenderResource("aws_key_pair", tfName, tf)
}
func (e *SSHKey) TerraformLink() *terraform.Literal {
return terraform.LiteralProperty("aws_key_pair", *e.Name, "id")
tfName := strings.Replace(*e.Name, ":", "", -1)
return terraform.LiteralProperty("aws_key_pair", tfName, "id")
}