forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch-templates.tf
More file actions
39 lines (32 loc) 路 866 Bytes
/
Copy pathlaunch-templates.tf
File metadata and controls
39 lines (32 loc) 路 866 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
variable "ami_id" {
description = "AMI ID for EC2 instances"
type = string
}
variable "instance_type" {
description = "EC2 instance type"
type = string
default = "t3.medium"
}
resource "aws_launch_template" "app" {
name_prefix = "${var.project_name}-${var.environment}-"
image_id = var.ami_id
instance_type = var.instance_type
vpc_security_group_ids = [aws_security_group.app.id]
iam_instance_profile {
name = aws_iam_instance_profile.app.name
}
monitoring {
enabled = true
}
tag_specifications {
resource_type = "instance"
tags = {
Environment = var.environment
Project = var.project_name
}
}
}
resource "aws_iam_instance_profile" "app" {
name = "${var.project_name}-${var.environment}-instance-profile"
role = "${var.project_name}-${var.environment}-ec2-role"
}