From cf4d933702c1b635f065d9e81215c3e5657d1ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 25 Jul 2019 12:53:20 -0400 Subject: [PATCH] move dev environment to it's own tf module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- dns.tf | 10 ---------- main.tf | 10 ++++++++++ dev.tf => modules/dev/main.tf | 24 +++++++++++++++--------- modules/dev/outputs.tf | 10 ++++++++++ modules/dev/variables.tf | 15 +++++++++++++++ 5 files changed, 50 insertions(+), 19 deletions(-) rename dev.tf => modules/dev/main.tf (83%) create mode 100644 modules/dev/outputs.tf create mode 100644 modules/dev/variables.tf diff --git a/dns.tf b/dns.tf index 9e814ed..beb4322 100644 --- a/dns.tf +++ b/dns.tf @@ -37,13 +37,3 @@ resource "gandi_zonerecord" "dap_ps_site" { "185.199.111.153", ] } - -/* DEV SITE -------------------------------------*/ - -resource "gandi_zonerecord" "dev_dap_ps_site" { - zone = "${gandi_zone.dap_ps_zone.id}" - name = "dev" - type = "CNAME" - ttl = 3600 - values = ["${aws_elastic_beanstalk_environment.dev_dap_ps.cname}."] -} diff --git a/main.tf b/main.tf index 2b5a837..8b983d9 100644 --- a/main.tf +++ b/main.tf @@ -41,3 +41,13 @@ resource "aws_s3_bucket" "tf-state" { prevent_destroy = true } } + +/* ENVIRONMENTS ---------------------------------*/ + +module "dev" { + source = "./modules/dev" + name = "dev-dap-ps" + gandi_zone_id = "${gandi_zone.dap_ps_zone.id}" + dns_domain = "dap.ps" + dns_entry = "dev" +} diff --git a/dev.tf b/modules/dev/main.tf similarity index 83% rename from dev.tf rename to modules/dev/main.tf index 22e57d1..8297794 100644 --- a/dev.tf +++ b/modules/dev/main.tf @@ -1,15 +1,11 @@ -locals { - name = "dev-dap-ps" -} - /* ACCESS ---------------------------------------*/ resource "aws_iam_group" "deploy" { - name = "${local.name}-deploy" + name = "${var.name}-deploy" } resource "aws_iam_user" "deploy" { - name = "${local.name}-deploy" + name = "${var.name}-deploy" tags = { Description = "User for deploying the dap.ps Elastic Beanstalk app" } @@ -45,12 +41,12 @@ output "deploy_secret_key" { /* ROLES ----------------------------------------*/ resource "aws_iam_instance_profile" "main" { - name = "${local.name}" + name = "${var.name}" role = "${aws_iam_role.main.name}" } resource "aws_iam_role" "main" { - name = "${local.name}" + name = "${var.name}" assume_role_policy = <