Skip to content

Instantly share code, notes, and snippets.

View guivin's full-sized avatar

Guillaume Vincent guivin

View GitHub Profile
@guivin
guivin / variables.tf
Created August 21, 2021 10:40
terraform/modules/aws-rds/variables.tf
variable "region" {
type = string
description = "(Required) AWS region to use"
}
variable "vpc_id" {
type = string
description = "(Required) The VPC ID where to deploy RDS instance"
}
@guivin
guivin / providers.tf
Created August 21, 2021 10:40
terraform/modules/aws-rds/providers.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.45.0"
}
random = {
source = "hashicorp/random"
version = "~> 3.1.0"
@guivin
guivin / outputs.tf
Created August 21, 2021 10:39
terraform/modules/aws-rds/outputs.tf
output "db_endpoint" {
description = "The database endpoint for connection"
value = aws_db_instance.default.endpoint
}
output "db_address" {
description = "The database address for connection"
value = aws_db_instance.default.address
}
@guivin
guivin / locals.tf
Created August 21, 2021 10:38
terraform/modules/aws-rds/locals.tf
locals {
name = "${var.tags["environment"]}-${var.tags["project"]}-rds"
}
@guivin
guivin / main.tf
Created August 21, 2021 10:37
terraform/modules/aws-rds/main.tf
resource "aws_security_group" "default" {
name = local.name
description = "Allow inbound access in port 3306 only"
vpc_id = var.vpc_id
ingress {
protocol = "tcp"
from_port = var.db_port
to_port = var.db_port
security_groups = var.allowed_security_groups
@guivin
guivin / outputs.tf
Created August 21, 2021 10:35
terraform/modules/aws-vpc/outputs.tf
output "vpc_id" {
description = "The default VPC ID"
value = aws_default_vpc.default.id
}
output "subnet_id" {
description = "The default subnet ID"
value = aws_default_subnet.default.id
}
@guivin
guivin / providers.tf
Created August 21, 2021 10:35
terraform/modules/aws-vpc/providers.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.45.0"
}
}
}
provider "aws" {
@guivin
guivin / locals.tf
Created August 21, 2021 10:34
terraform/modules/aws-vpc/locals.tf
locals {
name = "${var.tags["environment"]}-${var.tags["project"]}"
}
@guivin
guivin / variables.tf
Created August 21, 2021 10:33
terraform/modules/aws-vpc/variables.tf
variable "region" {
type = string
description = "(Required) AWS region"
}
variable "tags" {
type = map(string)
description = "(Required) Tags for resources"
}
@guivin
guivin / main.tf
Created August 21, 2021 10:33
terraform/modules/aws-vpc/main.tf
resource "aws_default_vpc" "default" {
tags = merge({
name = local.name
}, var.tags)
}
resource "aws_default_subnet" "default" {
availability_zone = var.availability_zone
tags = merge({
name = local.name