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

instance_type_replica not honoured #220

Closed
svenlito opened this issue May 11, 2021 · 16 comments
Closed

instance_type_replica not honoured #220

svenlito opened this issue May 11, 2021 · 16 comments

Comments

@svenlito
Copy link

Description

When creating a cluster where instance_type is set, instance_type_replica is ignored and instance_type is used for replica instances.

I believe this was introduced here #211

Reproduction

Steps to reproduce the behavior:

create autoscaling example with instance_type and instance_type_replica defined.

Expected behavior

instance_type_replica to be honoured.

Actual behavior

instance_type_replica uses instance_type value

@svenlito svenlito changed the title instance_type_replica not honoured when instance_type is set instance_type_replica not honoured May 11, 2021
@rnrsr
Copy link

rnrsr commented May 11, 2021

When creating a cluster where instance_type is set, instance_type_replica is ignored and instance_type is used for replica instances.

@svenlito I think this is intentional, from the instance_type description here: https://registry.terraform.io/modules/terraform-aws-modules/rds-aurora/aws/latest?tab=inputs
it says:

If instance_type_replica is not set it will use the same type for replica instances

If you want different types used on your read replicas specify the instance_type_replica like so, i just tried it on 5.2.0:

  replica_count                = 2
  instance_type                = "db.t3.small"
  instance_type_replica        = "db.t3.medium"

gives me:

  # module.rds_my.module.rds-cluster.aws_rds_cluster_instance.this[0] will be updated in-place
  ~ resource "aws_rds_cluster_instance" "this" {
        id                              = "my-1"
      ~ instance_class                  = "db.r5.large" -> "db.t3.small"
      ~ performance_insights_enabled    = true -> false
        tags                            = {
            "Environment" = "dev"
            "Terraform"   = "true"
        }
        # (25 unchanged attributes hidden)
    }

  # module.rds_my.module.rds-cluster.aws_rds_cluster_instance.this[1] will be updated in-place
  ~ resource "aws_rds_cluster_instance" "this" {
        id                              = "my-2"
      ~ instance_class                  = "db.r5.large" -> "db.t3.medium"
      ~ performance_insights_enabled    = true -> false
        tags                            = {
            "Environment" = "dev"
            "Terraform"   = "true"
        }
        # (25 unchanged attributes hidden)
    }

@svenlito
Copy link
Author

@rnrsr what I found is that whether I remove the instance_type_replica attribute or update it, my state doesn't change and it's stuck with whatever I've set instance_type to be. The example you're showing works because you're also changing the value of instance_type.

@rnrsr
Copy link

rnrsr commented May 11, 2021

I don't think that's accurate, if i just try changing the instance_type_replica based on the above example, i get:

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.rds_my.module.rds-cluster.aws_rds_cluster_instance.this[1] will be updated in-place
  ~ resource "aws_rds_cluster_instance" "this" {
        id                              = "my-2"
      ~ instance_class                  = "db.r5.large" -> "db.t3.medium"
        tags                            = {
            "Environment" = "dev"
            "Terraform"   = "true"
        }
        # (26 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

So it did ignore the master instance

@svenlito svenlito added the bug label May 11, 2021
@svenlito
Copy link
Author

I don't think that's accurate, if i just try changing the instance_type_replica based on the above example, i get:

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.rds_offers.module.rds-cluster.aws_rds_cluster_instance.this[1] will be updated in-place
  ~ resource "aws_rds_cluster_instance" "this" {
        id                              = "offers-2"
      ~ instance_class                  = "db.r5.large" -> "db.t3.medium"
        tags                            = {
            "Environment" = "dev"
            "Terraform"   = "true"
        }
        # (26 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

I get:

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.

@rnrsr
Copy link

rnrsr commented May 11, 2021

╰─❯ terraform version
Terraform v0.14.4
+ provider registry.terraform.io/hashicorp/aws v3.36.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0

Your version of Terraform is out of date! The latest version
is 0.15.3. You can update by downloading from https://www.terraform.io/downloads.html

@svenlito
Copy link
Author

➔ t version
Terraform v0.14.2
+ provider registry.terraform.io/hashicorp/aws v3.39.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/hashicorp/vault v2.19.1
+ provider registry.terraform.io/terraform-providers/mysql v1.9.0

Your version of Terraform is out of date! The latest version
is 0.15.3. You can update by downloading from https://www.terraform.io/downloads.html

@rnrsr
Copy link

rnrsr commented May 11, 2021

wierd. tried a re-init?

@svenlito
Copy link
Author

Doing both, bumping to 0.14.4 and re-init now.

@svenlito
Copy link
Author

Doing both, bumping to 0.14.4 and re-init now.

This didn't help.

@rnrsr
Copy link

rnrsr commented May 11, 2021

interesting, what replica_count are you using?

i notice this count.index > 0 ? in the commit. Are you trying to reduce the replica_count to 1 at the same time as removing the instance_type_replica?

@svenlito
Copy link
Author

interesting, what replica_count are you using?

Currently replica_count = 1

@svenlito
Copy link
Author

if replica_count is set to 2 it will create module.production_master.aws_rds_cluster_instance.this[1] with the intended instance_type. Did I misinterprete the docs?

@svenlito
Copy link
Author

interesting, what replica_count are you using?

i notice this count.index > 0 ? in the commit. Are you trying to reduce the replica_count to 1 at the same time as removing the instance_type_replica?

Oh, I think this is an off by one type of mistake then..

@svenlito
Copy link
Author

I think this should be https://github.com/terraform-aws-modules/terraform-aws-rds-aurora/blob/master/main.tf#L119

instance_class = try(lookup(var.instances_parameters[count.index], "instance_type"), count.index + 1 > 0 ? coalesce(var.instance_type_replica, var.instance_type) : var.instance_type)

@svenlito
Copy link
Author

I think #193 is somewhat related

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants