-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added data source Labs for AWS and Azure
- Loading branch information
1 parent
75ecada
commit af569fa
Showing
5 changed files
with
104 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
provider "aws" { | ||
region = "us-east-1" | ||
# access_key = "my-access-key" | ||
# secret_key = "my-secret-key" | ||
} | ||
|
||
resource "aws_vpc" "vpc_network" { | ||
cidr_block = "10.10.0.0/16" | ||
|
||
tags = { | ||
Name = "my-tf-vpc-network" | ||
} | ||
} | ||
|
||
output "vpc_id" { | ||
value = aws_vpc.vpc_network.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
provider "aws" { | ||
region = "us-east-1" | ||
# access_key = "my-access-key" | ||
# secret_key = "my-secret-key" | ||
} | ||
|
||
################## | ||
# Reference Remote state file to get output values | ||
|
||
data "aws_vpc" "vpc" { | ||
#id = "${var.vpc_id}" | ||
filter { | ||
name = "tag-key" | ||
values = ["Name"] | ||
} | ||
filter { | ||
name = "tag-value" | ||
values = ["my-tf-vpc-network"] | ||
} | ||
} | ||
|
||
resource "aws_subnet" "subnet1" { | ||
cidr_block = "10.10.1.0/24" | ||
|
||
tags = { | ||
Name = "my-tf-vpc-subnet1" | ||
} | ||
|
||
# Refer to vpc ID | ||
vpc_id = data.aws_vpc.vpc.id | ||
} | ||
|
||
########################### | ||
|
||
|
||
## Following example shows how to use terraform cidrsubnet function | ||
## cidrsubnet(prefix, newbits, netnum) | ||
## newbits is the number of additional bits with which to extend the prefix. For example, if given a prefix ending in /16 and a newbits value of 8, the resulting subnet address will have length /24 | ||
## netnum is a whole number that can be represented as a binary integer with no more than newbits binary digits, which will be used to populate the additional bits added to the prefix | ||
|
||
|
||
# resource "aws_subnet" "subnet2" { | ||
# cidr_block = cidrsubnet(data.aws_vpc.vpc.cidr_block, 8, 10) | ||
|
||
# tags = { | ||
# Name = "my-tf-vpc-subnet2" | ||
# } | ||
|
||
# # Refer to vpc ID | ||
# vpc_id = data.aws_vpc.vpc.id | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
provider "azurerm" { | ||
# subscription_id = "your_subscription_id" | ||
# client_id = "your_appId" | ||
# client_secret = "your_password" | ||
# tenant_id = "your_tenant_id" | ||
features {} | ||
} | ||
|
||
resource "azurerm_resource_group" "rg" { | ||
name = "my-tf-rg" | ||
location = "southcentralus" | ||
} | ||
|
||
output rg_name { | ||
value = azurerm_resource_group.rg.name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
provider "azurerm" { | ||
# subscription_id = "your_subscription_id" | ||
# client_id = "your_appId" | ||
# client_secret = "your_password" | ||
# tenant_id = "your_tenant_id" | ||
features {} | ||
} | ||
|
||
data "azurerm_resource_group" "rg" { | ||
name = "my-tf-rg" | ||
} | ||
|
||
resource "azurerm_virtual_network" "vnet" { | ||
location = data.azurerm_resource_group.rg.location | ||
resource_group_name = data.azurerm_resource_group.rg.name | ||
|
||
name = "my-tf-vnet-network" | ||
address_space = ["10.10.0.0/16"] | ||
|
||
} |