-
Notifications
You must be signed in to change notification settings - Fork 17
feat: dns records and zones inclusion #910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
ecb9f18
feat: dns records and zones inclusion
imprateeksh 9ccda69
fix: modified changes around the resource used
imprateeksh 81b6093
test: tmp reverted changes
imprateeksh 293f0cf
test: tmp reverted changes
imprateeksh 309aa6e
test: dns changes added back
imprateeksh b69a5d3
test: added permitted nw
imprateeksh a6f3061
test: added permitted nw
imprateeksh 7dc7386
test: modified zone-id
imprateeksh 6a9e2bb
Merge branch 'main' into 11726-dns-records
imprateeksh 9c12aa2
fix: modified changes around DNS to include the correct rdata type
imprateeksh 47c45a2
fix: modified changes around DNS to include the correct rdata type
imprateeksh 30ca03b
fix: made changes for dns records
imprateeksh fd302e5
test\: added test for dns records
imprateeksh 2d1c058
test: added test for dns records
imprateeksh e28517a
fix: precommit errors
imprateeksh 7048db6
fix: precommit errors
imprateeksh b13cb7d
fix: pre-commit error
imprateeksh 5357581
Merge branch 'main' into 11726-dns-records
rajatagarwal-ibm 064c82c
Merge branch 'main' into 11726-dns-records
imprateeksh f7c6c9b
fix: resolved review comments
imprateeksh 2a12cb9
Merge branch '11726-dns-records' of github.com:terraform-ibm-modules/…
imprateeksh fb7bc50
fix: resolved review comments
imprateeksh 0efb038
Merge branch 'main' into 11726-dns-records
imprateeksh 921b887
fix: addressed review changes
imprateeksh ada5563
refactor: moved test to pr_test
imprateeksh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| # VPC with DNS example | ||
|
|
||
| A simple example demonstrating the provisioning of a `Secure Landing Zone (SLZ) Virtual Private Cloud (VPC)` across two zones (`Zone 1` and `Zone 2`). This setup includes the creation of `Domain Name System (DNS) Zones and Records`, linking the provisioned VPC as a permitted network for DNS operations. | ||
|
|
||
| The following resources are provisioned by this example: | ||
|
|
||
| * A new `resource group`, if an existing one is not passed in. | ||
|
|
||
| * An IBM `Virtual Private Cloud (VPC)` with a publicly exposed subnet. | ||
|
|
||
| * Private `DNS zone` which can only be resolved from IBM Cloud's private network. | ||
|
|
||
| * `DNS permitted network` - [DNS Service](https://cloud.ibm.com/docs/dns-svcs/getting-started.html) is a global service, hence the permitted networks (for example, a `VPC`) should be added from any IBM Cloud region. This adds the network to the DNS zone, giving the network access to the zone. Maximum of 10 permitted networks can be added to a `DNS zone`. [Learn more](https://cloud.ibm.com/docs/dns-svcs?topic=dns-svcs-managing-permitted-networks&interface=ui) | ||
|
|
||
| * `DNS Records` - `DNS Records` make the connection between human-readable names and IP addresses. | ||
|
|
||
| > Note: To create a `PTR` type record, you must have an existing `A` or `AAAA` record that is not already associated with another `PTR` record. [Learn More](https://cloud.ibm.com/docs/dns-svcs?topic=dns-svcs-managing-dns-records&interface=ui#ptr-record) |
This file contains hidden or 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,52 @@ | ||
| ############################################################################## | ||
| # Resource Group | ||
| ############################################################################## | ||
|
|
||
| module "resource_group" { | ||
| source = "terraform-ibm-modules/resource-group/ibm" | ||
| version = "1.1.6" | ||
| # if an existing resource group is not set (null) create a new one using prefix | ||
| resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null | ||
| existing_resource_group_name = var.resource_group | ||
| } | ||
|
|
||
| ############################################################################# | ||
| # Locals | ||
| ############################################################################# | ||
| locals { | ||
| subnets = { | ||
| zone-1 = [ | ||
| { | ||
| name = "subnet-a" | ||
| cidr = "10.10.10.0/24" | ||
| public_gateway = true | ||
| acl_name = "vpc-acl" | ||
| } | ||
| ], | ||
| zone-2 = [ | ||
| { | ||
| name = "subnet-b" | ||
| cidr = "10.20.10.0/24" | ||
| public_gateway = false | ||
| acl_name = "vpc-acl" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| ############################################################################# | ||
| # Provision VPC | ||
| ############################################################################# | ||
|
|
||
| module "slz_vpc" { | ||
| source = "../../" | ||
| resource_group_id = module.resource_group.resource_group_id | ||
| region = var.region | ||
| name = var.name | ||
| prefix = var.prefix | ||
| tags = var.resource_tags | ||
| enable_hub = true | ||
| dns_zone_name = var.dns_zone_name | ||
| dns_records = var.dns_records | ||
| subnets = local.subnets | ||
| } |
This file contains hidden or 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,47 @@ | ||
| ############################################################################## | ||
| # Outputs | ||
| ############################################################################## | ||
|
|
||
| output "vpc_id" { | ||
| value = module.slz_vpc.vpc_id | ||
| description = "VPC id" | ||
| } | ||
|
|
||
| output "vpc_crn" { | ||
| value = module.slz_vpc.vpc_crn | ||
| description = "VPC crn" | ||
| } | ||
|
|
||
| output "network_acls" { | ||
| value = module.slz_vpc.network_acls | ||
| description = "VPC network ACLs" | ||
| } | ||
|
|
||
| output "public_gateways" { | ||
| value = module.slz_vpc.public_gateways | ||
| description = "VPC public gateways" | ||
| } | ||
|
|
||
| output "subnet_zone_list" { | ||
| value = module.slz_vpc.subnet_zone_list | ||
| description = "VPC subnet zone list" | ||
| } | ||
|
|
||
| output "subnet_detail_map" { | ||
| value = module.slz_vpc.subnet_detail_map | ||
| description = "VPC subnet detail map" | ||
| } | ||
|
|
||
| output "dns_zone_state" { | ||
| description = "The state of the DNS zone." | ||
| value = module.slz_vpc.dns_zone_state | ||
| } | ||
|
|
||
| output "dns_zone_id" { | ||
| description = "The ID of the DNS zone." | ||
| value = module.slz_vpc.dns_zone_id | ||
| } | ||
| output "dns_record_ids" { | ||
| description = "List of all the domain resource records." | ||
| value = module.slz_vpc.dns_record_ids | ||
| } | ||
This file contains hidden or 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,4 @@ | ||
| provider "ibm" { | ||
| ibmcloud_api_key = var.ibmcloud_api_key | ||
| region = var.region | ||
| } |
This file contains hidden or 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,87 @@ | ||
| variable "ibmcloud_api_key" { | ||
| description = "APIkey that's associated with the account to provision resources." | ||
| type = string | ||
| sensitive = true | ||
| } | ||
|
|
||
| variable "region" { | ||
| description = "The region to which to deploy the VPC" | ||
| type = string | ||
| default = "us-south" | ||
| } | ||
|
|
||
| variable "prefix" { | ||
| description = "The prefix that you would like to append to your resources" | ||
| type = string | ||
| default = "dns" | ||
| } | ||
|
|
||
| variable "name" { | ||
| description = "The name of the vpc" | ||
| type = string | ||
| default = "slz-vpc" | ||
| } | ||
|
|
||
| variable "resource_group" { | ||
| type = string | ||
| description = "An existing resource group name to use for this example, if unset a new resource group will be created" | ||
| default = null | ||
| } | ||
|
|
||
| variable "resource_tags" { | ||
| description = "List of Tags for the resource created" | ||
| type = list(string) | ||
| default = null | ||
| } | ||
|
|
||
| variable "dns_records" { | ||
imprateeksh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| description = "List of DNS records to create" | ||
| type = list(object({ | ||
| name = string | ||
| type = string | ||
| rdata = string | ||
| ttl = optional(number) | ||
| preference = optional(number) | ||
| priority = optional(number) | ||
| port = optional(number) | ||
| protocol = optional(string) | ||
| service = optional(string) | ||
| weight = optional(number) | ||
| })) | ||
| default = [ | ||
| { | ||
| name = "testA" | ||
| type = "A" | ||
| rdata = "1.2.3.4" | ||
| ttl = 3600 | ||
| }, | ||
| { | ||
| name = "testMX" | ||
| type = "MX" | ||
| rdata = "mailserver.test.com" | ||
| preference = 10 | ||
| }, | ||
| { | ||
| type = "SRV" | ||
| name = "testSRV" | ||
| rdata = "tester.com" | ||
| priority = 100 | ||
| weight = 100 | ||
| port = 8000 | ||
| service = "_sip" | ||
| protocol = "udp" | ||
| }, | ||
| { | ||
| name = "testTXT" | ||
| type = "TXT" | ||
| rdata = "textinformation" | ||
| ttl = 900 | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| variable "dns_zone_name" { | ||
imprateeksh marked this conversation as resolved.
Show resolved
Hide resolved
imprateeksh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| description = "The name of the DNS zone to be created." | ||
| type = string | ||
| default = "dns-example.com" | ||
| } | ||
This file contains hidden or 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,10 @@ | ||
| terraform { | ||
| required_version = ">= 1.3.0" | ||
| required_providers { | ||
| # Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works | ||
| ibm = { | ||
| source = "IBM-Cloud/ibm" | ||
| version = "1.59.0" | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.