From 25b53a455ae4ac5528c81e74c1160a45bedf3936 Mon Sep 17 00:00:00 2001 From: Caio Fernandes Date: Sun, 25 Jun 2023 18:54:45 -0300 Subject: [PATCH] Add terraform infrastructure example --- infra/.env.template | 9 +++++ infra/.gitignore | 2 ++ infra/Makefile | 0 infra/main.tf | 86 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 infra/.env.template create mode 100644 infra/.gitignore create mode 100644 infra/Makefile create mode 100644 infra/main.tf diff --git a/infra/.env.template b/infra/.env.template new file mode 100644 index 0000000..9d574d7 --- /dev/null +++ b/infra/.env.template @@ -0,0 +1,9 @@ +WORKSPACE +AWS_ROLE +AWS_ACCOUNT_ID +AWS_DEFAULT_REGION +AWS_PROFILE +AWS_DEFAULT_PROFILE +AWS_ACCESS_KEY_ID +AWS_SECRET_ACCESS_KEY +AWS_SESSION_TOKEN \ No newline at end of file diff --git a/infra/.gitignore b/infra/.gitignore new file mode 100644 index 0000000..22128ee --- /dev/null +++ b/infra/.gitignore @@ -0,0 +1,2 @@ +.terraform + diff --git a/infra/Makefile b/infra/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/infra/main.tf b/infra/main.tf new file mode 100644 index 0000000..848e2ba --- /dev/null +++ b/infra/main.tf @@ -0,0 +1,86 @@ +terraform { + backend "s3" { + bucket = "testing-terraform-dnx" + key = "platform" + region = "us-east-1" + encrypt = true + } +} + +provider "aws" { + region = "us-east-1" + + default_tags { + tags = { + Environment = "dev" + } + } +} + + +module "eb_windows" { + source = "git::https://github.com/DNXLabs/terraform-aws-eb-windows.git?ref=2.7.2" + name = "testingApplication" + security_group_name = "testing_eb_app_sg" + eb_platform = "dotnet" + eb_solution_stack_name = "64bit Windows Server 2019 v2.11.4 running IIS 10.0" + environment = "dev" + environment_type = "LoadBalanced" + loadbalancer_type = "application" + application_subnets = data.aws_subnets.public.ids + loadbalancer_subnets = data.aws_subnets.public.ids + loadbalancer_idle_timeout = 60 + elb_scheme = "public" + instance_type = "t3a.small" + vpc_id = data.aws_vpc.selected.id + create_security_group = false + application_port = 80 + http_listener_enabled = true + ingress_rules = [] + enable_stream_logs = true + healthcheck_url = "/" + healthcheck_httpcodes_to_match = ["200"] + deployment_timeout = 600 + eb_wait_for_ready_timeout = "10m" + asg_min = 1 + asg_max = 1 + rolling_update_enabled = false + rolling_update_type = "Time" + updating_min_in_service = 0 + associate_public_ip_address = true + root_volume_size = 30 + iam_role_policy_attachment_to_instance = [ + { + "name" : "SecretsManagerReadWrite", + "policy_arn" : "arn:aws:iam::aws:policy/SecretsManagerReadWrite" + }, + { + "name" : "AWSXRayDaemonWriteAccess", + "policy_arn" : "arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess" + }, + { + "name" : "AmazonS3ReadOnlyAccess", + "policy_arn" : "arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess" + }, + ] +} + +data "aws_subnets" "public" { + + filter { + name = "vpc-id" + values = [data.aws_vpc.selected.id] + } + + filter { + name = "tag:Scheme" + values = ["public"] + } +} + +data "aws_vpc" "selected" { + filter { + name = "tag:Name" + values = ["dev-VPC"] + } +}