-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
45 lines (37 loc) · 842 Bytes
/
main.tf
File metadata and controls
45 lines (37 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.27"
}
}
required_version = ">= 0.14.9"
}
provider "aws" {
profile = "default"
region = "eu-central-1"
}
resource "aws_instance" "app_server" {
ami = var.ami_id
key_name = var.key_name
instance_type = var.app_instance_type
vpc_security_group_ids = [aws_security_group.cache_server.id]
tags = local.common_tags
}
resource "aws_security_group" "cache_server" {
name_prefix = "cache"
}
resource "aws_eip" "eip" {
instance = aws_instance.app_server.id
vpc = true
count = var.eip_attach ? 1 : 0
}
module "ec2_key_pair" {
source = "terraform-aws-modules/key-pair/aws"
tags = local.common_tags
key_name = var.key_name
public_key = var.public_key
}
locals {
common_tags = var.app_instance_tags
}