Skip to content

Commit 67c4738

Browse files
committed
refa: renamed VPC ID variable
1 parent d34d815 commit 67c4738

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This module provides a PostgreSQL RDS instance, an optional RDS proxy and a Secr
2929
| instance_class | The instance class of the RDS instance. Must be one of the [supported RDS instance classes](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html). | `string` | "db.t3.micro" | no |
3030
| engine_version | The PostgreSQL engine version for the RDS instance. Must be one of the [supported RDS postgres engine versions](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts.General.FeatureSupport.Extensions). | `string` | "16.1" | no |
3131
| allocated_storage | Storage capacity of the RDS instance in GigiBytes. | `number` | 20 | no |
32-
| vpc_id | ID of the subnets' VPC. | `string` | n/a | yes |
32+
| vpc | ID of the subnets' VPC. | `string` | n/a | yes |
3333
| subnets | A list of IDs of subnets for the subnet group and potentially the RDS proxy. | `list(string)` | n/a | yes |
3434
| skip_final_snapshot | A flag for wether or not skipping the creation of a final snapshot befor deletion of the RDS instance. | `bool` | true | no |
3535
| db_name | Name of the database initially created in the RDS instance. | `string` | "postgres" | no |
@@ -65,7 +65,7 @@ module "database" {
6565
instance_class = "db.t3.micro"
6666
engine_version = "16.1"
6767
allocated_storage = 20
68-
vpc_id = "vpc-01234567890abcdef"
68+
vpc = "vpc-01234567890abcdef"
6969
subnets = ["subnet-1242421", "subnet-2344898"]
7070
skip_final_snapshot = true
7171
db_name = "postgres"

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ resource "aws_security_group" "proxy" {
2020
count = var.proxy != null ? 1 : 0
2121
name = "${var.identifier}-rds-proxy"
2222
description = "Allows RDS proxy to access the RDS instance and other services to access the RDS proxy"
23-
vpc_id = var.vpc_id
23+
vpc_id = var.vpc
2424

2525
tags = var.tags
2626
}
2727

2828
resource "aws_security_group" "rds" {
2929
name = "${var.identifier}-rds"
3030
description = var.proxy != null ? "Allows RDS instance to be accessed by RDS proxy" : "Allows RDS instance to be accessed by services"
31-
vpc_id = var.vpc_id
31+
vpc_id = var.vpc
3232

3333
tags = var.tags
3434
}
3535

3636
resource "aws_security_group" "external" {
3737
name = "${var.identifier}-external"
3838
description = var.proxy != null ? "Allows services to access the RDS proxy" : "Allows services to access the RDS instance"
39-
vpc_id = var.vpc_id
39+
vpc_id = var.vpc
4040

4141
tags = var.tags
4242
}

tests/proxy.tftest.hcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ run "valid_proxy" {
1212

1313
variables {
1414
identifier = "test"
15-
vpc_id = "vpc-01234567890abcdef"
15+
vpc = "vpc-01234567890abcdef"
1616
subnets = ["subnet-1242421", "subnet-2344898"]
1717

1818
proxy = {
@@ -75,7 +75,7 @@ run "no_proxy" {
7575

7676
variables {
7777
identifier = "test"
78-
vpc_id = "vpc-01234567890abcdef"
78+
vpc = "vpc-01234567890abcdef"
7979
subnets = ["subnet-1242421", "subnet-2344898"]
8080

8181
proxy = null

tests/rds.tftest.hcl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ run "invalid_vpc_id" {
1212

1313
variables {
1414
identifier = "test"
15-
vpc_id = "abc-01234567890abcdef"
15+
vpc = "abc-01234567890abcdef"
1616
subnets = ["subnet-1242421", "subnet-2344898"]
1717
}
1818

19-
expect_failures = [var.vpc_id]
19+
expect_failures = [var.vpc]
2020
}
2121

2222
run "invalid_subnets_length" {
2323
command = plan
2424

2525
variables {
2626
identifier = "test"
27-
vpc_id = "vpc-01234567890abcdef"
27+
vpc = "vpc-01234567890abcdef"
2828
subnets = ["subnet-2344898"]
2929
}
3030

@@ -36,7 +36,7 @@ run "invalid_subnets" {
3636

3737
variables {
3838
identifier = "test"
39-
vpc_id = "vpc-01234567890abcdef"
39+
vpc = "vpc-01234567890abcdef"
4040
subnets = ["subnet-2344898", "foobar-2344898"]
4141
}
4242

@@ -48,7 +48,7 @@ run "invalid_db_name" {
4848

4949
variables {
5050
identifier = "test"
51-
vpc_id = "vpc-01234567890abcdef"
51+
vpc = "vpc-01234567890abcdef"
5252
subnets = ["subnet-2344898", "subnet-2344898"]
5353
db_name = "ab"
5454
}
@@ -61,7 +61,7 @@ run "invalid_db_username" {
6161

6262
variables {
6363
identifier = "test"
64-
vpc_id = "vpc-01234567890abcdef"
64+
vpc = "vpc-01234567890abcdef"
6565
subnets = ["subnet-2344898", "subnet-2344898"]
6666
db_username = "ab"
6767
}
@@ -74,7 +74,7 @@ run "invalid_db_password" {
7474

7575
variables {
7676
identifier = "test"
77-
vpc_id = "vpc-01234567890abcdef"
77+
vpc = "vpc-01234567890abcdef"
7878
subnets = ["subnet-2344898", "subnet-2344898"]
7979
db_password = "passwor"
8080
}

variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ variable "allocated_storage" {
2121
default = 20
2222
}
2323

24-
variable "vpc_id" {
24+
variable "vpc" {
2525
description = "ID of the subnets' VPC."
2626
type = string
2727
validation {
28-
condition = startswith(var.vpc_id, "vpc-")
28+
condition = startswith(var.vpc, "vpc-")
2929
error_message = "Must be valid VPC ID"
3030
}
3131
}

0 commit comments

Comments
 (0)