Share KMS instances across multiple accounts
In an enterprise environment, managing keys independently across accounts increases administrative costs and makes it difficult to enforce consistent security policies. The multi-account sharing feature of KMS instances allows an enterprise to securely distribute a single KMS instance to multiple member accounts across the organization, achieving unified key management and cost optimization.
Workflow
Cross-account sharing is built on two Alibaba Cloud services: Resource Directory and Resource Sharing. The workflow is as follows:
Set up an organization: Use Resource Directory to group all relevant Alibaba Cloud accounts as members under a single organization.
Resource Sharing: The instance owner creates a resource share through Resource Sharing, adds KMS instances as shared resources, and specifies other members in Resource Directory as resource principals.
Grant permissions:
Permission policy: When creating the share, the instance owner configures a predefined permission policy (
AliyunRSDefaultPermissionKMSInstance). Resource Sharing applies this policy to the specified resource principals.Sharing mode: Both “Independent Ownership” and “Joint Ownership” modes are available to control how resource (key and secret) permissions are divided within the KMS instance.
RAM users: Resource principals must attach RAM policies with specific operation permissions (such as
kms:Encryptandkms:Decrypt) to their RAM identities (RAM users or roles).
Example scenario: Department A of an enterprise purchases a KMS instance. If Department B also needs to use the KMS instance, the enterprise can use Resource Directory to centrally manage Alibaba Cloud accounts and then use Resource Sharing to share the KMS instance with Department B. The following figure shows the architecture.
Applicable scope
Instance requirements:
An enabled software key management instance or hardware key management instance.
Account and organization requirements:
The instance owner and instance principals must be under the same enterprise real-name verification.
The instance owner and instance principals must belong to the same Resource Directory.
Sharing mode selection guide
For detailed permission differences between the two modes, see Appendix: Sharing mode permission details.
Feature | Independent ownership | Joint ownership |
Use case | Cross-account secrets with the same name, or permission isolation between accounts. | Internal collaboration where a central team (such as IT or security) manages and audits all keys and secrets. |
Core feature | Independent data sovereignty: The instance owner cannot manage or use the keys and secrets created by instance users. | Shared data sovereignty: The instance owner can manage and use the keys and secrets created by instance users. |
Same-name secrets across accounts | Allowed. Instance users and the instance owner can create secrets with the same name. | Not allowed. All key and secret names within the instance must be unique. |
Model change | Cannot be changed to Joint Ownership. | Can be changed to Independent Ownership. |
Procedure
Configure sharing (instance owner)
Step 1: Set up Resource Directory and enable organization sharing
Enable Resource Directory:
Log on to the console
Use the management account to log on to the Resource Management console.
Enable Resource Directory
In the left-side navigation pane, choose,Click Enable Resource Directory. For more information, see Enable Resource Directory
Create a folder
Go to in the upper-right corner. In the resource directory tree on the left, click the target folder, and then on the Resource Organization View tab. In the resource directory tree on the left, click the target folder, and then on the Member tab, click Create Folder. Enter Folder Name and then click Confirm. For more information, see Create a folder.
Configure members
On the Member tab, click Create Member Account or Invite Member, and refer to Create a member Invite an Alibaba Cloud account and Move a member to configure the account name, account UID, and billing account.
Invite Member
Parameter
Description
Account ID or logon email address
Account ID: To find an account ID, see How do I find my Alibaba Cloud account ID?.
Logon email address: The email address that you used to register the account. If an account does not have a logon email, use its account ID.
To invite multiple accounts, enter their account IDs or logon email addresses, separated by commas.
Remarks
Enter a remark for the invitation. This helps the invitee verify the invitation's authenticity and respond faster.
Tag
Add a tag to the member for easier filtering and management.
Parent Folder
By default, the invited member is placed in the Root folder. You can click Modify to move the member to a different folder. You can also change the folder after the member accepts the invitation.
Create Member Account
Parameter
Description
Account Name
The Alibaba Cloud account name is a unique identifier for a member and must be unique within Resource Directory.
The Alibaba Cloud account name must be 2 to 50 characters in length and can contain letters, digits, and special characters
_.-. It must start and end with a letter or digit and cannot contain consecutive special characters_.-.
Member Account Name
The display name must be 2 to 50 characters in length and can contain Chinese characters, letters, digits, and special characters
_.-.Billing Account
Specify the billing account for the newly created member.
-
Use Management Account for Settlement of New Member: Uses the management account of the resource directory as the billing account under financial trusteeship.
-
Use Existing Member for Settlement of New Member: Uses an existing member of the resource directory as the billing account under financial trusteeship. In the Specify Member panel, you must select a member from the directory tree of the resource directory.
NoteA member cannot be selected if it does not have payment capabilities. For more information about member payment capabilities, see Financial Trusteeship Notes.
-
Use New Member Itself for Settlement: Uses the current member as its own billing account.
Tags
Bind tags to the member for tag-based management.
Parent Folder
By default, the invited account is placed under the root folder. You can click Modify to change the folder. You can also change the folder after the invitation is accepted.
Enable Resource Sharing
After you enable Resource Sharing, the resource owner (management account or member) can share resources with the entire resource directory, folders, or members. For more information, see Enable resource sharing.
Use the management account of the resource directory to log on to the Resource Sharing console. In the left-side navigation pane, choose.
Click Enable, and then in the Service-linked Role for Resource Sharing dialog box, click OK.
NoteThe system automatically creates a service-linked role named AliyunServiceRoleForResourceSharing to obtain the organization information of the resource directory. For more information, see Service-linked role for Resource Sharing.
Step 2: Configure KMS instance sharing
This step guides the instance owner through sharing a KMS instance with one or more principals.
Log on to the console
Log on to the Key Management Service console. In the top menu bar, select a region. In the left-side navigation pane, click Instances.
Select a sharing mode
On the Instances page, find the target KMS instance, and click Share Resources in the Actions column. In the RD Multi-account Sharing Settings panel, first select the Sharing mode selection guide to choose a Sharing Model.
Configure the resource share
In the Add to Resource Share area, select or create a resource share.
Item
Create a resource share (recommended)
Select an existing resource share
Scenario
First-time sharing or when permission isolation is required.
When you need to add the current instance to an existing resource share and reuse its principals and permissions.
Features
Permission isolation:Contains only the current KMS instance with independent permissions.
Scope of control:Only newly added accounts can access the shared instance.
Permission sharing:
All existing principals in the resource share automatically gain access to the new instance, consuming the access management quota.
Any permission change to the resource share affects all resources in the share.
Scope of control: Both existing principals and newly added accounts can access the shared instance.
WarningThis may cause unintended permission escalation and quota consumption. Proceed with caution.
Configure sharing parameters
Complete the following configuration based on the selected method, and then click OK.
Create a resource share (recommended)
Resource Share Name
Supports Chinese characters, uppercase and lowercase letters, digits, and special characters (".", "_", or "-"). Maximum length: 50 characters.
Principals(instance principals)
Specify the accounts that can use this KMS instance.
ImportantWe recommend that you add resources by folder or cloud account for fine-grained control. Each addition consumes an access management quota of the instance.
If you add or remove principals in an existing resource share, the changes take effect on all resources in the unit.
You can add the following three types of principals:
Cloud account:The resource is shared only with the specified Alibaba Cloud account (UID).
Resource directory organization:Share the resource with all member accounts in the entire resource directory, including members added later.
Folder (organizational unit):Enter a folder ID to share the resource with all members under the folder, including members added later. Folder ID format: fd-string. For more information about how to view folder information, see Folder basic information.
Add Permissions
Configure the permissions for resource principals (instance principals). For detailed permission information, view the permission library in the Resource Sharing console.
AliyunRSDefaultPermissionKMSInstance(recommended): Two versions (v1 and v2) are available. Newly created permissions default to v2. For more information about how to view the permission version, see View the details of a permission.AliyunRSPermissionKMSInstanceReadWrite(deprecated): If you used this permission before, you can continue to use it.
Select an existing resource share
Select Resource Share
The system synchronizes all resource shares under the current account. For more information, see Create a resource share.
Shared Resources
This list automatically displays the existing resources in the selected resource share (read-only). After this operation, the current KMS instance is added to the resource share.
Principals(instance principals)
Specify the accounts that can use this KMS instance.
ImportantWe recommend that you add resources by folder or cloud account for fine-grained control. Each addition consumes an access management quota of the instance.
If you add or remove principals in an existing resource share, the changes take effect on all resources in the unit.
You can add the following three types of principals:
Cloud account:The resource is shared only with the specified Alibaba Cloud account (UID).
Resource directory organization:Share the resource with all member accounts in the entire resource directory, including members added later.
Folder (organizational unit):Enter a folder ID to share the resource with all members under the folder, including members added later. Folder ID format: fd-string. For more information about how to view folder information, see Folder basic information.
Add Permissions
Configure the permissions for resource principals (instance principals). For detailed permission information, view the permission library in the Resource Sharing console.
AliyunRSDefaultPermissionKMSInstance(recommended): Two versions (v1 and v2) are available. Newly created permissions default to v2. For more information about how to view the permission version, see View the details of a permission.AliyunRSPermissionKMSInstanceReadWrite(deprecated): If you used this permission before, you can continue to use it.
Use the shared instance (instance principal)
Verify that the sharing is successful, and then create and use keys/secrets in the shared instance.
Log on to the console
Log on to the Key Management Service console. On the Instances page, you can see a KMS instance with the Shared label.
Create keys and secrets
On the Keys or Secrets tab, click Create Key or Create Secret. For KMS Instance, select the shared instance. For other configuration, see Create a key and Create a secret.
Grant permissions to RAM users:
The resource principal must configure a RAM policy for its RAM identities (users or roles) to grant permissions to call specific KMS API operations (such as
kms:Encrypt,kms:Decrypt). For more information, see Use RAM to implement access control.Use keys and secrets
After keys and secrets are created, you can use them in cloud services or self-managed applications. For more information, see:
Server-side encryption for cloud services:Overview of KMS encryption integration with cloud services Cloud services integrated with KMS.
Cloud service secret integration: Integrating KMS secrets with Alibaba Cloud services.
Self-managed application integration with KMS (keys and secrets): Integrate KMS with self-managed applications.
Management and maintenance
Modify resource principals of a resource share
Perform operations in the Key Management Service console
Instance owner Log on toKey Management Service console. In the top menu bar, select a region. In the left-side navigation pane, click Instances.
On Instances page, based on the KMS instance type, click Software Key Management tab or Hardware Key Management tab.
Find the target KMS instance and click Actions/Share Resources.
In the Add to Resource Share panel, select resource share, click Principals in the Edit section, add or remove resource principals, and then click OK.
Perform operations in the Resource Sharing console
For more information, see Modify a resource share.
Remove KMS instance sharing relationships
Before you revoke the sharing, the instance principal must delete all keys and secrets that they created. Otherwise, the revocation fails. Make sure that the associated resources are no longer in use to avoid service interruption.
Operations can only be performed in the Resource Sharing console.
Use the management account toLog on to the Resource Sharing console.
In the left-side navigation pane, choose .In the list of Resource Shares, click the ID of the target Resource Share.
In the upper-right corner of the page, click Delete Resource Share.In the Delete Resource Share dialog box, click OK.
View operation logs
The instance owner can use ActionTrail or the KMS console to query key and secret operation logs of the shared KMS instance for audit purposes.
You can only view Alibaba Cloud SDK (such as encryption, decryption, and secret retrieval) operation logs.Management operations (such as key creation and key status modification) cannot be viewed.
ActionTrail
Scope: You can only view business operations performed through shared gateways.
Procedure:
Log on to ActionTrail console. In the left-side navigation pane, choose Event Query.
In the top navigation bar, select the region where the shared KMS instance is deployed.
Set the query condition to Resource Name and enter the key or secret ID created under the shared instance.
Simple Log Service for KMS
Scope: Supports viewing business operations performed through dedicated gateways and shared gateways.
Procedure:
Log on to the Key Management Service console. In the top navigation bar, select a region. In the left-side navigation pane, choose .
In the top navigation bar, select the region where the shared KMS instance is deployed.
Select the shared instance ID and click Search.
NoteIf log service is not enabled for the current instance, first Enable Simple Log Service for KMS.
Production environment best practices
When deploying and using shared instances in production environments, follow these guidelines to ensure system stability, security, and compliance.
Network connectivity
If instance principals deploy self-managed applications in a VPC and need to access KMS through a private gateway, the instance owner must bind the VPC to which the instance principals belong to the shared KMS instance for private network access. For more information, see Configure Multi-VPC access to KMS instances within the same region.
Audit and compliance
Instance owner: must enable ActionTrail to record all management operations on the shared instance and critical operations performed by principals.
Instance principals: We recommend that you enable ActionTrail to record all API call activities within your account.
Change management:
Revoke sharing: Before revoking a sharing relationship or deleting a resource share, the instance principal must delete all keys and secrets created in the shared instance. If resources remain, the revocation fails. Make sure that the associated resources are no longer in use to avoid service interruption. For more information, see Remove KMS instance sharing relationships.
Modify instance principals: Adding or removing principals in a resource share affects all shared resources in the share. To avoid permission confusion, we recommend that you create separate resource shares for different business scenarios or teams. For more information, see Modify resource principals of a resource share.
Quotas and limits
Feature limits
Default keys (such as
alias/acs/osskeys) cannot be shared..Instance principals cannot use a shared KMS instance across regions.
In Joint ownership mode: All key and secret names within the instance must be globally unique.
Access management quota limits
Shared KMS instances consume the instance owner's access management quota. If the quota is insufficient, promptly Upgrade KMS instance.
ImportantQuota calculation:
Consumed quota = Number of shared accounts + Number of bound VPCs.For example, if you share an instance with 3 accounts and bind 2 VPCs, the total consumed quota is 5.
Quota change description: If adding resource principals fails due to insufficient quota, the system does not automatically retry after you increase the instance quota. You must manually remove the principals (account or folder) from the resource share and then re-add them.
FAQ
After configuration, if instance principals receive "AccessDenied" or "Forbidden" errors when calling APIs, how can I troubleshoot the issue?
Check the following four permission configurations in order:
Resource Sharing permissions: In the Resource Sharing console: Confirm that the principal account has been added to the resource share and the sharing status is normal.
KMS instance permissions:Check whether the permission associated with the resource share is
AliyunRSDefaultPermissionKMSInstance.RAM call permissions:Confirm that the RAM user or RAM role that calls the API operation has been granted a RAM policy to access KMS. For example,
kms:Encrypt,kms:Decryptoperation permissions.Resource ownership: In Independent ownership mode: Confirm that the key or secret being operated on was created by the current instance principal.
Why do I receive a name conflict error when creating a secret in joint ownership mode?
In Joint Ownership mode: All key and secret names in the KMS instance must be unique. The instance owner and principals cannot create resources with the same name.
Solution 1: Change the secret name.
Solution 2: If your business scenario requires keys or secrets with the same name across accounts, switch the sharing mode to “Independent Ownership” mode.
WarningThis change can only be made from “Joint ownership” to “Independent ownership” and is irreversible. Carefully evaluate the impact before proceeding.
Appendix: Sharing mode permission details
The following table lists the operation permissions of the instance owner and instance principals for each feature in the two sharing modes.
indicates that the feature is supported.indicates that the feature is not supported.
Joint Ownership
Feature | Sub-feature | Instance owner | Instance principals |
Instance management | View KMS instance details | ||
Configure multi-VPC access to the KMS instance | |||
Upgrade the instance | |||
Renew the instance | |||
Remove sharing association | |||
Key management | Create a key | ||
View key metadata | Note All keys are supported, including keys created by instance principals. | Note Only keys created by instance principals are supported. | |
Configure key rotation | |||
Schedule key deletion | |||
Enable deletion protection | |||
Create and manage key aliases | |||
Add and manage key tags | |||
Cryptographic operations | None | ||
Secret management | Create a secret | ||
View secret metadata | Note All secrets are supported, including secrets created by instance principals. | Note Only secrets created by instance principals are supported. | |
Delete a secret | |||
Configure secret rotation | |||
Add and manage secret tags | |||
Get the secret value | None | ||
Backup management | None | Note All keys and secrets can be backed up, including keys and secrets created by instance principals. | |
Application access | Create an application access point |
Independent Ownership
Feature | Sub-feature | Instance owner | Instance principals |
Instance management | View KMS instance details | ||
Configure multi-VPC access to the KMS instance | |||
Upgrade the instance | |||
Renew the instance | |||
Remove sharing association | |||
Key management | Create a key | ||
View key metadata | Note Only keys created by the instance owner are supported. | Note Only keys created by instance principals are supported. | |
Configure key rotation | |||
Schedule key deletion | |||
Enable deletion protection | |||
Create and manage key aliases | |||
Add and manage key tags | |||
Cryptographic operations | None | ||
Secret management | Create a secret | ||
View secret metadata | Note Only keys created by the instance owner are supported. | Note Only secrets created by instance principals are supported. | |
Delete a secret | |||
Configure secret rotation | |||
Add and manage secret tags | |||
Get the secret value | None | ||
Backup management | None | Note Only keys created by the instance owner can be backed up. | |
Application access | Create an application access point |