Skip to content

aws_kms renderer either not working or not documented sufficiently #56247

Closed as not planned

Description

@viq

Description of Issue

It doesn't seem to be possible to use aws_kms renderer as described.

Setup

KMS configured on AWS, encryption and decryption verified via CLI tools.
Assigned pillar along the lines of

#!yaml|aws_kms
something: other
kms_test: AQ(...)A==

Data key generated with the command listed: aws kms generate-data-key --key-id some-key-uuid --key-spec AES_256 --query 'CiphertextBlob' --output text, giving me a long base64 encoded string.
Now I'm trying to put that data key into config.

aws_kms:
  data_key: !!binary "AQ(...)Q=="

results in saltmaster being quite unhappy, with lots of logs like

Feb 25 18:27:25 saltmaster.example.com salt-master[18086]: [ERROR   ] An un-handled exception from the multiprocessing process 'MWorker-0' was caught: 
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]: Traceback (most recent call last):                                                      
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/utils/process.py", line 760, in wrapped_run_func
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     return run_func()                                                                         
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/master.py", line 1139, in run               
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     self.key,                                                                               
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/master.py", line 1881, in __init__          
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     self.local = salt.client.get_local_client(self.opts['conf_file'])                       
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/client/__init__.py", line 100, in get_local_client
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     opts = salt.config.client_config(c_path)                                                
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/config/__init__.py", line 4092, in client_config
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     master_config(path, defaults=defaults)                                              
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/config/__init__.py", line 3887, in master_config
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     apply_sdb(opts)                                                                     
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/config/__init__.py", line 2530, in apply_sdb    
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     sdb_opts[key] = apply_sdb(opts, value)                                                    
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/config/__init__.py", line 2530, in apply_sdb
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     sdb_opts[key] = apply_sdb(opts, value)                                                  
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/config/__init__.py", line 2524, in apply_sdb
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     if isinstance(sdb_opts, six.string_types) and sdb_opts.startswith('sdb://'):            
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]: TypeError: startswith first arg must be bytes or a tuple of bytes, not str                    
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]: Process MWorker-0:                                                                      
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]: Traceback (most recent call last):                                                          
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap         
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     self.run()                                                                              
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/utils/process.py", line 771, in wrapped_run_func  
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     six.reraise(*sys.exc_info())                                                        
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/ext/six.py", line 693, in reraise               
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     raise value                                                                         
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/utils/process.py", line 760, in wrapped_run_func
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     return run_func()
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/master.py", line 1139, in run
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     self.key,
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/master.py", line 1881, in __init__
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     self.local = salt.client.get_local_client(self.opts['conf_file']) 
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/client/__init__.py", line 100, in get_local_client
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     opts = salt.config.client_config(c_path)
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/config/__init__.py", line 4092, in client_config
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     master_config(path, defaults=defaults)
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/config/__init__.py", line 3887, in master_config
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     apply_sdb(opts)
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/config/__init__.py", line 2530, in apply_sdb
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     sdb_opts[key] = apply_sdb(opts, value)
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/config/__init__.py", line 2530, in apply_sdb
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     sdb_opts[key] = apply_sdb(opts, value)
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:   File "/usr/lib/python3/dist-packages/salt/config/__init__.py", line 2524, in apply_sdb
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]:     if isinstance(sdb_opts, six.string_types) and sdb_opts.startswith('sdb://'):
Feb 25 18:27:25 saltmaster.example.com salt-master[18086]: TypeError: startswith first arg must be bytes or a tuple of bytes, not str

and even test.ping not working with a message about a timeout.

Putting it in config like

aws_kms:
  data_key: "AQ(...)Q=="

makes the master work, but attempt to get that pillar results in following logs:

