Skip to content

Commit

Permalink
Merge pull request #155 from grebois/fix/postgres
Browse files Browse the repository at this point in the history
Making postgres work without using remote state
  • Loading branch information
grebois authored Aug 9, 2021
2 parents 6a4c12b + 33b28fe commit b05a4ec
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 3 additions & 1 deletion terraform-modules/aws/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ No resources.
| <a name="input_name"></a> [name](#input\_name) | The DB name to create. If omitted, no database is created initially | `string` | `null` | no |
| <a name="input_parameters"></a> [parameters](#input\_parameters) | A list of DB parameters (map) to apply | `list(map(string))` | <pre>[<br> {<br> "name": "autovacuum",<br> "value": 1<br> },<br> {<br> "name": "client_encoding",<br> "value": "utf8"<br> }<br>]</pre> | no |
| <a name="input_password"></a> [password](#input\_password) | Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file | `string` | `null` | no |
| <a name="input_private_subnets"></a> [private\_subnets](#input\_private\_subnets) | A list of private subnets | `list(any)` | n/a | yes |
| <a name="input_storage_encrypted"></a> [storage\_encrypted](#input\_storage\_encrypted) | Specifies whether the DB instance is encrypted | `bool` | `true` | no |
| <a name="input_storage_type"></a> [storage\_type](#input\_storage\_type) | One of 'standard' (magnetic), 'gp2' (general purpose SSD), or 'io1' (provisioned IOPS SSD). The default is 'io1' if iops is specified, 'gp2' if not. | `string` | `"gp2"` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | n/a | `map(any)` | <pre>{<br> "ops_env": "staging",<br> "ops_managed_by": "terraform",<br> "ops_owners": "devops",<br> "ops_source_repo": "kubernetes-ops",<br> "ops_source_repo_path": "terraform-module/aws/postgres"<br>}</pre> | no |
| <a name="input_username"></a> [username](#input\_username) | Username for the master DB user | `string` | `null` | no |
| <a name="input_vpc"></a> [vpc](#input\_vpc) | VPC where the rds and security group will be created | `any` | n/a | yes |
| <a name="input_vpc_cidr_block"></a> [vpc\_cidr\_block](#input\_vpc\_cidr\_block) | The CIDR block of the VPC | `any` | n/a | yes |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The ID of the VPC | `any` | n/a | yes |

## Outputs

Expand Down
6 changes: 3 additions & 3 deletions terraform-modules/aws/postgres/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module "security_group" {

name = "${var.identifier}-${var.name}"
description = "PostgreSQL security group"
vpc_id = var.vpc.outputs.vpc_id
vpc_id = var.vpc_id

# ingress
ingress_with_cidr_blocks = [
Expand All @@ -14,7 +14,7 @@ module "security_group" {
protocol = "tcp"

description = "PostgreSQL access from within VPC"
cidr_blocks = var.vpc.outputs.vpc_cidr_block
cidr_blocks = var.vpc_cidr_block
},
]

Expand Down Expand Up @@ -47,7 +47,7 @@ module "db" {
port = 5432

multi_az = true
subnet_ids = var.vpc.outputs.private_subnets
subnet_ids = var.private_subnets
vpc_security_group_ids = [module.security_group.security_group_id]

maintenance_window = var.maintenance_window
Expand Down
14 changes: 12 additions & 2 deletions terraform-modules/aws/postgres/variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
variable "vpc" {
description = "VPC where the rds and security group will be created"
variable "vpc_id" {
description = "The ID of the VPC"
}

variable "vpc_cidr_block" {
description = "The CIDR block of the VPC"
}

variable "private_subnets" {
description = "A list of private subnets"
type = list(any)
}

variable "identifier" {
description = "The name of the RDS instance, if omitted, Terraform will assign a random, unique identifier"
type = string
Expand Down
4 changes: 2 additions & 2 deletions terraform-modules/aws/vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ module "vpc" {

public_subnet_tags = {
"kubernetes.io/cluster/${var.cluster_name}" = "shared"
"kubernetes.io/role/elb" = "1"
"kubernetes.io/role/elb" = "1"
}

private_subnet_tags = {
"kubernetes.io/cluster/${var.cluster_name}" = "shared"
"kubernetes.io/role/internal-elb" = "1"
"kubernetes.io/role/internal-elb" = "1"
}

tags = var.tags
Expand Down

0 comments on commit b05a4ec

Please sign in to comment.