Skip to content

Commit f74e5a4

Browse files
committed
Minor tweaks to starting modules for getting started demo
1 parent 504181d commit f74e5a4

File tree

6 files changed

+57
-121
lines changed

6 files changed

+57
-121
lines changed
Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,21 @@
1-
provider "aws" { }
2-
3-
data "aws_vpc" "default" {
4-
default = true
5-
}
6-
7-
data "aws_subnet_ids" "all" {
8-
vpc_id = "${data.aws_vpc.default.id}"
1+
provider "aws" {
2+
region = "${var.region}"
93
}
104

11-
data "aws_ami" "amazon_linux" {
12-
most_recent = true
13-
14-
filter {
15-
name = "name"
5+
resource "aws_vpc" "demo_vpc" {
6+
cidr_block = "${var.vpc_cidr_block}"
167

17-
values = [
18-
"amzn-ami-hvm-*-x86_64-gp2",
19-
]
8+
tags {
9+
Name = "fp_demo_vpc"
2010
}
21-
22-
filter {
23-
name = "owner-alias"
24-
25-
values = [
26-
"amazon",
27-
]
28-
}
29-
}
30-
31-
module "security_group" {
32-
source = "terraform-aws-modules/security-group/aws"
33-
34-
name = "${var.name}"
35-
description = "Security group for example usage with EC2 instance"
36-
vpc_id = "${data.aws_vpc.default.id}"
37-
38-
ingress_cidr_blocks = ["0.0.0.0/0"]
39-
ingress_rules = ["http-80-tcp", "all-icmp"]
40-
egress_rules = ["all-all"]
41-
42-
tags = "${var.tags}"
4311
}
4412

45-
resource "aws_eip" "this" {
46-
vpc = true
47-
instance = "${module.ec2.id[0]}"
48-
}
49-
50-
module "ec2" {
51-
source = "terraform-aws-modules/ec2-instance/aws"
13+
resource "aws_subnet" "demo_subnet" {
14+
vpc_id = "${aws_vpc.demo_vpc.id}"
15+
cidr_block = "${var.subnet_cidr_block}"
16+
availability_zone = "${var.subnet_availability_zone}"
5217

53-
name = "${var.name}"
54-
ami = "${data.aws_ami.amazon_linux.id}"
55-
instance_type = "${var.instance_type}"
56-
subnet_id = "${element(data.aws_subnet_ids.all.ids, 0)}"
57-
vpc_security_group_ids = ["${module.security_group.this_security_group_id}"]
58-
associate_public_ip_address = true
59-
60-
tags = "${var.tags}"
18+
tags {
19+
Name = "fp_demo_subnet"
20+
}
6121
}
Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
output "id" {
2-
description = "List of IDs of instances"
3-
value = ["${module.ec2.id}"]
1+
output "vpc_id_consumable" {
2+
value = "${aws_vpc.demo_vpc.id}"
3+
description = "This is the VPC ID for later use"
44
}
55

6-
output "public_dns" {
7-
description = "List of public DNS names assigned to the instances"
8-
value = ["${module.ec2.public_dns}"]
9-
}
10-
11-
output "instance_id" {
12-
description = "EC2 instance ID"
13-
value = "${module.ec2.id[0]}"
14-
}
15-
16-
output "instance_public_dns" {
17-
description = "Public DNS name assigned to the EC2 instance"
18-
value = "${module.ec2.public_dns[0]}"
6+
output "demo_subnet_id" {
7+
value = "${aws_subnet.demo_subnet.id}"
8+
description = "This is the Subnet ID for later use"
199
}

self-serve-infrastructure/getting-started/terraform-aws/variables.tf

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
module "network" {
2-
source = "Azure/network/azurerm"
3-
resource_group_name = "${var.name}"
4-
location = "${var.network_location}"
5-
address_space = "10.0.0.0/16"
6-
subnet_prefixes = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
7-
subnet_names = ["${var.name}-1", "${var.name}-2", "${var.name}-3"]
1+
provider "azurerm" {
2+
subscription_id = ""
3+
client_id = ""
4+
client_secret = ""
5+
tenant_id = ""
6+
}
87

9-
tags = "${merge(var.tags, map("Name", format("%s-%d", var.name, count.index+1)))}"
8+
resource "azurerm_resource_group" "demo_resource_group" {
9+
name = "${var.rg_name}"
10+
location = "${var.rg_location}"
1011
}
1112

12-
module "linuxservers" {
13-
source = "Azure/compute/azurerm"
14-
location = "${var.compute_location}"
15-
vm_os_simple = "UbuntuServer"
16-
public_ip_dns = ["${var.name}"] // change to a unique name per datacenter region
17-
vnet_subnet_id = "${module.network.vnet_subnets[0]}"
13+
resource "azurerm_virtual_network" "demo_virtual_network" {
14+
name = "${var.vn_name}"
15+
address_space = ["${var.vn_address_space}"]
16+
location = "${azurerm_resource_group.demo_resource_group.location}"
17+
resource_group_name = "${azurerm_resource_group.demo_resource_group.name}"
18+
}
1819

19-
tags = "${merge(var.tags, map("Name", format("%s-%d", var.name, count.index+1)))}"
20+
resource "azurerm_subnet" "demo_subnet" {
21+
name = "${var.sb_name}"
22+
resource_group_name = "${azurerm_resource_group.demo_virtual_network.name}"
23+
virtual_network_name = "${azurerm_virtual_network.demo_virtual_network.name}"
24+
address_prefix = "${var.sb_address_prefix}"
2025
}
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1-
output "linux_vm_public_name"{
2-
value = "${module.linuxservers.public_ip_dns_name}"
1+
output "resource_group_consumable" {
2+
value = "${azurerm_resource_group.demo_resource_group.name}"
3+
description = "The Demo VPC Name for later use"
4+
}
5+
6+
output "virtual_network_consumable_name" {
7+
value = "${azurerm_virtual_network.demo_virtual_network.name}"
8+
description = "The Demo Virtaul Network name for later use"
9+
}
10+
11+
output "virtual_network_consumable_address_space" {
12+
value = "${azurerm_virtual_network.demo_virtual_network.address_space}"
13+
description = "The Demo Virtaul Network address space for later use"
14+
}
15+
16+
output "subnet_consumable" {
17+
value = "${azurerm_subnet.demo_subnet.address_prefix}"
18+
description = "The Demo Subnet for later use"
319
}

self-serve-infrastructure/getting-started/terraform-azure/variables.tf

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)