Skip to content

Commit

Permalink
provider/aws: Use ID in lookup for AWS KMS Aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
catsby committed Apr 25, 2016
1 parent 6c2b78c commit e138a07
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions builtin/providers/aws/resource_aws_kms_alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,13 @@ func resourceAwsKmsAliasCreate(d *schema.ResourceData, meta interface{}) error {

func resourceAwsKmsAliasRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).kmsconn
name := d.Get("name").(string)

alias, err := findKmsAliasByName(conn, name, nil)
alias, err := findKmsAliasByName(conn, d.Id(), nil)
if err != nil {
return err
}
if alias == nil {
log.Printf("[DEBUG] Removing KMS Alias %q as it's already gone", name)
log.Printf("[DEBUG] Removing KMS Alias (%s) as it's already gone", d.Id())
d.SetId("")
return nil
}
Expand Down Expand Up @@ -138,17 +137,16 @@ func resourceAwsKmsAliasTargetUpdate(conn *kms.KMS, d *schema.ResourceData) erro

func resourceAwsKmsAliasDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).kmsconn
name := d.Get("name").(string)

req := &kms.DeleteAliasInput{
AliasName: aws.String(name),
AliasName: aws.String(d.Id()),
}
_, err := conn.DeleteAlias(req)
if err != nil {
return err
}

log.Printf("[DEBUG] KMS Alias: %s deleted.", name)
log.Printf("[DEBUG] KMS Alias: (%s) deleted.", d.Id())
d.SetId("")
return nil
}
Expand Down

0 comments on commit e138a07

Please sign in to comment.