-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
68 lines (57 loc) · 1.72 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
terraform {
required_version = ">= 0.12.23"
}
provider "vault" {
address = var.vault_addr
skip_tls_verify = var.vault_skip_tls_verify
#token = var.vault_token
auth_login {
path = var.vault_auth_path
parameters = {
role_id = var.vault_role_id
secret_id = var.vault_secret_id
}
}
}
data "vault_aws_access_credentials" "creds" {
backend = var.vault_aws_backend
role = var.vault_aws_role
}
provider "aws" {
region = var.aws_region
access_key = data.vault_aws_access_credentials.creds.access_key
secret_key = data.vault_aws_access_credentials.creds.secret_key
}
################################################################################
# let's find the latest Ubuntu 18.04 image
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = [var.ubuntu_os_filter]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
################################################################################
# let's provision an ec2 instance
resource "aws_instance" "demo" {
#ami = data.aws_ami.hashistack.id
ami = data.aws_ami.ubuntu.id
instance_type = var.instance_type
availability_zone = "${var.aws_region}a"
key_name = var.ssh_key_name
root_block_device {
volume_type = var.volume_type
encrypted = var.root_volume_encrypted
volume_size = var.root_volume_size
#kms_key_id = var.aws_kms_key_id
}
tags = {
Name = var.name
Owner = var.owner
}
}