-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.tf
49 lines (40 loc) · 1.29 KB
/
main.tf
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
45
46
47
48
resource "aws_key_pair" "terraform_best_practices_demo" {
key_name = "${terraform.workspace}-terraform-best-practices-demo-key"
public_key = file("/home/ubuntu/.ssh/id_rsa.pub")
}
resource "aws_instance" "instance_1" {
ami = var.instance_1_ami
instance_type = var.instance_1_type
tags = {
Name = "${terraform.workspace}-${var.instance_1_name}"
}
key_name = aws_key_pair.terraform_best_practices_demo.key_name
}
resource "aws_instance" "instance_2" {
ami = var.instance_2_ami
instance_type = var.instance_2_type
tags = {
Name = "${terraform.workspace}-${var.instance_2_name}"
}
provisioner "local-exec" {
command = "echo The IP address of the Server is ${self.private_ip}"
on_failure = continue
}
key_name = aws_key_pair.terraform_best_practices_demo.key_name
}
module "website_s3_bucket_1" {
source = "./modules/aws-s3-static-website-bucket"
bucket_name = "${terraform.workspace}-${var.website_s3_bucket_1_name}"
tags = {
Terraform = var.terraform
Environment = var.environment
}
}
module "website_s3_bucket_2" {
source = "./modules/aws-s3-static-website-bucket"
bucket_name = "${terraform.workspace}-${var.website_s3_bucket_2_name}"
tags = {
Terraform = var.terraform
Environment = var.environment
}
}