-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
94 lines (76 loc) · 1.54 KB
/
main.tf
File metadata and controls
94 lines (76 loc) · 1.54 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
docker = {
source = "kreuzwerker/docker"
}
}
}
provider "aws" {
profile = "default"
region = "us-east-1"
shared_credentials_file = "credentials"
}
provider "docker" {
}
// AWS Resources
resource "aws_s3_bucket" "tf_course" {
bucket = "tf-course-20210207"
acl = "private"
}
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
resource "aws_instance" "web" {
ami = data.aws_ami.ubuntu.id
instance_type = "t2.micro"
provisioner "local-exec" {
command = "echo ${aws_instance.web.public_ip} >> private_ips.txt"
}
tags = {
Name = "DevOps_Cohort_2020"
}
}
/*
resource "aws_eip" "ip" {
vpc = true
instance = aws_instance.web.id
}
*/
// Docker Resources
resource "docker_image" "nginx" {
name = "nginx:latest"
keep_locally = false
}
resource "docker_container" "nginx" {
image = docker_image.nginx.latest
name = "tutorial"
ports {
internal = 90
external = 9000
}
}
// Docker Resources
resource "docker_image" "flask" {
name = "habboubi/flaskapp:latest"
keep_locally = false
}
resource "docker_container" "flask" {
image = docker_image.flask.latest
name = "flaskapp"
ports {
internal = 80
external = 80
}
}