@@ -2,7 +2,7 @@ SOPS: Secrets OPerationS
22========================
33
44**SOPS ** is an editor of encrypted files that supports YAML, JSON, ENV, INI and BINARY
5- formats and encrypts with AWS KMS, GCP KMS, Azure Key Vault, age, and PGP.
5+ formats and encrypts with AWS KMS, GCP KMS, Azure Key Vault, HuaweiCloud KMS, age, and PGP.
66(`demo <https://www.youtube.com/watch?v=YTEVyLXFiq0 >`_)
77
88.. image :: https://i.imgur.com/X0TM5NI.gif
@@ -532,13 +532,77 @@ To easily deploy Vault locally: (DO NOT DO THIS FOR PRODUCTION!!!)
532532
533533 $ sops encrypt --verbose prod/raw.yaml > prod/encrypted.yaml
534534
535+ Encrypting using HuaweiCloud KMS
536+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
537+
538+ The HuaweiCloud KMS integration uses the
539+ ` default credential provider chain < https://github.com/huaweicloud/huaweicloud-sdk-go-v3/blob/master/core/auth/provider/provider.go> ` _
540+ which tries several authentication methods, in this order:
541+
542+ 1. Environment variables: ` ` HUAWEICLOUD_SDK_AK` ` , ` ` HUAWEICLOUD_SDK_SK` ` , ` ` HUAWEICLOUD_SDK_PROJECT_ID` `
543+ 2. Credentials file at ` ` ~/.huaweicloud/credentials` `
544+ 3. Instance metadata (when running on HuaweiCloud instances)
545+
546+ For example, you can use environment variables:
547+
548+ .. code:: bash
549+
550+ export HUAWEICLOUD_SDK_AK="your-access-key"
551+ export HUAWEICLOUD_SDK_SK="your-secret-key"
552+ export HUAWEICLOUD_SDK_PROJECT_ID="your-project-id"
553+
554+ Alternatively, you can create a credentials file at ` ` ~/.huaweicloud/credentials` ` :
555+
556+ .. code:: sh
557+
558+ $ cat ~/.huaweicloud/credentials
559+ [default]
560+ ak = your-access-key
561+ sk = your-secret-key
562+ project_id = your-project-id
563+
564+ Encrypting/decrypting with HuaweiCloud KMS requires a KMS key ID in the format
565+ ` ` region:key-uuid` ` . You can get the key ID from the HuaweiCloud console or using
566+ the HuaweiCloud API. The key ID format is ` ` region:key-uuid` ` where:
567+
568+ - ` ` region` ` is the HuaweiCloud region (e.g., ` ` tr-west-1` ` , ` ` cn-north-1` ` )
569+ - ` ` key-uuid` ` is the UUID of the KMS key (e.g., ` ` abc12345-6789-0123-4567-890123456789` ` )
570+
571+ Now you can encrypt a file using:
572+
573+ .. code:: sh
574+
575+ $ sops encrypt --hckms tr-west-1:abc12345-6789-0123-4567-890123456789 test.yaml > test.enc.yaml
576+
577+ Or using the environment variable:
578+
579+ .. code:: sh
580+
581+ $ export SOPS_HUAWEICLOUD_KMS_IDS="tr-west-1:abc12345-6789-0123-4567-890123456789"
582+ $ sops encrypt test.yaml > test.enc.yaml
583+
584+ And decrypt it using:
585+
586+ .. code:: sh
587+
588+ $ sops decrypt test.enc.yaml
589+
590+ You can also configure HuaweiCloud KMS keys in the ` ` .sops.yaml` ` config file:
591+
592+ .. code:: yaml
593+
594+ creation_rules:
595+ - path_regex: \.hckms\.yaml$
596+ hckms:
597+ - tr-west-1:abc12345-6789-0123-4567-890123456789,tr-west-2:def67890-1234-5678-9012-345678901234
598+
535599Adding and removing keys
536600~~~~~~~~~~~~~~~~~~~~~~~~
537601
538602When creating new files, ` ` sops` ` uses the PGP, KMS and GCP KMS defined in the
539- command line arguments ` ` --kms` ` , ` ` --pgp` ` , ` ` --gcp-kms` ` or ` ` --azure-kv` ` , or from
603+ command line arguments ` ` --kms` ` , ` ` --pgp` ` , ` ` --gcp-kms` ` , ` ` --hckms ` ` or ` ` --azure-kv` ` , or from
540604the environment variables ` ` SOPS_KMS_ARN` ` , ` ` SOPS_PGP_FP` ` , ` ` SOPS_GCP_KMS_IDS` ` ,
541- ` ` SOPS_AZURE_KEYVAULT_URLS` ` . That information is stored in the file under the
605+ ` ` SOPS_HUAWEICLOUD_KMS_IDS ` ` , ` ` SOPS_AZURE_KEYVAULT_URLS` ` . That information is stored in the file under the
542606` ` sops` ` section, such that decrypting files does not require providing those
543607parameters again.
544608
@@ -582,9 +646,9 @@ disabled by supplying the ``-y`` flag.
582646
583647The ` ` rotate` ` command generates a new data encryption key and reencrypt all values
584648with the new key. At the same time, the command line flag ` ` --add-kms` ` , ` ` --add-pgp` ` ,
585- ` ` --add-gcp-kms` ` , ` ` --add-azure-kv` ` , ` ` --rm-kms` ` , ` ` --rm-pgp` ` , ` ` --rm-gcp-kms` `
586- and ` ` --rm-azure-kv` ` can be used to add and remove keys from a file. These flags use
587- the comma separated syntax as the ` ` --kms` ` , ` ` --pgp` ` , ` ` --gcp-kms` ` and ` ` --azure-kv` `
649+ ` ` --add-gcp-kms` ` , ` ` --add-hckms ` ` , ` ` --add- azure-kv` ` , ` ` --rm-kms` ` , ` ` --rm-pgp` ` , ` ` --rm-gcp-kms` ` ,
650+ ` ` --rm-hckms ` ` and ` ` --rm-azure-kv` ` can be used to add and remove keys from a file. These flags use
651+ the comma separated syntax as the ` ` --kms` ` , ` ` --pgp` ` , ` ` --gcp-kms` ` , ` ` --hckms ` ` and ` ` --azure-kv` `
588652arguments when creating new files.
589653
590654Use ` ` updatekeys` ` if you want to add a key without rotating the data key.
@@ -760,7 +824,7 @@ stdout.
760824Using .sops.yaml conf to select KMS, PGP and age for new files
761825~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
762826
763- It is often tedious to specify the ` ` --kms` ` ` ` --gcp-kms` ` ` ` --pgp` ` and ` ` --age` ` parameters for creation
827+ It is often tedious to specify the ` ` --kms` ` ` ` --gcp-kms` ` ` ` --hckms ` ` ` ` -- pgp` ` and ` ` --age` ` parameters for creation
764828of all new files. If your secrets are stored under a specific directory, like a
765829` ` git` ` repository, you can create a ` ` .sops.yaml` ` configuration file at the root
766830directory to define which keys are used for which filename.
@@ -802,6 +866,10 @@ can manage the three sets of configurations for the three types of files:
802866 - path_regex: \.gcp\.yaml$
803867 gcp_kms: projects/mygcproject/locations/global/keyRings/mykeyring/cryptoKeys/thekey
804868
869+ # hckms files using HuaweiCloud KMS
870+ - path_regex: \.hckms\.yaml$
871+ hckms: tr-west-1:abc12345-6789-0123-4567-890123456789,tr-west-2:def67890-1234-5678-9012-345678901234
872+
805873 # Finally, if the rules above have not matched, this one is a
806874 # catchall that will encrypt the file using KMS set C as well as PGP
807875 # The absence of a path_regex means it will match everything
@@ -1797,6 +1865,16 @@ To directly specify a single key group, you can use the following keys:
17971865 - hc_vault_transit_uri:
17981866 - http://my.vault/v1/sops/keys/secondkey
17991867
1868+ * ` ` hckms` ` (list of strings): list of HuaweiCloud KMS key IDs (format: ` ` <region>:<key-uuid>` ` ).
1869+ Example:
1870+
1871+ .. code:: yaml
1872+
1873+ creation_rules:
1874+ - hckms:
1875+ - tr-west-1:abc12345-6789-0123-4567-890123456789
1876+ - tr-west-1:def67890-1234-5678-9012-345678901234
1877+
18001878To specify a list of key groups, you can use the following key:
18011879
18021880* ` ` key_groups` ` (list of key group objects): a list of key group objects.
@@ -1824,6 +1902,8 @@ To specify a list of key groups, you can use the following key:
18241902 - https://vault.url/keys/key-name/ # key without version, the latest will be used
18251903 hc_vault_transit_uri:
18261904 - http://my.vault/v1/sops/keys/secondkey
1905+ hckms:
1906+ - tr-west-1:abc12345-6789-0123-4567-890123456789
18271907
18281908 merge:
18291909 - pgp:
@@ -1901,6 +1981,17 @@ A key group supports the following keys:
19011981
19021982* ` ` hc_vault` ` (list of strings): list of HashiCorp Vault transit URIs.
19031983
1984+ * ` ` hckms` ` (list of objects): list of HuaweiCloud KMS key IDs.
1985+ Every object must have the following key:
1986+
1987+ * ` ` key_id` ` (string): the key ID in format ` ` < region> :< key-uuid> ` ` .
1988+
1989+ Example:
1990+
1991+ .. code:: yaml
1992+
1993+ - key_id: tr-west-1:abc12345-6789-0123-4567-890123456789
1994+
19041995* ` ` age` ` (list of strings): list of Age public keys.
19051996
19061997* ` ` pgp` ` (list of strings): list of PGP/GPG key fingerprints.
0 commit comments