Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/aws: Use ID in lookup for AWS KMS Aliases #6328

Merged
merged 1 commit into from
Apr 25, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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