-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: initial commit for DA #915
Draft
maheshwarishikha
wants to merge
12
commits into
main
Choose a base branch
from
vpc-da-12217
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.
+751
−1
Draft
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d13a7c9
feat: initial commit
17888e3
Merge branch 'main' into vpc-da-12217
0635ef8
update defalt value of resource group
af8271a
update code
c718316
Merge branch 'main' into vpc-da-12217
maheshwarishikha 41eaba0
update code
6386636
Merge branch 'main' into vpc-da-12217
maheshwarishikha faf01ac
add validations
cc592f7
create public_gateway object and added validation
a00fc30
Merge branch 'main' into vpc-da-12217
maheshwarishikha c083207
added vpn gateway feature
a93760f
Merge branch 'main' into vpc-da-12217
maheshwarishikha 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 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,11 @@ | ||
# IBM VPC deployable architecture | ||
|
||
This deployable architecture supports provisioning the following resources: | ||
|
||
- A new resource group if one is not passed in. | ||
- A VPC. | ||
|
||
|
||
 | ||
|
||
: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). |
6 changes: 6 additions & 0 deletions
6
solutions/fully-configurable/catalogValidationValues.json.template
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,6 @@ | ||
{ | ||
"ibmcloud_api_key": $VALIDATION_APIKEY, | ||
"region": "us-south", | ||
"resource_tags": $TAGS, | ||
"resource_group_name": $PREFIX | ||
} |
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,133 @@ | ||
locals { | ||
prefix = var.prefix != null ? (var.prefix != "" ? var.prefix : null) : null | ||
} | ||
|
||
############################################################################## | ||
# Resource Group | ||
############################################################################## | ||
|
||
module "resource_group" { | ||
source = "terraform-ibm-modules/resource-group/ibm" | ||
version = "1.1.6" | ||
resource_group_name = var.use_existing_resource_group == false ? try("${local.prefix}-${var.resource_group_name}", var.resource_group_name) : null | ||
existing_resource_group_name = var.use_existing_resource_group == true ? var.resource_group_name : null | ||
} | ||
|
||
############################################################################# | ||
# COS Bucket for VPC flow logs | ||
############################################################################# | ||
|
||
# parse COS details from the existing COS instance CRN | ||
module "existing_cos_crn_parser" { | ||
count = var.existing_cos_instance_crn != null ? 1 : 0 | ||
source = "terraform-ibm-modules/common-utilities/ibm//modules/crn-parser" | ||
version = "1.1.0" | ||
crn = var.existing_cos_instance_crn | ||
} | ||
|
||
locals { | ||
bucket_name = try("${local.prefix}-${var.cos_bucket_name}", var.cos_bucket_name) | ||
|
||
bucket_config = [{ | ||
access_tags = var.access_tags | ||
bucket_name = local.bucket_name | ||
kms_encryption_enabled = var.kms_encryption_enabled_bucket | ||
kms_guid = var.kms_encryption_enabled_bucket ? module.existing_kms_instance_crn_parser[0].service_instance : null | ||
kms_key_crn = var.kms_encryption_enabled_bucket ? var.existing_kms_instance_crn : null | ||
skip_iam_authorization_policy = var.skip_cos_kms_auth_policy | ||
management_endpoint_type = var.management_endpoint_type_for_bucket | ||
storage_class = var.cos_bucket_class | ||
resource_instance_id = var.existing_cos_instance_crn | ||
region_location = var.region | ||
force_delete = true | ||
}] | ||
} | ||
|
||
module "cos_buckets" { | ||
count = var.enable_vpc_flow_logs ? 1 : 0 | ||
source = "terraform-ibm-modules/cos/ibm//modules/buckets" | ||
version = "8.19.2" | ||
bucket_configs = local.bucket_config | ||
} | ||
|
||
####################################################################################################################### | ||
# KMS Key | ||
####################################################################################################################### | ||
|
||
# parse KMS details from the existing KMS instance CRN | ||
module "existing_kms_instance_crn_parser" { | ||
count = var.kms_encryption_enabled_bucket && var.existing_kms_instance_crn != null ? 1 : 0 | ||
source = "terraform-ibm-modules/common-utilities/ibm//modules/crn-parser" | ||
version = "1.1.0" | ||
crn = var.existing_kms_instance_crn | ||
} | ||
|
||
locals { | ||
# fetch KMS region from existing_kms_instance_crn if KMS resources are required | ||
kms_region = var.kms_encryption_enabled_bucket && var.existing_kms_instance_crn != null ? module.existing_kms_instance_crn_parser[0].region : null | ||
|
||
kms_key_ring_name = try("${var.prefix}-${var.kms_key_ring_name}", var.kms_key_ring_name) | ||
kms_key_name = try("${var.prefix}-${var.kms_key_name}", var.kms_key_name) | ||
|
||
create_kms_key = var.existing_kms_key_crn == null ? ((var.enable_vpc_flow_logs && var.kms_encryption_enabled_bucket && var.existing_kms_instance_crn != null) ? true : false) : false | ||
} | ||
|
||
module "kms" { | ||
count = local.create_kms_key ? 1 : 0 # no need to create any KMS resources if not passing an existing KMS CRN or existing KMS key CRN is provided | ||
source = "terraform-ibm-modules/kms-all-inclusive/ibm" | ||
version = "4.19.5" | ||
create_key_protect_instance = false | ||
region = local.kms_region | ||
existing_kms_instance_crn = var.existing_kms_instance_crn | ||
key_ring_endpoint_type = var.kms_endpoint_type | ||
key_endpoint_type = var.kms_endpoint_type | ||
keys = [ | ||
{ | ||
key_ring_name = local.kms_key_ring_name | ||
existing_key_ring = false | ||
force_delete_key_ring = true | ||
keys = [ | ||
{ | ||
key_name = local.kms_key_name | ||
standard_key = false | ||
rotation_interval_month = 3 | ||
dual_auth_delete_enabled = false | ||
force_delete = true | ||
} | ||
] | ||
} | ||
] | ||
} | ||
|
||
############################################################################# | ||
# VPC | ||
############################################################################# | ||
|
||
locals { | ||
# //TO DO | ||
# to create use_public_gateways object | ||
} | ||
|
||
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 | ||
tags = var.resource_tags | ||
access_tags = var.access_tags | ||
subnets = var.subnets | ||
default_network_acl_name = var.default_network_acl_name | ||
default_security_group_name = var.default_security_group_name | ||
default_routing_table_name = var.default_routing_table_name | ||
network_acls = var.network_acls | ||
clean_default_sg_acl = var.clean_default_sg_acl | ||
# use_public_gateways = local.public_gateway_object | ||
address_prefixes = var.address_prefixes | ||
routes = var.routes | ||
enable_vpc_flow_logs = var.enable_vpc_flow_logs | ||
create_authorization_policy_vpc_to_cos = !var.skip_vpc_cos_authorization_policy | ||
existing_cos_instance_guid = var.enable_vpc_flow_logs ? module.existing_cos_crn_parser[0].service_instance : null | ||
existing_storage_bucket_name = var.enable_vpc_flow_logs ? module.cos_buckets[0].buckets[0].bucket_name : null | ||
} |
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,36 @@ | ||
############################################################################## | ||
# VPC | ||
############################################################################## | ||
|
||
output "vpc_name" { | ||
description = "Name of VPC created" | ||
value = module.vpc.vpc_name | ||
} | ||
|
||
output "vpc_id" { | ||
description = "ID of VPC created" | ||
value = module.vpc.vpc_id | ||
} | ||
|
||
output "vpc_crn" { | ||
description = "CRN of VPC created" | ||
value = module.vpc.vpc_crn | ||
} | ||
|
||
############################################################################## | ||
# Public Gateways | ||
############################################################################## | ||
|
||
output "public_gateways" { | ||
description = "Map of public gateways by zone" | ||
value = module.vpc.public_gateways | ||
} | ||
|
||
############################################################################## | ||
# VPC flow logs | ||
############################################################################## | ||
|
||
output "vpc_flow_logs" { | ||
description = "Details of VPC flow logs collector" | ||
value = module.vpc.vpc_flow_logs | ||
} |
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,9 @@ | ||
######################################################################################################################## | ||
# Provider config | ||
######################################################################################################################## | ||
|
||
provider "ibm" { | ||
ibmcloud_api_key = var.ibmcloud_api_key | ||
region = var.region | ||
visibility = var.provider_visibility | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we really default this to force delete? I suspect the safer option would be to not force delete by default? Especially since the bucket will contain flow logs, which would be needed for audit purposes. Perhaos it needs to be exposed, defaulted to
false
but set to true in all our tests (otherwise the destroy would fail)