I have three JSON files:
vault.json:
{
"aws":
{
"access_key_id": "My-Key-id",
"secret_access_key": "My-Access-Key"
},
"ssl":
{
"crt": "My-Crt",
"key": "My-Key",
"req": "My-Req"
}
}
input.json:
{
".cloud_cpi_key": {
"type": "wildcard_domain",
"configurable": true,
"credential": false,
"value": "vault-supplied-value",
"optional": false
},
".cloud_cpi_secret": {
"type": "wildcard_domain",
"configurable": true,
"credential": false,
"value": "vault-supplied-value",
"optional": false
},
".properties.networking_point_of_entry": {
"type": "selector",
"configurable": true,
"credential": false,
"value": "external_ssl",
"optional": false
},
".properties.networking_point_of_entry.external_ssl.ssl_rsa_certificate": {
"type": "rsa_cert_credentials",
"configurable": true,
"credential": true,
"value": {
"private_key_pem": "vault-supplied-value",
"cert_pem": "vault-supplied-value"
},
"optional": false
}
}
keyfile.json
{
".cloud_cpi_key.value": "aws.access_key_id",
".cloud_cpi_secret": "secret_access_key",
".properties.networking_point_of_entry.external_ssl.ssl_rsa_certificate.value.private_key_pem": "ssl.key",
".properties.networking_point_of_entry.external_ssl.ssl_rsa_certificate.value.cert_pem": "ssl.crt"
}
I'd like to update the second json file, with the values from the first json, based on the third json. can this be done via JQ to provide output.json?
output.json:
{
".cloud_cpi_key": {
"type": "string",
"configurable": true,
"credential": true,
"value": "My-Key-id",
"optional": false
},
".cloud_cpi_secret": {
"type": "string",
"configurable": true,
"credential": true,
"value": "My-Access-Key",
"optional": false
},
".properties.networking_point_of_entry": {
"type": "selector",
"configurable": true,
"credential": false,
"value": "external_ssl",
"optional": false
},
".properties.networking_point_of_entry.external_ssl.ssl_rsa_certificate": {
"type": "rsa_cert_credentials",
"configurable": true,
"credential": true,
"value": {
"private_key_pem": "My-Key",
"cert_pem": "My-Crt"
},
"optional": false
}
}
I can modify keyfile.json any way I like to make things easier, like
{
"fromkey": "aws.access_key_id"
"tokey": ".cloud_cpi_key.value"
},
{ "fromkey": ....
}
But no values may be placed in keyfile.json, only key names.
And I can modify vault.json, to put things in arrays, or what-have-you, but I cannot change the lowest levels, i.e. I cannot change:
{
"access_key_id": "My-Key-id",
"secret_access_key": "My-Access-Key"
}
I cannot modify input.json. How can I accomplish this with JQ?