forked from kanchai123/demo-ghas-terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
65 lines (54 loc) · 1.45 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
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.27"
}
github = {
source = "integrations/github"
version = "4.10"
}
}
required_version = ">= 0.15"
}
variable "ec2_region" {
type = string
description = "The region where we want to deploy"
validation {
condition = can(regex("(us(-gov)?|ap|ca|cn|eu|sa)-(central|(north|south)?(east|west)?)-\\d", var.ec2_region))
error_message = "The image_id value must be a valid AMI id, starting with \"ami-\"."
}
}
provider "aws" {
profile = "default"
region = var.ec2_region
}
data "aws_ami" "latest-ubuntu" {
most_recent = true
owners = ["099720109477"] # Canonical
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
}
resource "aws_instance" "app_server" {
ami = "${data.aws_ami.latest-ubuntu.id}"
instance_type = "t2.nano"
tags = {
Name = "ExampleAppServerInstance"
Owner = "helaili"
Terminate = "2021-06-01"
}
}
module "local_child" {
source = "./modules"
latest-ubuntu-id = "${data.aws_ami.latest-ubuntu.id}"
}
module "remote_child" {
source = "git::https://github.com/octodemo/OctoTerraform-Module.git//modules?ref=main"
latest-ubuntu-id = "${data.aws_ami.latest-ubuntu.id}"
}