Skip to content

Commit

Permalink
Sanitize tf SSH keypair name
Browse files Browse the repository at this point in the history
Fix #299
  • Loading branch information
justinsb committed Aug 15, 2016
1 parent 004d08d commit 37199e4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions upup/pkg/fi/cloudup/awstasks/sshkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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")
}

0 comments on commit 37199e4

Please sign in to comment.