1
votes

I am attempting to run this module: https://registry.terraform.io/modules/azavea/postgresql-rds/aws/latest Here is the main.tf file created based on the information found there:

provider "aws" {
  region = "us-east-2"
  access_key = "key_here"
  secret_key = "key_here"
}
module postgresql_rds {
  source = "github.com/azavea/terraform-aws-postgresql-rds"
  vpc_id = "vpc-2470994d"
  instance_type = "db.t3.micro"
  database_name = "tyler"
  database_username = "admin"
  database_password = "admin1234"
  subnet_group = "tyler-subnet-1"
  project = "Postgres-ts"
  environment = "Staging"
  alarm_actions = ["arn:aws:sns:us-east-2:304831784377:tyler-test"]
  ok_actions = ["arn:aws:sns:us-east-2:304831784377:tyler-test"]
  insufficient_data_actions = ["arn:aws:sns:us-east-2:304831784377:tyler-test"]
  database_identifier = "jl23kj32sdf"

}

I am getting an error:

Error: Error creating DB Instance: DBSubnetGroupNotFoundFault: DBSubnetGroup 'tyler-subnet-1' not found. │ status code: 404, request id: a95975dd-5456-444a-8f64-440fc4c1782f │ │ with module.postgresql_rds.aws_db_instance.postgresql, │ on .terraform/modules/postgresql_rds/main.tf line 46, in resource "aws_db_instance" "postgresql": │ 46: resource "aws_db_instance" "postgresql" {

I have tried the example from the page:

subnet_group = aws_db_subnet_group.default.name

I used the default example from the page, under "Usage" ie subnet_group = aws_db_subnet_group.default.name. I have also used the subnet ID from AWS. I also assigned a name to the subnet, and used the name "tyler-subnet-1 in the above main.tf). I am getting the same basic error, with all three attempted inputs. Is there something I'm not understanding about the information that is being requested here?

1
Where aws_db_subnet_group.default.name comes from? Its not shown in your program.Marcin
@Marcin On this page: registry.terraform.io/modules/azavea/postgresql-rds/aws/latest It's the default value from the example under "Usage". I was trying anything to see what might work.Flipscuba

1 Answers

1
votes

Assuming you have a default subnet group, you can just use it:

 subnet_group = "default"

If not you have to create a custom subnet group using aws_db_subnet_group:

resource "aws_db_subnet_group" "default" {
  name       = "my-subnet-group"
  subnet_ids = [<subnet-id-1>, <subnet-id-2>]

  tags = {
    Name = "My DB subnet group"
  }
}

and use the custom group:

 subnet_group = aws_db_subnet_group.default.name