apache-nifiapache-nifi-registry

Updating Nifi Sensitive properties from API


We are developing CI-CD for Nifi using Nifi registry & Azure Devops. We want it to be fully automated and are blocked on one issue. In our processors, we are using sensitive properties like passwords, etc. How can we update them from rest API or nipyapi module ?

Is it supported or what is the recommended way ?


Solution

  • Sensitive properties setup is straightforward like any other property setup.

    Sample snippet, using nipyapi, to update sensitive properties in GetTwitter processor.

    # Custom method to return all processors in a process group by using group name; 
    # Equivalent to nipyapi.canvas.list_all_processors(pg_id='root') but accepts group name
    def get_all_processors_in_group(processgroup_name, "name"):
        # ...
        # ...
    
    def update():
        processors_list = get_all_processors_in_group(processgroup_name, "name")
        processor = ... # Get 'GetTwitter' processor
    
        props = processor.component.config.properties
        props["Consumer Key"] = "Random key"
        props["Consumer Secret"] = "Random secret" # Sensitive value
        props["Access Token"] = "Random token"
        props["Access Token Secret"] = "Random token secret" # Sensitive value
    
        config = processor.component.config
        config.properties = props
    
        nipyapi.canvas.update_processor(processor, config)