Skip to content

Commit 1bab361

Browse files
fix: bug fixes and documentation addition for service_map variable (#288)
1 parent 20dd627 commit 1bab361

File tree

4 files changed

+83
-2
lines changed

4 files changed

+83
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Update status and "latest release" badges:
1414

1515
This module generates authorization policies and context-based restriction (CBR) rules to enable access and restrictions between a source service and a target service.
1616

17+
For important details on upgrading from v1 to v2, please refer to the [migration notes](./docs/migration_notes.md). This explains necessary steps for handling `service_map` variable format changes and state migration to avoid unintended policy destruction during your upgrade process.
18+
1719
<!-- Below content is automatically populated via pre-commit hook -->
1820
<!-- BEGIN OVERVIEW HOOK -->
1921
## Overview
@@ -111,7 +113,7 @@ You need the following permissions to run this module.
111113
| <a name="input_cbr_target_service_details"></a> [cbr\_target\_service\_details](#input\_cbr\_target\_service\_details) | Details of the target service for which the rule has to be created. | <pre>list(object({<br/> target_service_name = string<br/> target_rg = optional(string)<br/> enforcement_mode = string<br/> tags = optional(list(string))<br/> }))</pre> | `[]` | no |
112114
| <a name="input_enable_cbr"></a> [enable\_cbr](#input\_enable\_cbr) | Set to true to enable creation of Context Based restrictions (CBR) for services defined in var.cbr\_target\_service\_details. When true, var.zone\_vpc\_crn\_list and var.zone\_service\_ref\_list must be provided to create and attach the required CBR zones. When false, no CBR zones or rules are created. | `bool` | `true` | no |
113115
| <a name="input_prefix"></a> [prefix](#input\_prefix) | Prefix for new CBR zones and rules. | `string` | `null` | no |
114-
| <a name="input_service_map"></a> [service\_map](#input\_service\_map) | Map of unique service pairs and their authorization config. | <pre>map(object({<br/> source_service_name = string<br/> target_service_name = string<br/> roles = list(string)<br/> description = optional(string, null)<br/> source_service_account_id = optional(string, null)<br/> source_resource_instance_id = optional(string, null)<br/> target_resource_instance_id = optional(string, null)<br/> source_resource_group_id = optional(string, null)<br/> target_resource_group_id = optional(string, null)<br/> }))</pre> | `{}` | no |
116+
| <a name="input_service_map"></a> [service\_map](#input\_service\_map) | Map of unique service pairs and their authorization config. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-s2s-auth/tree/main/solutions/fully-configurable/DA-complex-input-variables.md#service-map) | <pre>map(object({<br/> source_service_name = string<br/> target_service_name = string<br/> roles = list(string)<br/> description = optional(string, null)<br/> source_service_account_id = optional(string, null)<br/> source_resource_instance_id = optional(string, null)<br/> target_resource_instance_id = optional(string, null)<br/> source_resource_group_id = optional(string, null)<br/> target_resource_group_id = optional(string, null)<br/> }))</pre> | `{}` | no |
115117
| <a name="input_zone_service_ref_list"></a> [zone\_service\_ref\_list](#input\_zone\_service\_ref\_list) | Service reference for the zone creation. | <pre>map(object({<br/> service_ref_location = optional(list(string), [])<br/> }))</pre> | `{}` | no |
116118
| <a name="input_zone_vpc_crn_list"></a> [zone\_vpc\_crn\_list](#input\_zone\_vpc\_crn\_list) | CRN of the VPC for the zones. | `list(string)` | `[]` | no |
117119

ibm_catalog.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
},
5252
{
5353
"key": "service_map",
54+
"required": true,
5455
"custom_config": {
5556
"type": "code_editor"
5657
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Configuring complex inputs for Service to Service Authoirsation in IBM Cloud projects
2+
3+
The `service_map` input variable use complex object type. You need to specify this input variable when you configure deployable architecture.
4+
5+
* [Service Map](#service-map) (`service_map`)
6+
7+
## Service Map <a name="service-map"></a>
8+
9+
The `service_map` input variable allows you to define service to service authorisation policy between services in same or different account.
10+
11+
- Variable name: `service_map`
12+
- Type: A map of objects, where the key is a unique attribute to describe the authorisation policy
13+
- Default value: An empty map (`{}`)
14+
15+
### Options for service_map
16+
- `source_service_name` (required): The name of the service requesting the access (or needing the access)
17+
18+
- `target_service_name` (required): The name of the service that the source service wants to access or communicate with.
19+
20+
- `roles` (required): A list of roles or permissions granted from the source service to the target service. These roles define the scope and level of access allowed.
21+
22+
- `description` (optional): A description providing additional context or the purpose of the authorization policy
23+
24+
- `source_service_account_id` (optional): The cloud account ID where the source service resides. This is important when the source and target services belong to different accounts.
25+
26+
- `source_resource_instance_id` (optional): The unique identifier(GUID) for a specific resource instance of the source service. This is mutually exclusive with `source_resource_group_id` and identifies the granular resource for access control.
27+
28+
- `target_resource_instance_id` (optional): The unique identifier(GUID) for the target service. This gives fine-grained control over the target resource. It is mutually exclusive with `target_resource_group_id`.
29+
30+
- `source_resource_group_id` (optional): The resource group ID containing the source service instances. This is an alternative to `source_resource_instance_id` to specify a group-level scope. Cannot be used at the same time as `source_resource_instance_id`.
31+
32+
- `target_resource_group_id` (optional): The resource group ID for the target service. Allows specifying a group-level target rather than an individual resource instance. Mutually exclusive with `target_resource_instance_id`.
33+
34+
### Points to note
35+
36+
- You must provide either `source_resource_instance_id` or `source_resource_group_id` but not both.
37+
- Similarly, only one of `target_resource_instance_id` or `target_resource_group_id` should be provided to avoid conflicts in target scope definition.
38+
39+
### Example Service Map Configuration
40+
41+
#### Cross Account s2s Authorisation Policy
42+
43+
```hcl
44+
service_map = {
45+
"cross-account-policy" = {
46+
source_service_name = "toolchain"
47+
target_service_name = "secrets-manager"
48+
roles = ["Viewer"]
49+
description = "Toolchain in account A can view to secrets manager in account B."
50+
source_service_account_id = "acct-id-123456"
51+
source_resource_instance_id = "be19xxxxxxxx3ea90c7d"
52+
target_resource_instance_id = "abcd12xxxxxxxxe21fgh"
53+
source_resource_group_id = null
54+
target_resource_group_id = null
55+
}
56+
}
57+
```
58+
59+
#### Single Resource Instance to whole Resource Group
60+
61+
Authorize one resource instance to access all resources of service "secrets-manager" within a target resource group
62+
63+
```hcl
64+
service_map = {
65+
"instance-to-group-policy" = {
66+
source_service_name = "toolchain"
67+
target_service_name = "secrets-manager"
68+
roles = ["Viewer"]
69+
description = "Toolchain instance needs read access to all storage resources in dev group."
70+
source_resource_instance_id = "be19xxxxxxxx3ea90c7d"
71+
target_resource_instance_id = null
72+
source_resource_group_id = null
73+
target_resource_group_id = "example-resource-group"
74+
}
75+
}
76+
```
77+
78+
For more information, refer to the [IBM Cloud Service to Service Authorisation documentation](https://cloud.ibm.com/docs/account?topic=account-serviceauth&interface=ui) and the [IBM Cloud Terraform Provider documentation for Authorisation Policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy).

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ variable "prefix" {
99
}
1010

1111
variable "service_map" {
12-
description = "Map of unique service pairs and their authorization config."
12+
description = "Map of unique service pairs and their authorization config. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-s2s-auth/tree/main/solutions/fully-configurable/DA-complex-input-variables.md#service-map)"
1313
type = map(object({
1414
source_service_name = string
1515
target_service_name = string

0 commit comments

Comments
 (0)