forked from hashicorp/terraform-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
r/aws_elasticache_cluster: Add support for in-transit encryption
Fixes: hashicorp#26367
- Loading branch information
Showing
4 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package elasticache | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
gversion "github.com/hashicorp/go-version" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
var minMemcachedTransitEncryptionVersion = gversion.Must(gversion.NewVersion("1.6.12")) | ||
|
||
func CustomizeDiffValidateTransitEncryptionEnabled(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error { | ||
engine := diff.Get("engine").(string) | ||
|
||
transitEncryptionEnabled, ok := diff.GetOk("transit_encryption_enabled") | ||
if !ok || !transitEncryptionEnabled.(bool) { | ||
return nil | ||
} | ||
|
||
if engine == engineRedis { | ||
return fmt.Errorf("aws_elasticache_cluster does not support transit encryption using the redis engine, use aws_elasticache_replication_group instead") | ||
} | ||
|
||
engineVersion, ok := diff.GetOk("engine_version") | ||
if !ok { | ||
return nil | ||
} | ||
|
||
version, err := normalizeEngineVersion(engineVersion.(string)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if version.LessThan(minMemcachedTransitEncryptionVersion) { | ||
return fmt.Errorf("Transit encryption is not supported for memcached version %v", version) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters