|
| 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). |
0 commit comments