terraform-aws-modules / terraform-aws-rds-aurora

Terraform module to create AWS RDS Aurora resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/rds-aurora/aws
Apache License 2.0
382 stars 551 forks source link

Enabling the RDS Data API for Postgres Serverless v2 #440

Closed jritsema closed 1 month ago

jritsema commented 3 months ago

Description

For enable_http_endpoint, the docs say:

Enable HTTP endpoint (data API). Only valid when engine_mode is set to serverless

I was able to enable this when creating a serverless v2 cluster using the AWS console, so are the docs correct here?

When I tested it in Terraform, it appears to try setting it but ultimately did not work.

provider "aws" {}

variable "name" {
  type    = string
  default = "tf-aurora-postgres-serverless"
}

data "aws_rds_engine_version" "postgresql" {
  engine  = "aurora-postgresql"
  version = "15.4"
}

# lookup vpc by id
data "aws_vpc" "main" {
  id = "vpc-123456789012"
}

module "aurora_postgresql_v2" {
  source = "terraform-aws-modules/rds-aurora/aws"

  name              = var.name
  engine            = data.aws_rds_engine_version.postgresql.engine
  engine_mode       = "provisioned"
  engine_version    = data.aws_rds_engine_version.postgresql.version
  storage_encrypted = true

  master_username             = "postgres"
  manage_master_user_password = true
  enable_http_endpoint        = true

  vpc_id = data.aws_vpc.main.id

  db_subnet_group_name = module.vpc.database_subnet_group_name

  backup_retention_period = 7

  monitoring_interval = 60

  apply_immediately   = true
  skip_final_snapshot = true

  serverlessv2_scaling_configuration = {
    min_capacity = 0.5
    max_capacity = 2
  }

  instance_class = "db.serverless"
  instances = {
    one = {}
  }
}
Terraform will perform the following actions:

  # module.aurora_postgresql_v2.aws_rds_cluster.this[0] will be updated in-place
  ~ resource "aws_rds_cluster" "this" {
      ~ enable_http_endpoint                = false -> true
        id                                  = "tf-aurora-postgres-serverless"
        tags                                = {}
        # (39 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

If your request is for a new feature, please use the Feature request template.

Versions

Reproduction Code [Required]

Steps to reproduce the behavior:

Expected behavior

Actual behavior

Terminal Output Screenshot(s)

Additional context

bryantbiggs commented 3 months ago

we (typically) pull the argument description directly from upstream - this is the value that they currently have, but I have not checked if RDS has made changes that have relaxed/expanded support for this https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster#enable_http_endpoint

jritsema commented 3 months ago

It looks like the doc comment is incorrect and there's a PR in flight in the provider to resolve. It didn't appear to work but I will test again and update here. https://github.com/hashicorp/terraform-provider-aws/pull/35691

jritsema commented 3 months ago

I can verify that the doc in this project is incorrect.

Enable HTTP endpoint (data API). Only valid when engine_mode is set to serverless

Enabling HTTP endpoint (data API) does work when engine_mode is provisioned. It cannot be changed after creation which explains what I was seeing.

Here is the open issue in the provider for this. Looks like someone closed the associated PR that would change the description to the following:

Enable HTTP endpoint (data API). Only valid when `engine_mode` is set to `serverless` or when `engine` is set to `aurora-postgresql` and `engine_mode` is set to `provisioned`.

I can submit a PR in this repo, however, I understand if you want to wait and pull from upstream.

kzhou57 commented 2 months ago

We found a case that with engine is set to aurora-postgresql and engine_mode is set to provisioned, the terraform said the change is applied, but from AWS console , it still shows the Data API disabled.

Does anyone know what's going on here ? Is there a way to troubleshooting ?

rowen-anetac commented 2 months ago

We found a case that with engine is set to aurora-postgresql and engine_mode is set to provisioned, the terraform said the change is applied, but from AWS console , it still shows the Data API disabled.

Does anyone know what's going on here ? Is there a way to troubleshooting ?

Might want to double check you are in a supported region, that was my issue. This is only supported in 4 regions right now:

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Concepts.Aurora_Fea_Regions_DB-eng.Feature.Data_API.html#Concepts.Aurora_Fea_Regions_DB-eng.Feature.Data_API.apg

It will fail silently if executed in a region without support

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] commented 1 month ago

This issue was automatically closed because of stale in 10 days

github-actions[bot] commented 4 days ago

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.