2020-02-25 18:32:03,840 [salt.pillar      :750 ][CRITICAL][19017] Rendering SLS 'cf_salt_runner' failed, render error:
aws_kms:data_key is not a valid KMS data key
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/renderers/aws_kms.py", line 169, in _api_decrypt
    return kms.decrypt(CiphertextBlob=data_key)
  File "/usr/lib/python3/dist-packages/botocore/client.py", line 324, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python3/dist-packages/botocore/client.py", line 622, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidCiphertextException: An error occurred (InvalidCiphertextException) when calling the Decrypt operation: 

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/pillar/__init__.py", line 745, in render_pstate
    **defaults)
  File "/usr/lib/python3/dist-packages/salt/template.py", line 101, in compile_template
    ret = render(input_data, saltenv, sls, **render_kwargs)
  File "/usr/lib/python3/dist-packages/salt/renderers/aws_kms.py", line 260, in render
    return _decrypt_object(data, translate_newlines=translate_newlines)
  File "/usr/lib/python3/dist-packages/salt/renderers/aws_kms.py", line 244, in _decrypt_object
    translate_newlines=translate_newlines)
  File "/usr/lib/python3/dist-packages/salt/renderers/aws_kms.py", line 237, in _decrypt_object
    translate_newlines=translate_newlines)
  File "/usr/lib/python3/dist-packages/salt/renderers/aws_kms.py", line 218, in _decrypt_ciphertext
    data_key = _base64_plaintext_data_key()
  File "/usr/lib/python3/dist-packages/salt/renderers/aws_kms.py", line 202, in _base64_plaintext_data_key
    plaintext_data_key = _plaintext_data_key()
  File "/usr/lib/python3/dist-packages/salt/renderers/aws_kms.py", line 188, in _plaintext_data_key
    response = _api_decrypt()
  File "/usr/lib/python3/dist-packages/salt/renderers/aws_kms.py", line 176, in _api_decrypt
    six.raise_from(config_error, orig_exc)
  File "<string>", line 2, in raise_from
salt.exceptions.SaltConfigurationError: aws_kms:data_key is not a valid KMS data key
2020-02-25 18:32:03,841 [salt.pillar      :1044][CRITICAL][19017] Pillar render error: Rendering SLS 'cf_salt_runner' failed. Please see master log for details.

Steps to Reproduce Issue

Attempt to use aws_kms renderer. Get results as described above.

Versions Report

(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)

# salt --versions-report
Salt Version:
           Salt: 3000

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: 2.0.3
      gitpython: 2.1.8
         Jinja2: 2.10
        libgit2: 0.26.0
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.26.2
         Python: 3.6.9 (default, Nov  7 2019, 10:44:02)
   python-gnupg: 0.4.1
         PyYAML: 3.12
          PyZMQ: 16.0.2
          smmap: 2.0.3
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.2.5

System Versions:
           dist: Ubuntu 18.04 bionic
         locale: UTF-8
        machine: x86_64
        release: 4.15.0-1060-aws
         system: Linux
        version: Ubuntu 18.04 bionic
# dpkg -l '*boto*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                                  Version                         Architecture                    Description
+++-=====================================================-===============================-===============================-===============================================================================================================
un  python-boto                                           <none>                          <none>                          (no description available)
ii  python3-boto                                          2.44.0-1ubuntu2.18.04.0         all                             Python interface to Amazon's Web Services - Python 3.x
ii  python3-boto3                                         1.4.2-1                         all                             Python interface to Amazon's Web Services - Python 3.x
ii  python3-botocore                                      1.8.48+repack-1                 all                             Low-level, data-driven core of boto 3 (Python 3)

Activity

  1. bryceml commented on Feb 26, 2020

    @bryceml
    Contributor

    Documentation is re-added to the master branch here: #55914

  2. viq commented on Feb 26, 2020

    @viq
    ContributorAuthor

    Yes, but that documentation is still incorrect or incomplete.

  3. added
    v3000.1
    documentation
    and removed on Apr 14, 2020
  4. added this to the Approved milestone on Apr 14, 2020
  5. added
    doc-rework
    and removed
    v3000.1
    on Apr 15, 2020
  6. sagetherage commented on Apr 15, 2020

    @sagetherage
    Contributor

    @saltstack/docs-working-group

  7. sushantkumr commented on May 13, 2020

    @sushantkumr

    Hey ! Any progress on this? We are facing the same issue.

  8. 17 remaining items

  9. danlsgiga commented on Apr 4, 2022

    @danlsgiga
    Contributor

    Worth noting... Ubuntu 18.04 Bionic does not seem to support up-to-date boto versions, which breaks compatibility with this renderer due to the salt.utils.versions.check_boto_reqs() check.

  10. added
    severity-high
    on Apr 18, 2022
  11. dwoz commented on Oct 28, 2026

    @dwoz
    Contributor

    Closing — the aws_kms renderer was moved out of Salt core in the 3007.x → 3008.x migration. There is no actively-maintained community saltext for it yet. If you depend on it and want it maintained, consider standing up a saltext using the copier template at https://salt-extensions.github.io/salt-extension-copier/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Salt-CloudZDbotodoc-reworkdocumentationseverity-hightime-estimate-sprint

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions