hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.83k stars 9.19k forks source link

creating Neptune Cluster: InvalidDBClusterStateFault #28546

Open afaqueahmad opened 1 year ago

afaqueahmad commented 1 year ago

Terraform Core Version

v1.3.6

AWS Provider Version

aws v4.46.0

Affected Resource(s)

Official terraform code for creating neptune global cluster is failing.

Trying to create Neptune global cluster as below:

Neptune Global cluster -----Primary Cluster(us-west-2) -----Secondary Cluster(us-east-1)

Global cluster and primary cluster and its instance getting created fine, but when terraform is trying to create secondary cluster, it is throwing below error.

Error: creating Neptune Cluster: InvalidDBClusterStateFault: Source cluster: arn:aws:rds:us-west-2:755529035501:cluster:test-neptune-db is in a state which is not valid for physical replication
│   status code: 400, request id: 9ca474fa-4892-4fab-8df5-6c2487403cff
│ 
│   with module.neptunedb.aws_neptune_cluster.secondary[0],
│   on neptune1/main.tf line 63, in resource "aws_neptune_cluster" "secondary":
│   63: resource "aws_neptune_cluster" "secondary" {

Seems when terraform is trying to create secondary cluster, primary cluster is not in available or not in state which is require for replication cluster.

Expected Behavior

When you run terraform apply again, it works fine but it should work in one go.

Actual Behavior

when you run terraform apply it throws error after creating primary cluster.

I got a workaround that works fine in one go but that is not expected way of doing.

Relevant Error/Panic Output Snippet

aws_neptune_global_cluster.example: Creating...
aws_neptune_global_cluster.example: Creation complete after 2s [id=global-test]
aws_neptune_cluster.primary: Creating...
aws_neptune_cluster.secondary: Creating...
aws_neptune_cluster.primary: Still creating... [10s elapsed]
aws_neptune_cluster.primary: Still creating... [20s elapsed]
aws_neptune_cluster.primary: Still creating... [30s elapsed]
aws_neptune_cluster.primary: Still creating... [40s elapsed]
aws_neptune_cluster.primary: Still creating... [50s elapsed]
aws_neptune_cluster.primary: Still creating... [1m0s elapsed]
aws_neptune_cluster.primary: Creation complete after 1m4s [id=test-primary-cluster]
aws_neptune_cluster_instance.primary: Creating...
aws_neptune_cluster_instance.primary: Still creating... [10s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [20s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [30s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [40s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [50s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [1m0s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [1m10s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [1m20s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [1m30s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [1m40s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [1m50s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [2m0s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [2m10s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [2m20s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [2m30s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [2m40s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [2m50s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [3m0s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [3m10s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [3m20s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [3m30s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [3m40s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [3m50s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [4m0s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [4m10s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [4m20s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [4m30s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [4m40s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [4m50s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [5m0s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [5m10s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [5m20s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [5m30s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [5m40s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [5m50s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [6m0s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [6m10s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [6m20s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [6m30s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [6m40s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [6m50s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [7m0s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [7m10s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [7m20s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [7m30s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [7m40s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [7m50s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [8m0s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [8m10s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [8m20s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [8m30s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [8m40s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [8m50s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [9m0s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [9m10s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [9m20s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [9m30s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [9m40s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [9m50s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [10m0s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [10m10s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [10m20s elapsed]
aws_neptune_cluster_instance.primary: Still creating... [10m30s elapsed]
aws_neptune_cluster_instance.primary: Creation complete after 10m36s [id=test-primary-cluster-instance]
╷
│ Error: creating Neptune Cluster: InvalidDBClusterStateFault: Source cluster: arn:aws:rds:us-west-2:755529035501:cluster:test-primary-cluster is in a state which is not valid for physical replication
│   status code: 400, request id: 306e0a05-adca-4bff-8990-f3c872f1d04b
│ 
│   with aws_neptune_cluster.secondary,
│   on main.tf line 38, in resource "aws_neptune_cluster" "secondary":
│   38: resource "aws_neptune_cluster" "secondary" {

Terraform Configuration Files

provider "aws" {
  alias  = "primary"
  region = "us-east-2"
}

provider "aws" {
  alias  = "secondary"
  region = "us-east-1"
}

resource "aws_neptune_global_cluster" "example" {
  global_cluster_identifier = "global-test"
  engine                    = "neptune"
  engine_version            = "1.2.0.0"
}

resource "aws_neptune_cluster" "primary" {
  provider                  = aws.primary
  engine                    = aws_neptune_global_cluster.example.engine
  engine_version            = aws_neptune_global_cluster.example.engine_version
  cluster_identifier        = "test-primary-cluster"
  global_cluster_identifier = aws_neptune_global_cluster.example.id
  neptune_subnet_group_name = "default"
}

resource "aws_neptune_cluster_instance" "primary" {
  provider                  = aws.primary
  engine                    = aws_neptune_global_cluster.example.engine
  engine_version            = aws_neptune_global_cluster.example.engine_version
  identifier                = "test-primary-cluster-instance"
  cluster_identifier        = aws_neptune_cluster.primary.id
  instance_class            = "db.r5.large"
  neptune_subnet_group_name = "default"
}

resource "aws_neptune_cluster" "secondary" {
  provider                  = aws.secondary
  engine                    = aws_neptune_global_cluster.example.engine
  engine_version            = aws_neptune_global_cluster.example.engine_version
  cluster_identifier        = "test-secondary-cluster"
  global_cluster_identifier = aws_neptune_global_cluster.example.id
  neptune_subnet_group_name = "default"
}

resource "aws_neptune_cluster_instance" "secondary" {
  provider                  = aws.secondary
  engine                    = aws_neptune_global_cluster.example.engine
  engine_version            = aws_neptune_global_cluster.example.engine_version
  identifier                = "test-secondary-cluster-instance"
  cluster_identifier        = aws_neptune_cluster.secondary.id
  instance_class            = "db.r5.large"
  neptune_subnet_group_name = "default"

  depends_on = [
    aws_neptune_cluster_instance.primary
  ]
}

Steps to Reproduce

terraform init terraform apply

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

Yes

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue