Attempt to fix #6794 - update only non empty fields on aws_lambda_function s3
This commit is contained in:
parent
39d68025a5
commit
c5f788ec58
|
@ -306,20 +306,32 @@ func resourceAwsLambdaFunctionUpdate(d *schema.ResourceData, meta interface{}) e
|
||||||
}
|
}
|
||||||
|
|
||||||
codeUpdate := false
|
codeUpdate := false
|
||||||
if d.HasChange("filename") || d.HasChange("source_code_hash") {
|
if v, ok := d.GetOk("filename"); ok {
|
||||||
name := d.Get("filename").(string)
|
if d.HasChange("source_code_hash") {
|
||||||
file, err := loadFileContent(name)
|
file, err := loadFileContent(v.(string))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Unable to load %q: %s", name, err)
|
return fmt.Errorf("Unable to load %q: %s", v.(string), err)
|
||||||
|
}
|
||||||
|
codeReq.ZipFile = file
|
||||||
|
codeUpdate = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
s3Bucket, bucketOk := d.GetOk("s3_bucket")
|
||||||
|
s3Key, keyOk := d.GetOk("s3_key")
|
||||||
|
s3ObjectVersion, versionOk := d.GetOk("s3_object_version")
|
||||||
|
|
||||||
|
if bucketOk && d.HasChange("s3_bucket") {
|
||||||
|
codeReq.S3Bucket = aws.String(s3Bucket.(string))
|
||||||
|
codeUpdate = true
|
||||||
|
}
|
||||||
|
if keyOk && d.HasChange("s3_key") {
|
||||||
|
codeReq.S3Key = aws.String(s3Key.(string))
|
||||||
|
codeUpdate = true
|
||||||
|
}
|
||||||
|
if versionOk && d.HasChange("s3_object_version") {
|
||||||
|
codeReq.S3ObjectVersion = aws.String(s3ObjectVersion.(string))
|
||||||
|
codeUpdate = true
|
||||||
}
|
}
|
||||||
codeReq.ZipFile = file
|
|
||||||
codeUpdate = true
|
|
||||||
}
|
|
||||||
if d.HasChange("s3_bucket") || d.HasChange("s3_key") || d.HasChange("s3_object_version") {
|
|
||||||
codeReq.S3Bucket = aws.String(d.Get("s3_bucket").(string))
|
|
||||||
codeReq.S3Key = aws.String(d.Get("s3_key").(string))
|
|
||||||
codeReq.S3ObjectVersion = aws.String(d.Get("s3_object_version").(string))
|
|
||||||
codeUpdate = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if codeUpdate {
|
if codeUpdate {
|
||||||
|
|
Loading…
Reference in New Issue