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

F Warning for blue/green deployment on OpenSearch service #40507

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
48 changes: 39 additions & 9 deletions internal/service/opensearch/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,6 @@ func resourceDomainCreate(ctx context.Context, d *schema.ResourceData, meta inte
func resourceDomainRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).OpenSearchClient(ctx)

ds, err := findDomainByName(ctx, conn, d.Get(names.AttrDomainName).(string))

if !d.IsNewResource() && tfresource.NotFound(err) {
Expand All @@ -855,7 +854,6 @@ func resourceDomainRead(ctx context.Context, d *schema.ResourceData, meta interf
if err != nil {
return sdkdiag.AppendErrorf(diags, "reading OpenSearch Domain (%s): %s", d.Id(), err)
}

dc := outDescribeDomainConfig.DomainConfig

if ds.AccessPolicies != nil && aws.ToString(ds.AccessPolicies) != "" {
Expand Down Expand Up @@ -1005,19 +1003,30 @@ func resourceDomainUpdate(ctx context.Context, d *schema.ResourceData, meta inte
if d.HasChange("advanced_options") {
input.AdvancedOptions = flex.ExpandStringValueMap(d.Get("advanced_options").(map[string]interface{}))
}

if d.HasChange("advanced_security_options") {
input.AdvancedSecurityOptions = expandAdvancedSecurityOptions(d.Get("advanced_security_options").([]interface{}))
if (d.Get("advanced_security_options.0.enabled")).(bool) {
diags = sdkdiag.AppendWarningf(diags, "One of the updated attribute may cause a blue/green deployment on the cluster")
}
}

if d.HasChange("auto_tune_options") {
input.AutoTuneOptions = expandAutoTuneOptions(d.Get("auto_tune_options").([]interface{})[0].(map[string]interface{}))
if (d.Get("auto_tune_options.0.desired_state")).(string) == "DISABLED" {
diags = sdkdiag.AppendWarningf(diags, "One of the updated attribute may cause a blue/green deployment on the cluster")
}
}

if d.HasChange("cognito_options") {
input.CognitoOptions = expandCognitoOptions(d.Get("cognito_options").([]interface{}))
}

if d.HasChange("cluster_config.0.dedicated_master_count") {
o, n := d.GetChange("cluster_config.0.dedicated_master_count")
if o.(int) > n.(int) && o.(int) >= 2 {
diags = sdkdiag.AppendWarningf(diags, "One of the updated attribute may cause a blue/green deployment on the cluster")
}
}

if d.HasChange("domain_endpoint_options") {
input.DomainEndpointOptions = expandDomainEndpointOptions(d.Get("domain_endpoint_options").([]interface{}))
}
Expand All @@ -1036,7 +1045,6 @@ func resourceDomainUpdate(ctx context.Context, d *schema.ResourceData, meta inte

if d.HasChange("cluster_config") {
config := d.Get("cluster_config").([]interface{})

if len(config) == 1 {
m := config[0].(map[string]interface{})
input.ClusterConfig = expandClusterConfig(m)
Expand All @@ -1056,32 +1064,42 @@ func resourceDomainUpdate(ctx context.Context, d *schema.ResourceData, meta inte
} else {
log.Printf("[WARN] %s", err)
}
if d.HasChange("cluster_config.0.multi_az_with_standby_enabled") {
diags = sdkdiag.AppendWarningf(diags, "One of the updated attribute may cause a blue/green deployment on the cluster")
}
}
}
}

if d.HasChange("ebs_options") {
o, n := d.GetChange("ebs_options.0.volume_size")
if o.(int) > n.(int) {
diags = sdkdiag.AppendWarningf(diags, "One of the updated attribute may cause a blue/green deployment on the cluster")
}
}
if d.HasChange("encrypt_at_rest") {
input.EncryptionAtRestOptions = nil
if v, ok := d.GetOk("encrypt_at_rest"); ok {
options := v.([]interface{})
if options[0] == nil {
return sdkdiag.AppendErrorf(diags, "at least one field is expected inside encrypt_at_rest")
}

s := options[0].(map[string]interface{})
input.EncryptionAtRestOptions = expandEncryptAtRestOptions(s)
}
}

if d.HasChange("log_publishing_options") {
input.LogPublishingOptions = expandLogPublishingOptions(d.Get("log_publishing_options").(*schema.Set))
if d.Get("log_publishing_options.0.enabled").(bool) {
diags = sdkdiag.AppendWarningf(diags, "One of the updated attribute may cause a blue/green deployment on the cluster")
}
}

if d.HasChange("node_to_node_encryption") {
input.NodeToNodeEncryptionOptions = nil
if v, ok := d.GetOk("node_to_node_encryption"); ok {
options := v.([]interface{})

s := options[0].(map[string]interface{})
input.NodeToNodeEncryptionOptions = expandNodeToNodeEncryptionOptions(s)
}
Expand All @@ -1107,6 +1125,7 @@ func resourceDomainUpdate(ctx context.Context, d *schema.ResourceData, meta inte

if d.HasChange("software_update_options") {
input.SoftwareUpdateOptions = expandSoftwareUpdateOptions(d.Get("software_update_options").([]interface{}))
diags = sdkdiag.AppendWarningf(diags, "One of the updated attribute may cause a blue/green deployment on the cluster")
}

if d.HasChange("vpc_options") {
Expand All @@ -1132,7 +1151,13 @@ func resourceDomainUpdate(ctx context.Context, d *schema.ResourceData, meta inte
DomainName: aws.String(d.Get(names.AttrDomainName).(string)),
TargetVersion: aws.String(d.Get(names.AttrEngineVersion).(string)),
}
o, n := d.GetChange(names.AttrEngineVersion)
_, oldVersion, _ := parseEngineVersion(o.(string))
_, newVersion, _ := parseEngineVersion(n.(string))

if semver.GreaterThanOrEqual(newVersion, oldVersion) {
diags = sdkdiag.AppendWarningf(diags, "One of the updated attribute may cause a blue/green deployment on the cluster")
}
_, err := conn.UpgradeDomain(ctx, &upgradeInput)
if err != nil {
return sdkdiag.AppendErrorf(diags, "updating OpenSearch Domain (%s): upgrading: %s", d.Id(), err)
Expand All @@ -1142,16 +1167,21 @@ func resourceDomainUpdate(ctx context.Context, d *schema.ResourceData, meta inte
return sdkdiag.AppendErrorf(diags, "updating OpenSearch Domain (%s): upgrading: waiting for completion: %s", d.Id(), err)
}
}
// All changes that can cause a blue/green deployment
if d.HasChanges("cluster_config.0.instance_type", "cluster_config.0.warm_enabled", "cluster_config.0.cold_storage_options.enabled",
"cluster_config.0.dedicated_master_enabled", "vpc_options.0.subnet_ids", "vpc_options.0.security_group_ids",
"cognito_options.0.enabled", "cognito_options.0.identity_pool_id", "cognito_options.0.user_pool_id",
"advanced_options", "log_publishing_options", "encrypt_at_rest", "node_to_node_encryption") {
diags = sdkdiag.AppendWarningf(diags, "One of the updated attribute may cause a blue/green deployment on the cluster")
}
}

return append(diags, resourceDomainRead(ctx, d, meta)...)
}

func resourceDomainDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).OpenSearchClient(ctx)
domainName := d.Get(names.AttrDomainName).(string)

log.Printf("[DEBUG] Deleting OpenSearch Domain: %q", domainName)
_, err := conn.DeleteDomain(ctx, &opensearch.DeleteDomainInput{
DomainName: aws.String(domainName),
Expand Down
Loading