Drop alias from state file if missing from lambda. (#10759)
* Drop alias from state file if missing from lambda. This commit fixes an issue where if you remove a AWS Lambda, the corresponding alias for that Lambda is also deleted. * Added missing imports. * Removed non-local reference to constant.
This commit is contained in:
parent
442f6de8c9
commit
82ef4b678d
|
@ -3,8 +3,10 @@ package aws
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/lambda"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
@ -82,6 +84,12 @@ func resourceAwsLambdaAliasRead(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
aliasConfiguration, err := conn.GetAlias(params)
|
||||
if err != nil {
|
||||
if awsErr, ok := err.(awserr.Error); ok {
|
||||
if awsErr.Code() == "ResourceNotFoundException" && strings.Contains(awsErr.Message(), "Cannot find alias arn") {
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue