-
Notifications
You must be signed in to change notification settings - Fork 17
Added VPC Quickstart DA with predefined ACL profiles and optional VPC Flow Logs #1082
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
Open
Khuzaima05
wants to merge
10
commits into
main
Choose a base branch
from
issue_15496
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+843
−1
Open
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
45fbddc
added vpc quickstart DA
6e1016f
init commit
469f0b5
Merge branch 'main' into issue_15496
Khuzaima05 7252064
SKIP UPGRADE TEST: upgrade test failing due to breaking change
eea4579
resolve review comments
24afd60
Merge branch 'main' into issue_15496
Khuzaima05 f3531a4
Updated PR as per discussion
03442a6
resolve conflicts
76df8dd
added readme.md
996d5b6
fix pre-commit
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
4 changes: 4 additions & 0 deletions
4
reference-architectures/deployable-architecture-quickstart-vpc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,3 @@ | ||
| # Cloud automation for VPC (Quickstart) | ||
Khuzaima05 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| :exclamation: **Important:** This solution is not intended to be called by other modules because it contains a provider configuration and is not compatible with the `for_each`, `count`, and `depends_on` arguments. For more information, see [Providers Within Modules](https://developer.hashicorp.com/terraform/language/modules/develop/providers). | ||
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,7 @@ | ||
| { | ||
| "ibmcloud_api_key": $VALIDATION_APIKEY, | ||
| "region": "us-south", | ||
| "resource_tags": $TAGS, | ||
| "existing_resource_group_name": "geretain-test-resources", | ||
| "prefix": $PREFIX | ||
| } |
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,165 @@ | ||
| locals { | ||
| prefix = var.prefix != null ? (trimspace(var.prefix) != "" ? "${var.prefix}-" : "") : "" | ||
| } | ||
|
|
||
| ############################################################################## | ||
| # Resource Group | ||
| ############################################################################## | ||
|
|
||
| module "resource_group" { | ||
| source = "terraform-ibm-modules/resource-group/ibm" | ||
| version = "1.4.0" | ||
| existing_resource_group_name = var.existing_resource_group_name | ||
| } | ||
|
|
||
|
|
||
| ############################################################################# | ||
| # Provision cloud object storage and bucket | ||
| ############################################################################# | ||
|
|
||
| module "cos" { | ||
| count = var.enable_vpc_flow_logs ? 1 : 0 | ||
| source = "terraform-ibm-modules/cos/ibm" | ||
| version = "10.5.8" | ||
| resource_group_id = module.resource_group.resource_group_id | ||
| region = var.region | ||
| cos_instance_name = "${var.prefix}-cos" | ||
| cos_tags = var.resource_tags | ||
| bucket_name = "${var.prefix}-bucket" | ||
| kms_encryption_enabled = false | ||
| } | ||
|
|
||
| ########################################################################### | ||
| # NETWORK ACL PROFILES | ||
| ########################################################################### | ||
|
|
||
| locals { | ||
| acl_profiles = { | ||
| open = [ | ||
| { | ||
| name = "${local.prefix}acl" | ||
| add_ibm_cloud_internal_rules = false | ||
| add_vpc_connectivity_rules = false | ||
| prepend_ibm_rules = false | ||
| rules = [ | ||
| { | ||
| name = "allow-all-inbound" | ||
| action = "allow" | ||
| direction = "inbound" | ||
| source = "0.0.0.0/0" | ||
| destination = "0.0.0.0/0" | ||
| }, | ||
| { | ||
| name = "allow-all-outbound" | ||
| action = "allow" | ||
| direction = "outbound" | ||
| source = "0.0.0.0/0" | ||
| destination = "0.0.0.0/0" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| common = [ | ||
| { | ||
| name = "${local.prefix}acl" | ||
| add_ibm_cloud_internal_rules = true | ||
| add_vpc_connectivity_rules = true | ||
| prepend_ibm_rules = true | ||
| rules = [ | ||
| { | ||
| name = "allow-ssh" | ||
| action = "allow" | ||
| direction = "inbound" | ||
| source = "0.0.0.0/0" | ||
| destination = "0.0.0.0/0" | ||
| tcp = { port_min = 22, port_max = 22 } | ||
| }, | ||
| { | ||
| name = "allow-https" | ||
| action = "allow" | ||
| direction = "inbound" | ||
| source = "0.0.0.0/0" | ||
| destination = "0.0.0.0/0" | ||
| tcp = { port_min = 443, port_max = 443 } | ||
| }, | ||
| { | ||
| name = "allow-http" | ||
| action = "allow" | ||
| direction = "inbound" | ||
| source = "0.0.0.0/0" | ||
| destination = "0.0.0.0/0" | ||
| tcp = { port_min = 80, port_max = 80 } | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| ibm-internal = [ | ||
| { | ||
| name = "${local.prefix}acl" | ||
| add_ibm_cloud_internal_rules = true | ||
| add_vpc_connectivity_rules = true | ||
| prepend_ibm_rules = true | ||
| rules = [] | ||
| } | ||
| ] | ||
| closed = [ | ||
| { | ||
| name = "${local.prefix}acl" | ||
| add_ibm_cloud_internal_rules = false | ||
| add_vpc_connectivity_rules = false | ||
| prepend_ibm_rules = false | ||
| rules = [] | ||
| } | ||
| ] | ||
| } | ||
| network_acls = lookup(local.acl_profiles, var.network_acls, local.acl_profiles["common"]) | ||
| } | ||
|
|
||
| ############################################################################# | ||
| # VPC | ||
| ############################################################################# | ||
|
|
||
| module "vpc" { | ||
| source = "../../" | ||
| resource_group_id = module.resource_group.resource_group_id | ||
| region = var.region | ||
| create_vpc = true | ||
| name = var.vpc_name | ||
| prefix = local.prefix != "" ? trimspace(var.prefix) : null | ||
| tags = var.resource_tags | ||
| access_tags = var.access_tags | ||
| subnets = { | ||
| zone-1 = [ | ||
| { | ||
| name = "${local.prefix}subnet-a" | ||
| cidr = "10.10.10.0/24" | ||
| public_gateway = true | ||
| acl_name = "${local.prefix}acl" | ||
| no_addr_prefix = false | ||
| } | ||
| ] | ||
| zone-2 = [ | ||
| { | ||
| name = "${local.prefix}subnet-b" | ||
| cidr = "10.20.10.0/24" | ||
| public_gateway = true | ||
| acl_name = "${local.prefix}acl" | ||
| no_addr_prefix = false | ||
| } | ||
| ] | ||
| zone-3 = [ | ||
| { | ||
| name = "${local.prefix}subnet-c" | ||
| cidr = "10.30.10.0/24" | ||
| public_gateway = true | ||
| acl_name = "${local.prefix}acl" | ||
| no_addr_prefix = false | ||
| } | ||
| ] | ||
| } | ||
| network_acls = local.network_acls | ||
| enable_vpc_flow_logs = var.enable_vpc_flow_logs | ||
| create_authorization_policy_vpc_to_cos = !var.skip_vpc_cos_iam_auth_policy | ||
| existing_cos_instance_guid = var.enable_vpc_flow_logs ? module.cos[0].cos_instance_guid : null | ||
| existing_storage_bucket_name = var.enable_vpc_flow_logs ? module.cos[0].bucket_name : null | ||
| } |
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.