Skip to content

Commit 76b39f2

Browse files
authored
feat: initial stable release (#301)
1 parent 1c89a2a commit 76b39f2

File tree

13 files changed

+64
-340
lines changed

13 files changed

+64
-340
lines changed

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2023-04-05T23:33:26Z",
6+
"generated_at": "2023-04-11T16:23:03Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# IBM Virtual Private Endpoints module
22

3-
[![Incubating (Not yet consumable)](https://img.shields.io/badge/status-Incubating%20(Not%20yet%20consumable)-red)](https://terraform-ibm-modules.github.io/documentation/#/badge-status)
3+
[![Stable (With quality checks)](https://img.shields.io/badge/Status-Stable%20(With%20quality%20checks)-green)](https://terraform-ibm-modules.github.io/documentation/#/badge-status)
44
[![Build status](https://github.com/terraform-ibm-modules/terraform-ibm-vpe-module/actions/workflows/ci.yml/badge.svg)](https://github.com/terraform-ibm-modules/terraform-ibm-vpe-module/actions/workflows/ci.yml)
55
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
66
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
77
[![latest release](https://img.shields.io/github/v/release/terraform-ibm-modules/terraform-ibm-vpe-module?logo=GitHub&sort=semver)](https://github.com/terraform-ibm-modules/terraform-ibm-vpe-module/releases/latest)
88

9-
You can use this module to create and configure virtual private endpoint gateways (https://cloud.ibm.com/docs/vpc?topic=vpc-ordering-endpoint-gateway) for an IBM Cloud service.
9+
This module creates and configures virtual private endpoint gateways (https://cloud.ibm.com/docs/vpc?topic=vpc-ordering-endpoint-gateway) for an IBM Cloud service.
1010

1111
The module supports the following actions:
12-
- Create reserved IP addresses and endpoint gateways
12+
- Create virtual private endpoint gateways
13+
- Create reserved IP addresses
1314
- Attach endpoint gateways to reserved IP addresses
1415

1516
## Usage
@@ -68,7 +69,7 @@ You need the following permissions to run this module.
6869
<!-- BEGIN EXAMPLES HOOK -->
6970
## Examples
7071

71-
- [Examples](examples)
72+
- [ End-to-end example](examples/default)
7273
<!-- END EXAMPLES HOOK -->
7374

7475
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

common-dev-assets

examples/default/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# End-to-end example
2+
3+
This example creates the following infrastructure:
4+
- A resource group, if one is not passed in.
5+
- A VPC, if one is not passed in.
6+
- The VPC is created with three subnets across the three availability zones of the region that is passed as input.
7+
- A security group in the VPC.
8+
- The security group is created with a single inbound rule that allows traffic from resources that are attached to the default VPC security group. This rule is added as an example.
9+
- Two virtual private endpoint (VPE) gateways. By default, one VPE to COS and another VPE to Key Protect are created. You can change the defaults by using the `service_endpoints` input.
10+
- Each of the two virtual private endpoint gateways are attached to the three VPC subnets.
11+
- The new security group is attached to the two VPE gateways.

examples/default/main.tf

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,51 @@ module "resource_group" {
99
}
1010

1111
##############################################################################
12-
13-
##############################################################################
14-
# Locals
12+
# Create a VPC for this example using defaults from terraform-ibm-landing-zone-vpc
13+
# ( 3 subnets across the 3 AZs in the region )
1514
##############################################################################
1615

17-
locals {
18-
# input variable validation
19-
# tflint-ignore: terraform_unused_declarations
20-
validate_vpc_inputs = var.vpc_id == null && !var.create_vpc ? tobool("var.create_vpc should be set to true if var.vpc_id is set to null") : true
21-
# tflint-ignore: terraform_unused_declarations
22-
validate_vpc_id_and_create_vpc_both_not_set_inputs = var.vpc_id != null && var.create_vpc ? tobool("var.vpc_id cannot be set whilst var.create_vpc is set to true") : true
23-
vpc_instance_id = var.vpc_id == null ? tolist(ibm_is_vpc.vpc[*].id)[0] : var.vpc_id
16+
module "vpc" {
17+
count = var.vpc_id != null ? 0 : 1
18+
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vpc.git?ref=v5.0.1"
19+
resource_group_id = module.resource_group.resource_group_id
20+
region = var.region
21+
prefix = var.prefix
22+
name = var.vpc_name
23+
tags = var.resource_tags
2424
}
2525

2626
##############################################################################
27-
# Create a VPC for this example
27+
# Demonstrate how to create a custom security group that is applied to the VPEs
28+
# This examples allow all workload associated with the default VPC security group
29+
# to interact with the VPEs
2830
##############################################################################
29-
resource "ibm_is_vpc" "vpc" {
30-
count = var.create_vpc ? 1 : 0
31-
name = "${var.prefix}-${var.vpc_name}"
31+
32+
data "ibm_is_vpc" "vpc" {
33+
# Explicit depends as the vpc_name is known prior to VPC creation
34+
depends_on = [
35+
module.vpc
36+
]
37+
name = var.vpc_id != null ? var.vpc_id : module.vpc[0].vpc_name
38+
}
39+
40+
data "ibm_is_security_group" "default_sg" {
41+
name = data.ibm_is_vpc.vpc.default_security_group_name
42+
}
43+
44+
module "vpe_security_group" {
45+
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-security-group.git?ref=v1.0.0"
46+
security_group_name = "${var.prefix}-vpe-sg"
47+
add_ibm_cloud_internal_rules = false # No need for the internal ibm cloud rules for SG associated with VPEs
48+
49+
security_group_rules = [{
50+
name = "allow-all-default-sg-inbound"
51+
direction = "inbound"
52+
remote = data.ibm_is_security_group.default_sg.id
53+
}]
54+
3255
resource_group = module.resource_group.resource_group_id
33-
tags = var.resource_tags
56+
vpc_id = var.vpc_id != null ? var.vpc_id : module.vpc[0].vpc_id
3457
}
3558

3659
##############################################################################
@@ -41,10 +64,10 @@ module "vpes" {
4164
region = var.region
4265
prefix = var.prefix
4366
vpc_name = var.vpc_name
44-
vpc_id = local.vpc_instance_id
45-
subnet_zone_list = var.subnet_zone_list
67+
vpc_id = var.vpc_id != null ? var.vpc_id : module.vpc[0].vpc_id
68+
subnet_zone_list = var.vpc_id != null ? var.subnet_zone_list : module.vpc[0].subnet_zone_list
4669
resource_group_id = module.resource_group.resource_group_id
47-
security_group_ids = var.security_group_ids
70+
security_group_ids = var.security_group_ids != null ? var.security_group_ids : [module.vpe_security_group.security_group_id]
4871
cloud_services = var.cloud_services
4972
cloud_service_by_crn = var.cloud_service_by_crn
5073
service_endpoints = var.service_endpoints

examples/default/variables.tf

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,25 @@ variable "prefix" {
1919
variable "resource_group" {
2020
type = string
2121
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
22-
default = "geretain-test-resources"
22+
default = null
2323
}
2424

2525
##############################################################################
2626
# VPC Variables
2727
##############################################################################
2828

2929
variable "vpc_name" {
30-
description = "Name of the VPC where the Endpoint Gateways will be created. This value is used to dynamically generate VPE names."
30+
description = "Name of the VPC where the Endpoint Gateways will be created. This value is used to dynamically generate VPE names. It is also used to create a VPC when the vpc_id input is set to null."
3131
type = string
32-
default = "my-vpc-instance"
32+
default = "vpc-instance"
3333
}
3434

3535
variable "vpc_id" {
36-
description = "ID of the VPC where the Endpoint Gateways will be created"
36+
description = "ID of the VPC where the Endpoint Gateways will be created. Creates a VPC if set to null."
3737
type = string
3838
default = null
3939
}
4040

41-
variable "create_vpc" {
42-
description = "Create a VPC instance."
43-
type = bool
44-
default = true
45-
}
46-
4741
##############################################################################
4842

4943
##############################################################################

examples/security-group/main.tf

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

examples/security-group/outputs.tf

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

examples/security-group/provider.tf

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

0 commit comments

Comments
 (0)